Skip to content

Commit 7c12178

Browse files
chriscoolgitster
authored andcommitted
t7063: add tests for core.untrackedCache
Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dae6c32 commit 7c12178

File tree

1 file changed

+81
-4
lines changed

1 file changed

+81
-4
lines changed

t/t7063-status-untracked-cache.sh

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if ! test_have_prereq UNTRACKED_CACHE; then
1818
test_done
1919
fi
2020

21+
test_expect_success 'core.untrackedCache is unset' '
22+
test_must_fail git config --get core.untrackedCache
23+
'
24+
2125
test_expect_success 'setup' '
2226
git init worktree &&
2327
cd worktree &&
@@ -30,13 +34,13 @@ test_expect_success 'setup' '
3034

3135
test_expect_success 'untracked cache is empty' '
3236
test-dump-untracked-cache >../actual &&
33-
cat >../expect <<EOF &&
37+
cat >../expect-empty <<EOF &&
3438
info/exclude 0000000000000000000000000000000000000000
3539
core.excludesfile 0000000000000000000000000000000000000000
3640
exclude_per_dir .gitignore
3741
flags 00000006
3842
EOF
39-
test_cmp ../expect ../actual
43+
test_cmp ../expect-empty ../actual
4044
'
4145

4246
cat >../status.expect <<EOF &&
@@ -506,7 +510,7 @@ EOF
506510

507511
test_expect_success 'verify untracked cache dump (sparse/subdirs)' '
508512
test-dump-untracked-cache >../actual &&
509-
cat >../expect <<EOF &&
513+
cat >../expect-from-test-dump <<EOF &&
510514
info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
511515
core.excludesfile 0000000000000000000000000000000000000000
512516
exclude_per_dir .gitignore
@@ -525,7 +529,7 @@ file
525529
/dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
526530
two
527531
EOF
528-
test_cmp ../expect ../actual
532+
test_cmp ../expect-from-test-dump ../actual
529533
'
530534

531535
test_expect_success 'test sparse status again with untracked cache and subdir' '
@@ -569,4 +573,77 @@ EOF
569573
test_cmp ../status.expect ../status.actual
570574
'
571575

576+
test_expect_success '--no-untracked-cache removes the cache' '
577+
git update-index --no-untracked-cache &&
578+
test-dump-untracked-cache >../actual &&
579+
echo "no untracked cache" >../expect-no-uc &&
580+
test_cmp ../expect-no-uc ../actual
581+
'
582+
583+
test_expect_success 'git status does not change anything' '
584+
git status &&
585+
test-dump-untracked-cache >../actual &&
586+
test_cmp ../expect-no-uc ../actual
587+
'
588+
589+
test_expect_success 'setting core.untrackedCache to true and using git status creates the cache' '
590+
git config core.untrackedCache true &&
591+
test-dump-untracked-cache >../actual &&
592+
test_cmp ../expect-no-uc ../actual &&
593+
git status &&
594+
test-dump-untracked-cache >../actual &&
595+
test_cmp ../expect-from-test-dump ../actual
596+
'
597+
598+
test_expect_success 'using --no-untracked-cache does not fail when core.untrackedCache is true' '
599+
git update-index --no-untracked-cache &&
600+
test-dump-untracked-cache >../actual &&
601+
test_cmp ../expect-no-uc ../actual &&
602+
git update-index --untracked-cache &&
603+
test-dump-untracked-cache >../actual &&
604+
test_cmp ../expect-empty ../actual
605+
'
606+
607+
test_expect_success 'setting core.untrackedCache to false and using git status removes the cache' '
608+
git config core.untrackedCache false &&
609+
test-dump-untracked-cache >../actual &&
610+
test_cmp ../expect-empty ../actual &&
611+
git status &&
612+
test-dump-untracked-cache >../actual &&
613+
test_cmp ../expect-no-uc ../actual
614+
'
615+
616+
test_expect_success 'using --untracked-cache does not fail when core.untrackedCache is false' '
617+
git update-index --untracked-cache &&
618+
test-dump-untracked-cache >../actual &&
619+
test_cmp ../expect-empty ../actual
620+
'
621+
622+
test_expect_success 'setting core.untrackedCache to keep' '
623+
git config core.untrackedCache keep &&
624+
git update-index --untracked-cache &&
625+
test-dump-untracked-cache >../actual &&
626+
test_cmp ../expect-empty ../actual &&
627+
git status &&
628+
test-dump-untracked-cache >../actual &&
629+
test_cmp ../expect-from-test-dump ../actual &&
630+
git update-index --no-untracked-cache &&
631+
test-dump-untracked-cache >../actual &&
632+
test_cmp ../expect-no-uc ../actual &&
633+
git update-index --force-untracked-cache &&
634+
test-dump-untracked-cache >../actual &&
635+
test_cmp ../expect-empty ../actual &&
636+
git status &&
637+
test-dump-untracked-cache >../actual &&
638+
test_cmp ../expect-from-test-dump ../actual
639+
'
640+
641+
test_expect_success 'test ident field is working' '
642+
mkdir ../other_worktree &&
643+
cp -R done dthree dtwo four three ../other_worktree &&
644+
GIT_WORK_TREE=../other_worktree git status 2>../err &&
645+
echo "warning: Untracked cache is disabled on this system or location." >../expect &&
646+
test_cmp ../expect ../err
647+
'
648+
572649
test_done

0 commit comments

Comments
 (0)