Re: [PATCH] builtin-commit: add --cached to operate only on index
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Nov 27, 2007, 18:18 UTC
- Message-ID
- <81b0412b0711271018m6419b076n269a0175494fac84@mail.gmail.com>
- In-Reply-To
- <7vfxyrd2x2.fsf@gitster.siamese.dyndns.org>
On 27/11/2007, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> On the other hand, when we know we do not have to _show_ the list of > staged/modified/untracked files (i.e. we already have the commit log > message via -m, -F, or -C and we were told not to invoke editor), we do > not have to call run_status(), only to discard its output. In such a > case, we are calling it only to see if we have something committable, > and we should be able to optimize THAT without being told by the user > with this new option. Incidentally I just checked the scripted version; > it does not do this optimization (git-commit.sh, ll. 514-517). The C > rewrite in 'next' does not have it in either (builtin-commit.c, > ll. 387-390). When no_edit is in effect, I think these two places can > be replaced with an equivalent of "diff-index --cached HEAD --" (which > should not hit the work tree at all) to see if there is anything to be > committed. For initial commit the check would obviously be "is the > index empty?" instead.
This is of course very useful optimization, and will speed up things everywhere (and especially here).
But still: I didn't mean it. I really meant the interactive case, with editor and prepared commit message which has status list. Sometimes this list is the reason why a commit is aborted: I notice that I'm committing something I didn't really intend to.