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

Re: [PATCH] stash: reuse cached index entries in --patch temporary index

From
Adam Johnson <me@adamj.eu>
Date
May 22, 2026, 20:55 UTC
Message-ID
<e6e3ba3a-a08d-426b-b0ae-1f57554b2b1d@app.fastmail.com>
In-Reply-To
<xmqqldde6cl5.fsf@gitster.g>
> Is this "non-zero return from refresh_index() leads to a failure"
> intended?

Good catch, it’s not needed. Removing, we can make the call unconditional.

On Wed, 20 May 2026, at 03:26, Junio C Hamano wrote:
Show 38 quoted lines
> "Adam Johnson via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> >  2 files changed, 83 insertions(+), 6 deletions(-)
> >
> > diff --git a/builtin/stash.c b/builtin/stash.c
> > index 32dbc97b47..48189cb9f7 100644
> > --- a/builtin/stash.c
> > +++ b/builtin/stash.c
> > @@ -372,6 +372,57 @@ static int reset_tree(struct object_id *i_tree, int update, int reset)
> >  return 0;
> >  }
> >  
> > +static int create_index_from_tree(const struct object_id *tree_id,
> > +   const char *index_path)
> > +{
> > + int nr_trees = 1;
> > + int ret = 0;
> > + struct unpack_trees_options opts;
> > + struct tree_desc t[MAX_UNPACK_TREES];
> > + struct tree *tree;
> > + struct index_state dst_istate = INDEX_STATE_INIT(the_repository);
> > + struct lock_file lock_file = LOCK_INIT;
> > +
> > + repo_read_index_preload(the_repository, NULL, 0);
> > + if (refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL, NULL))
> > + return -1;
> 
> Is this "non-zero return from refresh_index() leads to a failure"
> intended?  The old "git read-tree HEAD" wouldn't have cared if the
> original index were unmerged, for example, but with this update, we
> will see an immediate failure.  There are other conditions that
> refresh_index() flips its local variable has_errors on, which leads
> to its non-zero return.
> 
> Since "git stash -p" is almost always invoked when the user has
> unstaged modifications, I am not sure allowing refresh_index() to
> notice and barf is what we want here.
> 
Previous: Junio C HamanoNext: Adam Johnson via GitGitGadget
Message 5 of 7 in “stash: reuse cached index entries in --patch temporary index”
  1. stash: reuse cached index entries in --patch temporary indexAdam Johnson via GitGitGadget, May 19, 2026
  2. Junio C HamanoMay 20, 2026
  3. Adam JohnsonMay 22, 2026
  4. Junio C HamanoMay 20, 2026
  5. Adam JohnsonMay 22, 2026
  6. stash: reuse cached index entries in --patch temporary indexAdam Johnson via GitGitGadget, May 22, 2026
  7. Junio C HamanoJun 1, 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.