[PATCH 1/2] update cg-Xignore
From: David Greaves <hidden>
Date: 2016-06-15 22:41:57
Update Documentation to Jonas' style Add -0 to allow null terminated lines (slightly buggy) Add -t to cope with git-ls-files -t output Signed-off-by: David Greaves <redacted> --- commit 2fca920e6d3ccb92e9782bcf02f860b8333e23d9 tree d2490ad0bc8b38647c6baff9da3e72c0f25e9f35 parent fbb4054b80189c58f0b289dc34320f2b2de56d24 author David Greaves [off-list ref] Fri, 13 May 2005 23:17:18 +0100 committer David Greaves <david@ash.(none)> Fri, 13 May 2005 23:17:18 +0100 cg-Xignore | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 41 insertions(+), 16 deletions(-) Index: cg-Xignore ===================================================================
--- 9a39ca9b1e7dd28ddb4a1908ccb59787f432d752/cg-Xignore (mode:100755)
+++ d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-Xignore (mode:100755)@@ -1,14 +1,20 @@ #!/usr/bin/env bash # -# Takes a list of files on stdin and only passes valid ones agording to .git/ignore +# Takes a list of files on stdin and only passes valid ones according to .git/ignore # Copyright (c) David Greaves, 2005 # +# DESCRIPTION +# ----------- # 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 +# OPTIONS +# ------- +# -0:: +# processes null terminated lines +# this is buggy and uses \n internally so any files with a \n +# in will break it. Tough - don't use shell scripts. +# # -debug:: # produce helpful debug output #
@@ -24,18 +30,26 @@ # -h:: # passes symbolic links # -# The default is to pass all file types that are not ignored. +# -t:: +# cope with files preceded by a 'tag'. eg from git-ls-files -t +# +# The default is to pass all file types. # # 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: +# +# Example .git/ignore +# ------------------- +# # # bash regexps (not globs) # ^\.[^/] # /\. # /$ # .*\.o$ +# +USAGE="cg-Xignore [-0] [-debug] [-q] [-f] [-h] [-d] [-t] < file-list >useful-file-list" # This doesn't allow the -h which is the [ arg for symlinks...
@@ -44,19 +58,22 @@ 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 +stripzero='cat' +rezero='cat' while [ $# -gt 0 ]; do case $1 in + "-0") + # doesn't work :( + #zerosep=$'-d \0' + stripzero='tr "\000" "\n"' + rezero='tr "\n" "\000"' + ;; "-f") pass_all=0 pass_files=1
@@ -75,6 +92,9 @@ "-debug") debug=1 ;; + "-t") + tagged=1 + ;; esac shift done
@@ -92,10 +112,15 @@ exec 4>/dev/null fi - # Strip out the common leading ./ allowing "find ." -sed 's:^./::' | \ +$stripzero | sed "s:^./::" | \ while read $zerosep file; do + tag="" + if [ $tagged ]; then + tag=${file% *} + fname=${file#* } + file=$fname + fi echo "consider file: $file" >&4 ignore=0 if [ -f $IGNORE_FILE ]; then
@@ -112,7 +137,6 @@ fi done fi - echo "passing file: $file" >&4 if [ $ignore != "1" \ -a \( $pass_all -eq 1 \
@@ -121,6 +145,7 @@ -o \( $pass_links -eq 1 -a -h "$file" \) \ \) \ ]; then - echo "$file" + echo "passing file: $file" >&4 + echo "$tag$file" fi -done +done | $rezero