cg-status presently only cares about the cache (by parsing the output of git-update-cache and git-ls-files), when it should look at the tree in HEAD.
This patch fixes this, by using git-diff-cache HEAD instead (using git-diff-files only to detect the difference between missing files and cg-rm'd ones).
It also uses the exclusion mechanism in git-ls-files, instead of parsing git-ls-files output, and adds '*~' and '#*' to the list of patterns excluded by default.
Signed-off-by: Dan Holmsand <holmsand@gmail.com>
Show changes to cg-status +13 −22
diff --git a/cg-status b/cg-status --- a/cg-status +++ b/cg-status @@ -7,33 +7,24 @@ . ${COGITO_LIB}cg-Xlib +[ 0 -eq $# ] || die "no arguments allowed" + EXCLUDEFILE=$_git/exclude EXCLUDE= if [ -f $EXCLUDEFILE ]; then EXCLUDE="--exclude-from=$EXCLUDEFILE" fi -{ - git-ls-files -z -t --others --deleted --unmerged $EXCLUDE -} | sort -z -k 2 | xargs -0 sh -c ' -while [ "$1" ]; do - tag=${1% *}; - filename=${1#* }; - case "$filename" in - *.[ao] | tags | ,,merge*) ;; - *) echo "$tag $filename";; - esac - shift -done -' padding +git-update-cache --refresh > /dev/null + +git-ls-files --others --exclude='*.[ao]' --exclude='.*' --exclude=tags \ + --exclude='*~' --exclude='#*' \ + --exclude=',,merge*' $EXCLUDE | sed 's,^,? ,' -{ - git-update-cache --refresh -} | cut -f 1 -d ":" | xargs sh -c ' -while [ "$1" ]; do - tag="M"; - filename=${1%: *}; - echo "$tag $filename"; - shift +git-diff-cache HEAD | cut -f5- -d' ' | +while IFS=$'\t' read -r mode file; do + if [ "$mode" = D ]; then + [ "$(git-diff-files "$file")" ] && mode=! + fi + echo "$mode $file" done -' padding