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

Re: [Bug] Stashing during merge loses MERGING state

From
Elijah Newren <newren@gmail.com>
Date
Mar 12, 2021, 07:17 UTC
Message-ID
<CABPp-BG=EupfdjZXs5JZu4RPUyv61Rkxf0MQpR2xpGoYk2w6jQ@mail.gmail.com>
In-Reply-To
<CAPx1GvfguSyXznaaeQYB8JY96vmZmzOJyTnXX1yP3omeXptqXw@mail.gmail.com>
On Thu, Mar 11, 2021 at 11:07 PM Chris Torek <chris.torek@gmail.com> wrote:
Show 30 quoted lines
>
> On Thu, Mar 11, 2021 at 9:19 PM Phil Hord <phil.hord@gmail.com> wrote:
> > I wonder if a fix could be as simple as recording the MERGE_HEAD as
> > the third parent commit of the stash ref.
>
> There is already a third parent, but only when using -u / -a: this
> third-parent commit holds the untracked files (which are then removed
> a la `git clean`).
>
> A better trick would, I think, be able to save a partial merge state
> in general, including the unmerged statuses of various files, the
> ongoing action (merge or one of the other things that use it), and
> so on, in a form that could be restored later.  A plain `git stash` in
> any partially-merged state should tell you: no, use the fancier
> merge-state-saver instead.
>
> > I think being able to stash during a merge conflict could be very
> > useful.  I do sometimes need to get back to a working state
> > momentarily and a merge conflict represents a long pole to doing so.
> > Similarly, it could be useful to stash a conflicted `git rebase` so I
> > could return to it later and pick up where I left off.  Now we really
> > would need to store some extra metadata, though, like the todo-list
> > and ORIG_HEAD.  And we would definitely need some extra command line
> > switch to tell stash (or rebase) that I want to include all the rebase
> > state and also "pause" the rebase by restoring to my starting point.
>
> This is the sort of thing I'm thinking of, for the "superstash" (terrible
> name for it). Note that whatever this becomes, it should be send-able
> (via push and/or email) so that you can have multiple people work
> on resolving a particularly hairy merge.

You can use git-imerge (https://github.com/mhagger/git-imerge) for that...just not once you've already started a merge (unless you're willing to undo and restart).

As per my other email, I'm pretty worried about attempting to stash a merge, given that stash allows its contents to be "reapplied" on top of a different commit. That works fine for single-parent commits, but merges have multiple parents and it'd be rather tricky to reapply such a stash on a different base without creating an evil merge. Perhaps if "superstash" forced you to only reapply on the same base then it'd be fine...but it's starting to no longer be a "stash" anymore but something else.

Previous: Chris TorekNext: Elijah Newren
Message 8 of 9 in “[Bug] Stashing during merge loses MERGING state”
  1. Tassilo HornMar 11, 2021
  2. Jeff KingMar 11, 2021
  3. Tassilo HornMar 11, 2021
  4. Phil HordMar 12, 2021
  5. Junio C HamanoMar 12, 2021
  6. Elijah NewrenMar 12, 2021
  7. Chris TorekMar 12, 2021
  8. Elijah NewrenMar 12, 2021
  9. Elijah NewrenMar 12, 2021

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.