Skip to content

Commit 0c18c05

Browse files
derrickstoleegitster
authored andcommitted
read-cache: 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 <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 465a04a commit 0c18c05

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

read-cache.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
15771577
*/
15781578
preload_index(istate, pathspec, 0);
15791579
trace2_region_enter("index", "refresh", NULL);
1580+
/* TODO: audit for interaction with sparse-index. */
1581+
ensure_full_index(istate);
15801582
for (i = 0; i < istate->cache_nr; i++) {
15811583
struct cache_entry *ce, *new_entry;
15821584
int cache_errno = 0;
@@ -2498,6 +2500,8 @@ int repo_index_has_changes(struct repository *repo,
24982500
diff_flush(&opt);
24992501
return opt.flags.has_changes != 0;
25002502
} else {
2503+
/* TODO: audit for interaction with sparse-index. */
2504+
ensure_full_index(istate);
25012505
for (i = 0; sb && i < istate->cache_nr; i++) {
25022506
if (i)
25032507
strbuf_addch(sb, ' ');

0 commit comments

Comments
 (0)