diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2021-04-01 01:49:58 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-04-14 13:47:42 -0700 |
commit | 0c18c059a152058e30e23c4edcd24b3992599503 (patch) | |
tree | cc65da889deb7845dd356340627ac670916640b8 | |
parent | pathspec: ensure full index (diff) | |
download | tgif-0c18c059a152058e30e23c4edcd24b3992599503.tar.xz |
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 <dstolee@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | read-cache.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c index 3698bc7bf7..a9dcf0ab4f 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1577,6 +1577,8 @@ int refresh_index(struct index_state *istate, unsigned int flags, */ preload_index(istate, pathspec, 0); trace2_region_enter("index", "refresh", NULL); + /* TODO: audit for interaction with sparse-index. */ + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *ce, *new_entry; int cache_errno = 0; @@ -2498,6 +2500,8 @@ int repo_index_has_changes(struct repository *repo, diff_flush(&opt); return opt.flags.has_changes != 0; } else { + /* TODO: audit for interaction with sparse-index. */ + ensure_full_index(istate); for (i = 0; sb && i < istate->cache_nr; i++) { if (i) strbuf_addch(sb, ' '); |