From a934bbeb9476919f2ea219069027d1b775e614e4 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 30 Sep 2024 13:20:41 -0400 Subject: [PATCH 1/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 8172a7308c98e3..e1a416e3df5833 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -401,7 +401,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); From 777ce4d2ce484aae1f2bd6a8b60dc783284261a2 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 27 Sep 2024 13:46:35 -0400 Subject: [PATCH 2/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 dc88a09bf05df2..e3a5ef150e1605 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -372,6 +372,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 @@ -430,9 +434,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;