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

Re: [BUG] stash.index=true leaves a redundant stash entry after an autostash fast-forward

From
Eli Barzilay <eli@barzilay.org>
Date
Sep 16, 2026, 19:57 UTC
Message-ID
<CALO-guua8fcRq5n_M8=r9GMZ-aW4LaddXxS9rz0YhpAQ9TL3mA@mail.gmail.com>
In-Reply-To
<0BCA251B-9536-46E3-A6C5-7F917366F92D@gmail.com>

[Note from the peanut gallery since I can't spend time diving into the code -- that's result of collecting dead autostashes is the only thorn in my joy of discovering `stash.index` + `rebase.autoStash`. So while I can't spend time in the code, I'll be happy to try patches or whatever if it helps...]

On Wed, Sep 16, 2026 at 10:30 AM Ben Knoble <ben.knoble@gmail.com> wrote:
Show 37 quoted lines
>
> Hi Phillip,
>
> > Le 16 sept. 2026 à 09:35, Phillip Wood <phillip.wood123@gmail.com> a écrit :
> >
> > Hi Ben
> >
> >> On 15/09/2026 22:16, D. Ben Knoble wrote:
> >> I'm experimenting with something that swaps that out for a call to
> >> reset_working_tree(), but I don't think I've gotten it quite right for
> >> this bug yet (let alone run other test cases that might be affected by
> >> this change).
> >
> > It looks like stash has its own unpack_trees() wrapper, so I think the simplest fix is to replace reset_head() with
> >
> >    reset_tree(&c_tree, 0, 1);
> >
> > Taking a step back, this code applies the stashed index changes into the current index, writes the result to a tree and then resets the index to HEAD. We could avoid touching the index at all if we used merge_incore_nonrecursive() to cherry pick the index changes instead. That way we'd get a proper three-way merge and avoid spawning subprocesses for "git diff-tree", "git apply --cached", and "git reset". We're already using merge_ort_nonrecursive() to merge the working tree changes in that function so we have nearly everything we need already set up to merge the index changes as well. Essentially, when merging the index, we just need to call merge_incore_nonrecursive() instead of merge_ort_nonrecursive() and use info->i_tree instead of info->w_tree.
>
> Wow, I wish I’d had this info this morning! I spent a couple hours trying to understand this flow and still don’t have it in my head :) Thanks for the pointers.
>
> With the way I batch my side project time, it’ll be tomorrow before I get to trying to make and test patches for this, but I’ excited now.
>
> I may try to summarize my own notes (= questions about the existing code) and send those out later today, though, since I’d love to make my understanding line up with yours!
>
> >> BTW, it's really weird to me that the reset manual doesn't mention all
> >> these "extra" cleanups reset does via remove_merge_branch_state()!
> >
> > Agreed, I think it comes from "git foo --abort" calling "git reset (--merge|--hard)" though that doesn't really explain why a mixed reset also removes the branch state.
>
> Yeah, that abort bit makes sense. I wonder if we should have had a better side-channel for communicating that, but I’m a bit too afraid to touch that for now ;)
>
> > Thanks
> >
> > Phillip
>
> Thank *you*!
-- 
                 ((x=>x(x))(x=>x(x)))                  Eli Barzilay:
                 http://barzilay.org/                  Maze is Life!
Previous: Ben KnobleNext: D. Ben Knoble
Message 5 of 12 in “[BUG] stash.index=true leaves a redundant stash entry after an autostash fast-forward”
  1. Eli BarzilaySep 7, 2026
  2. D. Ben KnobleSep 15, 2026
  3. Phillip WoodSep 16, 2026
  4. Ben KnobleSep 16, 2026
  5. Eli BarzilaySep 16, 2026
  6. D. Ben KnobleSep 17, 2026
  7. Phillip WoodSep 17, 2026
  8. D. Ben KnobleSep 17, 2026
  9. Phillip WoodSep 17, 2026
  10. Phillip WoodSep 19, 2026
  11. D. Ben KnobleSep 19, 2026
  12. D. Ben KnobleSep 19, 2026

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.