Re: Please default to 'commit -a' when no changes were added
- From
Adam Brewster <adambrewster@gmail.com>
- Date
- Apr 23, 2010, 00:04 UTC
- Message-ID
- <l2vc376da901004221704l55f06952z4380c398783e5f9f@mail.gmail.com>
- In-Reply-To
- <x2l2cfc40321004221538qade3dd4dkc149f2748b94ef81@mail.gmail.com>
Show 6 quoted lines
> > Perhaps I am missing something, but I would have thought git > diff-files --quiet would be more useful in this context... > > jon. >
Maybe so. I really just meant to suggest that if you need something more complicated than a simple git-command, you can put whatever you want in a shell script and use it like an alias.
Then I learned that git aliases can be pretty fancy if they start with "!sh -c".
After looking at the man pages a bit more, I think "git diff --cached --quiet" or "git diff-index --cached --quiet HEAD" are the right condition. git diff-files will compare the working copy to the index, so this sequence
vi file1 vi file2 git add file1 git ci
would call commit -a, and I think that's wrong.
I also now realize that some use needs to be made of the arguments. As I sent it the first time, "git ci -m whatever" doesn't work as it should. Adding "$@" to the git commit call doesn't work either because it breaks "git ci filename" if there is no index (it calls "git commit -a filename").