git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: why does "git revert" commit even if i try to bail with ":q!"?

From
Robert P. J. Day <rpjday@crashcourse.ca>
Date
Mar 12, 2019, 18:14 UTC
Message-ID
<alpine.LFD.2.21.1903121411500.17683@localhost.localdomain>
In-Reply-To
<CAGyf7-F2wCB7D_JGzd7USaTV0YfmOuFG2Z6GkWVM-JqWKaagQA@mail.gmail.com>
On Tue, 12 Mar 2019, Bryan Turner wrote:
Show 23 quoted lines
> On Tue, Mar 12, 2019 at 10:23 AM Robert P. J. Day <rpjday@crashcourse.ca> 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>
> >
> >   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?
... snip ...
> When you use git revert, though, it writes a valid, usable message
> to the file ("Revert <subject>\n\nThis reverts commit <sha>"). When
> you :q!, that's still in the file. Since the file isn't empty, the
> commit moves ahead.
  again, this is also not true. as i think i mentioned in my earlier
note, if you get dropped into the revert edit session, even if you
delete all the usable commit message lines, if you type ":q!", the
revert commit still succeeds and, in fact, with all of the
revert-supplied usable lines that you just finished removing.
rday
-- 
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
Previous: Robert P. J. DayNext: SZEDER Gábor
Message 6 of 11 in “why does "git revert" commit even if i try to bail with ":q!"?”
  1. Robert P. J. DayMar 12, 2019
  2. Bryan TurnerMar 12, 2019
  3. Robert P. J. DayMar 12, 2019
  4. Bryan TurnerMar 12, 2019
  5. Robert P. J. DayMar 12, 2019
  6. Robert P. J. DayMar 12, 2019
  7. SZEDER GáborMar 12, 2019
  8. Bryan TurnerMar 12, 2019
  9. Kevin DaudtMar 12, 2019
  10. Robert P. J. DayMar 12, 2019
  11. Elijah NewrenMar 12, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.