From b6902f18e553e7f0a46264cc566f403b595b8e84 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 27 Sep 2024 13:46:35 -0400 Subject: [PATCH 1/2] sparse-index: do not copy hashtables during expansion Signed-off-by: Derrick Stolee --- sparse-index.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sparse-index.c b/sparse-index.c index fe369df3e53f76..a4562442f3cf7e 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -369,6 +369,10 @@ void expand_index(struct index_state *istate, struct pattern_list *pl) full = xcalloc(1, sizeof(struct index_state)); memcpy(full, istate, sizeof(struct index_state)); + full->name_hash_initialized = 0; + memset(&full->name_hash, 0, sizeof(full->name_hash)); + memset(&full->dir_hash, 0, sizeof(full->dir_hash)); + /* * This slightly-misnamed 'full' index might still be sparse if we * are only modifying the list of sparse directories. This hinges @@ -427,9 +431,15 @@ void expand_index(struct index_state *istate, struct pattern_list *pl) } /* Copy back into original index. */ + if (istate->name_hash_initialized) { + hashmap_clear(&istate->name_hash); + hashmap_clear(&istate->dir_hash); + } + istate->name_hash_initialized = full->name_hash_initialized; memcpy(&istate->name_hash, &full->name_hash, sizeof(full->name_hash)); memcpy(&istate->dir_hash, &full->dir_hash, sizeof(full->dir_hash)); + istate->sparse_index = pl ? INDEX_PARTIALLY_SPARSE : INDEX_EXPANDED; free(istate->cache); istate->cache = full->cache; From fbd3e0b679f5d3e562c96d930293105e2ac7cc21 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 30 Sep 2024 13:20:41 -0400 Subject: [PATCH 2/2] stash: use -f in checkout-index child process Signed-off-by: Derrick Stolee --- builtin/stash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/stash.c b/builtin/stash.c index 80ccfc7a085d1a..1b03edeba2d2a4 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -399,7 +399,7 @@ static int restore_untracked(struct object_id *u_tree) child_process_init(&cp); cp.git_cmd = 1; - strvec_pushl(&cp.args, "checkout-index", "--all", NULL); + strvec_pushl(&cp.args, "checkout-index", "--all", "-f", NULL); strvec_pushf(&cp.env, "GIT_INDEX_FILE=%s", stash_index_path.buf);