{"thread":{"id":"604","subject":"[PATCH 1/2] update cg-Xignore","startedAt":"2005-05-13T22:31:52Z","lastAt":"2005-05-13T22:31:52Z","messageCount":1,"participants":["David Greaves"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"3256","messageId":"E1DWihE-000790-Ub@ash.dgreaves.com","threadId":"604","inReplyTo":null,"subject":"[PATCH 1/2] update cg-Xignore","fromName":"David Greaves","fromEmail":"david@dgreaves.com","sentAt":"2005-05-13T22:31:52Z","receivedAt":"2005-05-13T22:31:52Z","isPatch":true,"sender":{"key":"david@dgreaves.com","avatar":"https://gravatar.com/avatar/ca67bad50999edcdd137c9a65da2381557d175bea99ae956afdabc5785e42b79?d=mp&s=160"},"body":"Update Documentation to Jonas' style\nAdd -0 to allow null terminated lines (slightly buggy)\nAdd -t to cope with git-ls-files -t output\n\nSigned-off-by: David Greaves <david@dgreaves.com>\n\n---\ncommit 2fca920e6d3ccb92e9782bcf02f860b8333e23d9\ntree d2490ad0bc8b38647c6baff9da3e72c0f25e9f35\nparent fbb4054b80189c58f0b289dc34320f2b2de56d24\nauthor David Greaves <david@dgreaves.com> Fri, 13 May 2005 23:17:18 +0100\ncommitter David Greaves <david@ash.(none)> Fri, 13 May 2005 23:17:18 +0100\n\n cg-Xignore |   57 +++++++++++++++++++++++++++++++++++++++++----------------\n 1 files changed, 41 insertions(+), 16 deletions(-)\n\nIndex: cg-Xignore\n===================================================================\n--- 9a39ca9b1e7dd28ddb4a1908ccb59787f432d752/cg-Xignore  (mode:100755)\n+++ d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-Xignore  (mode:100755)\n@@ -1,14 +1,20 @@\n #!/usr/bin/env bash\n #\n-# Takes a list of files on stdin and only passes valid ones agording to .git/ignore\n+# Takes a list of files on stdin and only passes valid ones according to .git/ignore\n # Copyright (c) David Greaves, 2005\n #\n+# DESCRIPTION\n+# -----------\n # This filter implements cogito ignore rules and should typically be used in find pipelines\n #\n-# Synopsis\n-# cg-Xignore [-debug] [-f] [-h] [-d] < file-list >useful-file-list\n #\n-# Options\n+# OPTIONS\n+# -------\n+# -0::\n+#     processes null terminated lines\n+#     this is buggy and uses \\n internally so any files with a \\n\n+#     in will break it. Tough - don't use shell scripts.\n+#\n # -debug::\n #     produce helpful debug output\n #\n@@ -24,18 +30,26 @@\n # -h::\n #     passes symbolic links\n #\n-# The default is to pass all file types that are not ignored.\n+# -t::\n+#     cope with files preceded by a 'tag'. eg from git-ls-files -t\n+#\n+# The default is to pass all file types.\n #\n # Note that the .git/ignore file contains multiple expressions, 1 per line\n # Lines beginning with a '#' are ignored (allowing comments)\n # These are 'bash regular expressions' not glob patterns\n # This allows ignore rules to take the directory into account\n-# Suggested contents:\n+#\n+# Example .git/ignore\n+# -------------------\n+#\n #   # bash regexps (not globs)\n #   ^\\.[^/]\n #   /\\.\n #   /$\n #   .*\\.o$\n+#\n+USAGE=\"cg-Xignore [-0] [-debug] [-q] [-f] [-h] [-d] [-t] < file-list >useful-file-list\"\n \n \n # This doesn't allow the -h which is the [ arg for symlinks...\n@@ -44,19 +58,22 @@\n \n IGNORE_FILE=\"$_git/ignore\"\n \n-if [ \"$1\" = \"-0\" ]; then\n-    # doesn't work :(\n-    zerosep=$'-d \"\\0\"'\n-    shift\n-fi\n \n # Defaults\n pass_files=0\n pass_dirs=0\n pass_links=0\n pass_all=1\n+stripzero='cat'\n+rezero='cat'\n while [ $# -gt 0 ]; do\n     case $1 in\n+\t\"-0\")\n+            # doesn't work :(\n+\t    #zerosep=$'-d \\0'\n+\t    stripzero='tr \"\\000\" \"\\n\"'\n+\t    rezero='tr \"\\n\" \"\\000\"'\n+\t    ;;\n \t\"-f\")\n \t    pass_all=0\n \t    pass_files=1\n@@ -75,6 +92,9 @@\n \t\"-debug\")\n \t    debug=1\n \t    ;;\n+\t\"-t\")\n+\t    tagged=1\n+\t    ;;\n \tesac\n     shift\n done\n@@ -92,10 +112,15 @@\n     exec 4>/dev/null\n fi\n \n-\n # Strip out the common leading ./ allowing \"find .\"\n-sed 's:^./::' | \\\n+$stripzero | sed \"s:^./::\" | \\\n while read $zerosep file; do\n+    tag=\"\"\n+    if [ $tagged ]; then\n+\ttag=${file% *}\n+\tfname=${file#* }\n+\tfile=$fname\n+    fi\n     echo \"consider file: $file\" >&4\n     ignore=0\n     if [ -f $IGNORE_FILE ]; then\n@@ -112,7 +137,6 @@\n \t    fi\n \tdone\n     fi\n-    echo \"passing file: $file\" >&4\n     \n     if [ $ignore != \"1\" \\\n \t-a \\( $pass_all -eq 1 \\\n@@ -121,6 +145,7 @@\n \t   -o \\( $pass_links -eq 1 -a -h \"$file\" \\) \\\n \t   \\) \\\n \t]; then\n-\techo \"$file\"\n+\techo \"passing file: $file\" >&4\n+\techo \"$tag$file\"\n     fi\n-done\n+done | $rezero\n"}]}