Skip to contentSkip to conversation

commit --amend neglecting return value

DISCUSSION maximilian attems 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

hello,

bug is easily reproducible by

Quoted 1 line

foo

git add foo
git commit --amend
:q!

 1 files changed, 1 insertions(+), 8 deletions(-)
 create mode 100644 test

git --version
git version 1.7.0.2

aboves is usage with vim as patch editor.
The expected behaviour would be to have not foo add to repo. afair this feature^Wbug exists since loooong.

thanks + kind regards

Signature · 1 line
maks
#1 lore raw
Quoted 7 lines · maximilian attems

bug is easily reproducible by

Quoted 1 line

foo

git add foo
git commit --amend
:q!

1 files changed, 1 insertions(+), 8 deletions(-)
Quoted 8 lines

create mode 100644 test

git --version
git version 1.7.0.2

aboves is usage with vim as patch editor.
The expected behaviour would be to have not foo add to repo. afair this feature^Wbug exists since loooong.

Vim returns 0 even if quit with :q!. Killing vim from another terminal causes this:

--- 8< ---
Vim: Caught deadly signal TERM

Vim: Finished.
error: /Users/brian/bin/vim died of signal 15
error: There was a problem with the editor '/Users/brian/bin/vim'. Please supply the message using either -m or -F option. --- 8< ---

If you want to abort committing while editing the message, delete the entire message (in Vim: "0dG:wq^M") and git will reply "Aborting commit due to empty commit message."

~~ Brian

#2 lore raw
Quoted 1 line · Brian Gernhardt

If you want to abort committing while editing the message, delete the entire message (in Vim: "0dG:wq^M") and git will reply "Aborting commit due to empty commit message."

Oops. Obviously I meant "ggdG:wq^M".

Also, a quick search of :help and testing reveals that ":cq" causes Vim to exit with non-zero status which will cause git to abort the commit.

~~ Brian

#3 lore raw
Quoted 8 lines · Brian Gernhardt
Quoted 1 line · Brian Gernhardt

If you want to abort committing while editing the message, delete the entire message (in Vim: "0dG:wq^M") and git will reply "Aborting commit due to empty commit message."

Oops. Obviously I meant "ggdG:wq^M".

Also, a quick search of :help and testing reveals that ":cq" causes Vim to exit with non-zero status which will cause git to abort the commit.

thanks for the pointer this is indeed very helpful. :)

kept hiting that bug in stressy situations, good to know a way out.