diff mbox series

[v3,15/26] stash: ensure full index

Message ID daa77e84e0e23ec675aef6805e7c2df7dedbb6bb.1618261698.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit a02912019a7a473b039d28713fb6419bf472386f
Headers show
Series Sparse Index: API protections | expand

Commit Message

Derrick Stolee April 12, 2021, 9:08 p.m. UTC
From: Derrick Stolee <dstolee@microsoft.com>

Before iterating over all cache entries, ensure that a sparse index is
expanded to a full index to avoid unexpected behavior.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 builtin/stash.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/builtin/stash.c b/builtin/stash.c
index ba774cce674f..6fb7178ef2fa 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1350,6 +1350,8 @@  static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
 		int i;
 		char *ps_matched = xcalloc(ps->nr, 1);
 
+		/* TODO: audit for interaction with sparse-index. */
+		ensure_full_index(&the_index);
 		for (i = 0; i < active_nr; i++)
 			ce_path_match(&the_index, active_cache[i], ps,
 				      ps_matched);