Jonathan Nieder <jrnie...@gmail.com> writes: > Hi again, > > Goswin von Brederlow wrote: > >> so far two people have suggested an alias >> for this and both have completly failed to achived the desired result. > > I had thought Adam already suggested using âgit diff-index --cached > --quiet HEADâ [1]. > > You can do so like this: > > cat <<-EOF >$HOME/bin/git-ci > #!/bin/sh > cleanindex() { git diff-index --cached --quiet HEAD; }
Thanks. That is the missing test. > if test "$1" != "-h" > then > echo >&2 usage: git ci && > exit 129 > fi > if test "$#" != 0 > then > echo >&2 Please use git commit directly. > if cleanindex > then > echo >&2 '(no staged changes)' > else > git diff --cached --name-status > fi > exit 129 > fi > if cleanindex > then > exec git commit -a > else > exec git commit > fi > EOF > chmod +x $HOME/bin/git-ci > > But dense as I am, I still canât imagine why > > echo '[alias] ci = commit -a' >>$HOME/.gitconfig > > wouldnât be better in every way (especially if Jakubâs > commit.preserveindex is enabled). Because with the above test it knows when -a is wrong and won't use it. >> If you know of a test to check if an index exists or not, preferably one >> that does consider new files being added or files being removed as >> "index exists", then please do speak up. > > test -e .git/index > > I know, not what you meant. But the condition you are looking for is > âstaged content does not match the last commitâ, not âthe tool has > suddenly entered a different modeâ. > > Hope that helps, > Jonathan > > [1] Well, he did: > http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/698001/focus=145581 Must have overlooked that mail, sorry. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org