Browse Source

Merge branch 'tk/untracked-cache-with-uall' into maint

Fix for a bug that makes write-tree to fail to write out a
non-existent index as a tree, introduced in 2.37.
source: <20220722212232.833188-1-martin.agren@gmail.com>

* tk/untracked-cache-with-uall:
  read-cache: make `do_read_index()` always set up `istate->repo`
maint
Junio C Hamano 2 years ago
parent
commit
4f049a16bf
  1. 2
      read-cache.c
  2. 5
      t/t7063-status-untracked-cache.sh

2
read-cache.c

@ -2294,6 +2294,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) @@ -2294,6 +2294,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
fd = open(path, O_RDONLY);
if (fd < 0) {
if (!must_exist && errno == ENOENT) {
if (!istate->repo)
istate->repo = the_repository;
set_new_index_sparsity(istate);
return 0;
}

5
t/t7063-status-untracked-cache.sh

@ -985,4 +985,9 @@ test_expect_success '"status" after file replacement should be clean with UC=fal @@ -985,4 +985,9 @@ test_expect_success '"status" after file replacement should be clean with UC=fal
status_is_clean
'

test_expect_success 'empty repo (no index) and core.untrackedCache' '
git init emptyrepo &&
git -C emptyrepo -c core.untrackedCache=true write-tree
'

test_done

Loading…
Cancel
Save