Skip to content

Commit

Permalink
do_read_index(): always mark as initialized unless erroring out
Browse files Browse the repository at this point in the history
Even when `.git/index` did not exist (and that was indicated as being
okay), we need to mark the index as initialized when returning from
`do_read_index()` with success.

This will become relevant in the next commit, where an incorrect
condition trying to determine whether an in-memory index was initialized
(using `cache_nr == 0` as an indicator, which is wrong) will be replaced
with the correct condition (`initialized != 0`).

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Jun 28, 2023
1 parent a9e066f commit 042058e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
if (fd < 0) {
if (!must_exist && errno == ENOENT) {
set_new_index_sparsity(istate);
istate->initialized = 1;
return 0;
}
die_errno(_("%s: index file open failed"), path);
Expand Down

0 comments on commit 042058e

Please sign in to comment.