Re: [PATCH v4 6/7] stash create: remove unnecessary index load and refresh
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 6, 2026, 01:59 UTC
- Message-ID
- <xmqqse1eoh3k.fsf@gitster.g>
- In-Reply-To
- <8c54c118307cce6553929f5ff7242f85d0bbc733.1792767795.git.phillip.wood@dunelm.org.uk>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 22 quoted lines
> From: Phillip Wood <phillip.wood@dunelm.org.uk> > > create_index_from_tree() is called either directly or indirectly > from do_create_stash() after it has loaded and refreshed the index, > so we do not need to refresh it again here. This saves three lstat() > calls per changed path. > > Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> > --- > builtin/stash.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/builtin/stash.c b/builtin/stash.c > index e17f75641a4..f97cd4771a5 100644 > --- a/builtin/stash.c > +++ b/builtin/stash.c > @@ -384,9 +384,6 @@ static int create_index_from_tree(const struct object_id *tree_id, > 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); > - refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL, NULL);
Makes sense. As a file-scope static function, we do not have to worry about calling context to change without we noticing as much as a public function. And I agree that with the current calling sequence, this refresh is not needed.