Re: [PATCH] Use a temporary index for interactive git-commit
From: Conrad Irwin <hidden>
Date: 2016-06-15 22:50:19
On 30 December 2010 04:33, Jeff King [off-list ref] wrote:
this behavior will not apply to "git add -p". So doesn't that introduce a new confusing inconsistency, that ^C from "git commit -p" abandons changes entirely, but from "git add -p" will silently stage changes?
That is an interesting observation. The intention of the commit was not to make the interactive add atomic, just isolated from the real index (much like git commit /path/to/file.c or git commit -a). This means that if you leave the commit message empty (even after a successful git-add--interactive) you have not staged any new files. I'd agree that it would also make sense for git-add--interactive to be atomic, so that when you abort it forgets everything you've told it to do (and that this patch highlights that very nicely). At the moment git-add--interactive is atomic at a file level, i.e. it remembers each decision for git add --interactive, and for git add --patch, it saves your decisions only once you've got to the end of a file (not that you'd notice). While I could fix git add -p in the same manner as git commit -p, by using a temporary isolated index, it would be better to change git-add--interactive directly, and thus git checkout -p and git reset -p too. Conrad