Re: [Census] So who uses git?
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Feb 1, 2006, 17:11 UTC
- Message-ID
- <Pine.LNX.4.64.0602010856150.21884@g5.osdl.org>
- In-Reply-To
- <7v4q3jlgw2.fsf@assigned-by-dhcp.cox.net>
On Tue, 31 Jan 2006, Junio C Hamano wrote:
Show 5 quoted lines
> > Taken together with your "during a partially conflicted merge" > example, it feels to me that the simplest safety valve would be > to refuse "git commit paths..." if the index does not exactly > match HEAD. Not just mentioned paths but anywhere.
But at that point, the existing "git commit" semantics actually are the ones we'd use, and the only difference ends up being that we error out if the index doesn't match HEAD.
The problem with that is that it appears that some of the people who don't like the current "git commit <filename>" thing _do_ actually understand the index, but they want to commit just that one file.
So at least from my understanding, I think Dscho was arguing for the new semantics of "git commit <file>" to _work_, but to only commit <file>, even if he does understand the index perfectly well, and might have done a "git add" or updated a file for some other reason..
Btw, one thing that _can_ be confusing is that you do
git commit fileA
and then when you edit the commit message, you realize that you don't actually want to do this at all, so you exit out of the editor without changes (which aborts the commit). Now "git commit" will not actually have done the commit, but it _will_ have done the "git-update-index" on that file.
So next time, when you do
git commit fileB
you'll currently commit _both_ fileA and fileB.
This is, in my opinion, the biggest argument for the suggested _new_ semantics: if you explicitly name a set of files, it should always do a
# Verify current state parent=$(git-rev-parse --verify HEAD) || exit
# Verify that the current index is ok in the named files a=$(git-diff-files --name-only --cached $parent "$@") || exit if [ "$a" ]; then echo -e >&2 "Files are changed in the index:\n $a" exit 2 fi
# create the new tree object export GIT_INDEX_FILE=tmpfile newtree=$(git-read-tree $parent && git-update-index "$@" && git-write-tree) || exit
# edit message ... edit message ..
# do commit newhead=$(git-commit-tree -p $parent < msg) git-update-ref HEAD $newhead $parent
or similar. That has the advantage that if we _do_ decide to break out of the commit, we will not have changed the current index (only the temporary one).
Linus