summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--read-cache.c2
-rwxr-xr-xt/t7063-status-untracked-cache.sh5
2 files changed, 7 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index 76f372f..4de2077 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -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;
}
diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh
index 9936cc3..c1f0d95 100755
--- a/t/t7063-status-untracked-cache.sh
+++ b/t/t7063-status-untracked-cache.sh
@@ -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