Re: Aborting "git commit --interactive" discards updates to index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



demerphq <demerphq@xxxxxxxxx> writes:

> On 27 June 2011 17:59, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> The latest feature release Git 1.7.6 is available at the usual
>> places:
>>
>>  http://www.kernel.org/pub/software/scm/git/
> [snip]
>>  * Aborting "git commit --interactive" discards updates to the index
>>   made during the interactive session.
>
> Hi, I am wondering why this change was made?

I wasn't directly involved in this particular part of the design of what
should happen to the index when a commit is aborted, so I would be a bad
person to give you the first answer, but let's try.

If a "commit" session is aborted, it is logical to revert whatever has
been done inside that session as a single logical unit, so I do not
particularly find the current behaviour so confusing. It might even make
more sense if we update "commit -i" and "commit -a" to also revert the
index modification when the command is aborted for consistency.

You are welcome to rehash the age old discussion, though. Personally I do
not care very deeply either way. I would never use "commit --interactive"
myself, and I would not encourage others to use it, either, even if we do
not worry about the behaviour when a commit is aborted.

One thread of interest (there are others, as this change was rerolled at
least a few times) may be

    http://thread.gmane.org/gmane.comp.version-control.git/173033/focus=173035

Having said all that,...

> .... I am writing this after spending about 45 minutes showing a
> colleague how to use git commit --interactive, when we realized that
> we had forgotten to add a file....

... if your partial commit is so complex that you need to spend 45 minutes
to sift what to be commited and what to be left out, you are much better
off to run "git add -i" to prepare the index, "git stash save -k" to check
out what is to be committed (and stash away what are to be left out) so
that you can make sure what you are committing is what you thought are
committing (by asking "git diff" and "make test" for example), and after
convincing yourself that you made a good state in the index, make a commit
with "git commit" (without any other arguments) and conclude it with "git
stash pop" to recover the changes that you decided to leave out.

"commit --interactive" robs me from that crucial "verification" step, and
that is why I wouldn't be a user or an advocate of this "misfeature".

By the way, why did you draw Ævar into this discussion? I do not think he
was involved in any way with the design or implementation of this command.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]