{"thread":{"id":"762","subject":"[PATCH] Make cg-status report added/removed files correctly","startedAt":"2005-05-29T22:11:09Z","lastAt":"2005-05-29T22:11:09Z","messageCount":1,"participants":["Dan Holmsand"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4201","messageId":"d7deh7$sbk$1@sea.gmane.org","threadId":"762","inReplyTo":null,"subject":"[PATCH] Make cg-status report added/removed files correctly","fromName":"Dan Holmsand","fromEmail":"holmsand@gmail.com","sentAt":"2005-05-29T22:11:09Z","receivedAt":"2005-05-29T22:11:09Z","isPatch":true,"sender":{"key":"holmsand@gmail.com","avatar":"https://gravatar.com/avatar/5c722084bafd85e754a02efad01fe69107eb6f393253c49232c5c9f7faa974df?d=mp&s=160"},"body":"cg-status presently only cares about the cache (by parsing the output of \ngit-update-cache and git-ls-files), when it should look at the tree in HEAD.\n\nThis patch fixes this, by using git-diff-cache HEAD instead (using \ngit-diff-files only to detect the difference between missing files and \ncg-rm'd ones).\n\nIt also uses the exclusion mechanism in git-ls-files, instead of parsing \ngit-ls-files output, and adds '*~' and '#*' to the list of patterns \nexcluded by default.\n\nSigned-off-by: Dan Holmsand <holmsand@gmail.com>\n\n\ndiff --git a/cg-status b/cg-status\n--- a/cg-status\n+++ b/cg-status\n@@ -7,33 +7,24 @@\n \n . ${COGITO_LIB}cg-Xlib\n \n+[ 0 -eq $# ] || die \"no arguments allowed\"\n+\n EXCLUDEFILE=$_git/exclude\n EXCLUDE=\n if [ -f $EXCLUDEFILE ]; then\n \tEXCLUDE=\"--exclude-from=$EXCLUDEFILE\"\n fi\n \n-{\n-\tgit-ls-files -z -t --others --deleted --unmerged $EXCLUDE\n-} | sort -z -k 2 | xargs -0 sh -c '\n-while [ \"$1\" ]; do\n-\ttag=${1% *};\n-\tfilename=${1#* };\n-\tcase \"$filename\" in\n-\t*.[ao] | tags | ,,merge*) ;;\n-\t*)   echo \"$tag $filename\";;\n-\tesac\n-\tshift\n-done\n-' padding\n+git-update-cache --refresh > /dev/null\n+\n+git-ls-files --others --exclude='*.[ao]' --exclude='.*' --exclude=tags \\\n+\t--exclude='*~' --exclude='#*' \\\n+\t--exclude=',,merge*' $EXCLUDE | sed 's,^,? ,'\n \n-{\n-\tgit-update-cache --refresh\n-} | cut -f 1 -d \":\" | xargs sh -c '\n-while [ \"$1\" ]; do\n-\ttag=\"M\";\n-\tfilename=${1%: *};\n-\techo \"$tag $filename\";\n-\tshift\n+git-diff-cache HEAD | cut -f5- -d' ' | \n+while IFS=$'\\t' read -r mode file; do\n+\tif [ \"$mode\" = D ]; then\n+\t\t[ \"$(git-diff-files \"$file\")\" ] && mode=!\n+\tfi\n+\techo \"$mode $file\"\n done\n-' padding\n"}]}