t7063: add tests for core.untrackedCache

Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Jan 27, 2016 at 07:58 UTC 7c121788f4c93a29dbec0d61b3cd986a757a5077
1 file changed +81 -4
t/t7063-status-untracked-cache.sh
+81 -4
@@ -18,6 +18,10 @@ if ! test_have_prereq UNTRACKED_CACHE; then
18 test_done
19 fi
20
21 +test_expect_success 'core.untrackedCache is unset' '
22 + test_must_fail git config --get core.untrackedCache
23 +'
24 +
25 test_expect_success 'setup' '
26 git init worktree &&
27 cd worktree &&
@@ -30,13 +34,13 @@ test_expect_success 'setup' '
34
35 test_expect_success 'untracked cache is empty' '
36 test-dump-untracked-cache >../actual &&
33 - cat >../expect <<EOF &&
37 + cat >../expect-empty <<EOF &&
38 info/exclude 0000000000000000000000000000000000000000
39 core.excludesfile 0000000000000000000000000000000000000000
40 exclude_per_dir .gitignore
41 flags 00000006
42 EOF
39 - test_cmp ../expect ../actual
43 + test_cmp ../expect-empty ../actual
44 '
45
46 cat >../status.expect <<EOF &&
@@ -506,7 +510,7 @@ EOF
510
511 test_expect_success 'verify untracked cache dump (sparse/subdirs)' '
512 test-dump-untracked-cache >../actual &&
509 - cat >../expect <<EOF &&
513 + cat >../expect-from-test-dump <<EOF &&
514 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
515 core.excludesfile 0000000000000000000000000000000000000000
516 exclude_per_dir .gitignore
@@ -525,7 +529,7 @@ file
529 /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
530 two
531 EOF
528 - test_cmp ../expect ../actual
532 + test_cmp ../expect-from-test-dump ../actual
533 '
534
535 test_expect_success 'test sparse status again with untracked cache and subdir' '
@@ -569,4 +573,77 @@ EOF
573 test_cmp ../status.expect ../status.actual
574 '
575
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 +
649 test_done