From: David Greaves <david@dgreaves.com>
To: Petr Baudis <pasky@ucw.cz>, GIT Mailing Lists <git@vger.kernel.org>
Subject: [PATCH] Ignore file filter
Date: Thu, 12 May 2005 22:30:32 +0100 [thread overview]
Message-ID: <4283CAF8.3050304@dgreaves.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
Hi Petr
This is an inline filter that introduces the concept of .git/ignore
It is intended to be used within the cogito scripts like the other cg-X*
files.
Signed-off-by: David Greaves <david@dgreaves.com>
--
[-- Attachment #2: cg-Xignore --]
[-- Type: text/plain, Size: 2346 bytes --]
#!/usr/bin/env bash
#
# Takes a list of files on stdin and only passes valid ones agording to .git/ignore
# Copyright (c) David Greaves, 2005
#
# This filter implements cogito ignore rules and should typically be used in find pipelines
#
# Synopsis
# cg-Xignore [-debug] [-f] [-h] [-d] < file-list >useful-file-list
#
# Options
# -debug::
# produce helpful debug output
#
# -q::
# don't say what paths are ignored
#
# -f::
# passes files
#
# -d::
# passes directories
#
# -h::
# passes symbolic links
#
# The default is to pass all file types that are not ignored.
#
# Note that the .git/ignore file contains multiple expressions, 1 per line
# Lines beginning with a '#' are ignored (allowing comments)
# These are 'bash regular expressions' not glob patterns
# This allows ignore rules to take the directory into account
# Suggested contents:
# # bash regexps (not globs)
# ^\.[^/]
# /\.
# /$
# .*\.o$
# This doesn't allow the -h which is the [ arg for symlinks...
#. ${COGITO_LIB}cg-Xlib
_git=${GIT_DIR:-.git}
IGNORE_FILE="$_git/ignore"
if [ "$1" = "-0" ]; then
# doesn't work :(
zerosep=$'-d "\0"'
shift
fi
# Defaults
pass_files=0
pass_dirs=0
pass_links=0
pass_all=1
while [ $# -gt 0 ]; do
case $1 in
"-f")
pass_all=0
pass_files=1
;;
"-d")
pass_all=0
pass_dirs=1
;;
"-h")
pass_all=0
pass_links=1
;;
"-q")
quiet=1
;;
"-debug")
debug=1
;;
esac
shift
done
# save stderr
exec 5>&2
if [ $quiet ]; then
# turn off noise
exec 2>&-
fi
if [ $debug ]; then
exec 4>&5
else
exec 4>/dev/null
fi
# Strip out the common leading ./ allowing "find ."
sed 's:^./::' | \
while read $zerosep file; do
echo "consider file: $file" >&4
ignore=0
if [ -f $IGNORE_FILE ]; then
exec 3<$IGNORE_FILE
while read -r -u3 patt ; do
if [[ $patt =~ "^\w*#" ]]; then
continue
fi
echo "consider pattern: $patt" >&4
if [[ $file =~ $patt ]]; then
ignore=1
echo "Ignoring $file because of $patt" >&2
break
fi
done
fi
echo "passing file: $file" >&4
if [ $ignore != "1" \
-a \( $pass_all -eq 1 \
-o \( $pass_files -eq 1 -a -f $file \) \
-o \( $pass_dirs -eq 1 -a -d $file \) \
-o \( $pass_links -eq 1 -a -h $file \) \
\) \
]; then
echo $file
fi
done
next reply other threads:[~2005-05-12 21:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-12 21:30 David Greaves [this message]
[not found] ` <7v64xodshs.fsf@assigned-by-dhcp.cox.net>
2005-05-13 8:50 ` [PATCH] Ignore file filter David Greaves
2005-05-13 23:12 ` Petr Baudis
2005-05-14 8:28 ` David Greaves
2005-05-14 9:01 ` Junio C Hamano
2005-05-14 14:24 ` Petr Baudis
2005-05-14 15:13 ` David Greaves
2005-05-14 15:30 ` [RFD] Ignore rules Petr Baudis
2005-05-14 17:51 ` David Greaves
2005-05-14 18:12 ` Junio C Hamano
2005-05-15 1:11 ` Jon Seymour
2005-05-15 6:05 ` Junio C Hamano
2005-05-15 6:52 ` Junio C Hamano
2005-05-15 20:27 ` [RFD] git-run-with-user-path Junio C Hamano
2005-05-16 9:35 ` [RFD] Ignore rules Matthias Urlichs
2005-05-16 16:05 ` David Greaves
2005-05-14 12:21 ` [PATCH] Ignore file filter Petr Baudis
2005-05-14 14:28 ` David Greaves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4283CAF8.3050304@dgreaves.com \
--to=david@dgreaves.com \
--cc=git@vger.kernel.org \
--cc=pasky@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.