Re: [BUG] - "git commit --amend" commits, when exiting the editor with no changes written
- From
- Eugene Sajine <euguess@gmail.com>
- Date
- Feb 2, 2010, 22:31 UTC
- Message-ID
- <76c5b8581002021431o2b5073a0s42b273b6d61893db@mail.gmail.com>
- In-Reply-To
- <77153A83-158D-4D36-A622-7AA3947C7D52@wincent.com>
> > Why should Git care about how you exited from your EDITOR? All it should > care about is the contents of the commit message, and the exit code of the > editor.
It doesn't matter which editor is used. The only thing that matters is that you saving or not saving on exit from editor. If not saving - abort the action.
Show 11 quoted lines
> >> For example IF there is a variable somewhere where message is stored: >> For new commit message it is NULL and when commit is ready it is set >> up to "message". We check If it is not empty and not NULL (:wq >> executed), then we can commit. >> For "prepopulated" messages this variable can be is set to "message" >> from the beginning, so it doesn't matter if you're writing changes or >> not the check will always be true, so we can commit. > > I don't understand what change you're asking for, as things already work as > you've just described (the "variable" is the file, .git/COMMIT_EDITMSG).
So, i was right in my assumption about how it is implemented - good;)
Show 9 quoted lines
> >> If the implementation would be like this, then I would propose to >> clean up this variable after the prepopulated message is populated, so >> it won't use it blindly, but only after you're overwriting the message >> (even if the message is not changed). > > Here is where you've lost me. Not sure what you mean here, nor how you're > going to maintain the existing behavior for all of the people who have grown > used to it over a long, long period of time.
Let me explain it like this (sorry for syntax):
new commit:
COMMIT_EDITMSG = NULL; $ git commit
in background: $EDITOR .git/COMMIT_EDITMSG
If saved/written COMMIT_EDITMSG=message
if (COMMIT_EDITMSG != NULL && !COMMIT_EDITMSG.equalsIgnoreCase("") ) { commit(); } else abort();
==================== amend or rebase: COMMIT_EDITMSG = "message from commit or rebase sequence"; $ git commit --amend
in background: $EDITOR .git/COMMIT_EDITMSG
COMMIT_EDITMSG = NULL <======== this i think is missing. We have to clean it after it is populated in the editor.
If written back by save: COMMIT_EDITMSG="message from commit or rebase sequence" (it was not changed, but saved/written)
If not saved, the check below will abort the action
if (COMMIT_EDITMSG != NULL && !COMMIT_EDITMSG.equalsIgnoreCase("") ) { commit(); } else abort();
Is that a better explanation?
So, the only change from user perspective will be that you will have always save/write your changes/rebase sequences (even if you don't change the message) for the program to proceed with commit amend/rebase or whatever the same way as for the simple commit.
Thanks, Eugene