Re: [BUG] - "git commit --amend" commits, when exiting the editor with no changes written
- From
- Eugene Sajine <euguess@gmail.com>
- Date
- Feb 2, 2010, 20:47 UTC
- Message-ID
- <76c5b8581002021247j6df8f609ld9e5d87a060a5423@mail.gmail.com>
- In-Reply-To
- <32541b131002021227o1ec9f369w6096e85382857b8a@mail.gmail.com>
On Tue, Feb 2, 2010 at 3:27 PM, Avery Pennarun <apenwarr@gmail.com> wrote:
Show 26 quoted lines
> On Tue, Feb 2, 2010 at 3:14 PM, Jacob Helwig <jacob.helwig@gmail.com> wrote:
>> On Tue, Feb 2, 2010 at 12:07, Eugene Sajine <euguess@gmail.com> wrote:
>>> When git commit --amend is executed it fires up vi so i can change the
>>> commit message. If I have something staged, then when I'm exiting vi
>>> using :q (without doing/writing any changes), it still commits
>>> everything staged with old message.
>>>
>>> I believe it should actually abort amending and return to the state
>>> before the "git commit --amend" was issued.
>>
>> I don't think this is actually the right way to go. A _very_ common
>> use case for "commit --amend" is to add things to the previous commit,
>> without changing the commit message at all. Yes, you can avoid having
>> to fire up the editor at all in this case, but it's still a perfectly
>> valid thing to want to do.
>
> I agree and I do this all the time. However, I've also done it
> accidentally before I learned the "remove the commit message and save"
> trick.
>
> Perhaps what's really missing is more documentation of how to
> "unamend" if you change your mind :) I happen to know about "git
> reset HEAD@{1}" but it's not terribly obvious.
>
> Avery
>Well, i understand this logic but it seems to me that the issue is a little bit deeper than that. I just realized that the "rebase -i" is doing the same thing.
If you're just exiting the vi using :q without writing changes it will perform rebase! I'm 100% sure it is not OK.
So, it seems that it will do that every time it has some *prepopulated* message in the editor, so it doesn't understand when changes are written and when they are not.
I believe all those actions should be treated exactly the same way as the commit itself. If I'm writing/saving changes - it is good to go. If not - abort. I.e. the message can be prepopulated in the editor, but it should be the same state as when you create a new message for commit, i.e. git should not know anything about that message.
Thanks, Eugene