On Tue, Mar 12, 2019 at 01:22:51PM -0400, Robert P. J. Day wrote: > > never noticed this before ... when i do a regular "git commit" and > enter my "vi" edit session and change my mind, i can bail with ":q!", > regardless of what i've set up as a commit message, and i'll see: > > Aborting commit due to empty commit message. > > however, i was just playing with "git revert" and, after i ran: > > $ git revert <commit SHA> > > i was dumped into another vi edit session: > > Revert "HTTP->HTTPS" > > This reverts commit 2965b41fd84a1a76f56984ecdf6c123d1992730f. > > # Please enter the commit message for your changes. Lines starting > # with '#' will be ignored, and an empty message aborts the commit. > # > # On branch master > # Your branch is up to date with 'rpjday/master'. > # > # Changes to be committed: > # modified: book/01-introduction/sections/installing.asc > # > > again, simulating that i changed my mind, i just typed ":q!", but > the revert went ahead, anyway. i tried again, this time completely > deleting all the lines from the commit msg (as the template > suggested), but the revert *still* completed after typing ":q!". > > it was only after deleting all the lines and using ":wq" that the > revert was cancelled: > > Aborting commit due to empty commit message. > > that seems ... inconsistent. am i misunderstanding something? > > rday The only reason why `:q!` works just for comitting is because there is no default message, so the final message ends up empty. When you do things like git revert or git ocmmit --amend, there is already a commit message, which you are then editing. When you quit without saving, the existing message remains and git uses that. vim has a command to let it exit with an error return code: `:cq`. This makes git something went wrong with editing the message, causing git to abort the commit.