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

Re: Bug: 'git am --abort' can silently reset the wrong branch

From
Jeff King <peff@peff.net>
Date
May 8, 2009, 09:12 UTC
Message-ID
<20090508091218.GC29737@coredump.intra.peff.net>
In-Reply-To
<7v7i0s0y03.fsf@alter.siamese.dyndns.org>
On Fri, May 08, 2009 at 02:01:16AM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> > Switching branches and clobbering some other branch
> > with --abort is just _one_ thing you can do to screw yourself. You could
> > also have been doing useful work on the _same_ branch, and that would
> > get clobbered by --abort.  However, I'm not sure if we have a good way
> > of telling the difference between "work which I did to try to get these
> > patches to apply, but which should be thrown away when I abort" and
> > "work which I did because I forgot I had an active git-am".
> 
> I think I've said this already, but honestly speaking, I think --abort
> should not do --reset at all, but just remove the $dotest directory.  Or
> perhaps introduce a --clear option to do so.

I assumed that people actually liked the current "reset" behavior, so I didn't want to propose getting rid of it. Personally, I hate it. So I would be very happy to see it ripped out entirely, and then that neatly solves the problem (i.e., it now errs on the side of not throwing away work).

Show 9 quoted lines
> What I sometimes see to my users happen is to try applying to the oldest
> integration branch the patch (the users think) ought to apply, see it fail
> to apply, switch to a bit newer branch and run "am" again (trusting that
> it will pick up the material from $dotest), repeat the above and then give
> up with "git am --abort".  I do not think anybody can offhand explain to
> which branch and to what state the command takes the user back to in such
> a situation without looking at what the code actually does X-<; even
> though I think it should take the user back to the original branch, I do
> not think that is what the code does.

No, the current code clobbers whatever is in the current HEAD with ORIG_HEAD. So not only might you set another random branch back to the originally am'd branch, but if you did a pull in between you can pick up some random commit.

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 5 of 14 in “Bug: 'git am --abort' can silently reset the wrong branch”
  1. Eduardo HabkostMay 6, 2009
  2. Jeff KingMay 8, 2009
  3. Sverre RabbelierMay 8, 2009
  4. Junio C HamanoMay 8, 2009
  5. Jeff KingMay 8, 2009
  6. am: do not do any reset on --abortJeff King, May 25, 2009
  7. Johannes SchindelinMay 25, 2009
  8. Jeff KingMay 25, 2009
  9. Johannes SixtMay 25, 2009
  10. Avery PennarunMay 25, 2009
  11. Jeff KingMay 25, 2009
  12. Jeff KingMay 25, 2009
  13. Avery PennarunMay 25, 2009
  14. Junio C HamanoMay 25, 2009

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.