stash: ensure full index

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> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Apr 1, 2021 at 01:49 UTC a02912019a7a473b039d28713fb6419bf472386f
1 file changed +2
builtin/stash.c
+2
@@ -1350,6 +1350,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1350 int i;
1351 char *ps_matched = xcalloc(ps->nr, 1);
1352
1353 + /* TODO: audit for interaction with sparse-index. */
1354 + ensure_full_index(&the_index);
1355 for (i = 0; i < active_nr; i++)
1356 ce_path_match(&the_index, active_cache[i], ps,
1357 ps_matched);