3 test_description
="Test whether cache-tree is properly updated
5 Tests whether various commands properly update and/or rewrite the
11 test-dump-cache-tree
>actual
&&
12 sed "s/$_x40/SHA/" <actual
>filtered
&&
13 test_cmp
"$1" filtered
16 # We don't bother with actually checking the SHA1:
17 # test-dump-cache-tree already verifies that all existing data is
19 test_shallow_cache_tree
() {
20 printf "SHA (%d entries, 0 subtrees)\n" $
(git ls-files|
wc -l) >expect
&&
24 test_invalid_cache_tree
() {
25 printf "invalid %s ()\n" "" "$@" >expect
&&
26 test-dump-cache-tree | \
27 sed -n -e "s/[0-9]* subtrees//" -e '/#(ref)/d' -e '/^invalid /p' >actual
&&
28 test_cmp expect actual
31 test_no_cache_tree
() {
36 test_expect_failure
'initial commit has cache-tree' '
38 test_shallow_cache_tree
41 test_expect_success
'read-tree HEAD establishes cache-tree' '
43 test_shallow_cache_tree
46 test_expect_success
'git-add invalidates cache-tree' '
47 test_when_finished "git reset --hard; git read-tree HEAD" &&
48 echo "I changed this file" >foo &&
50 test_invalid_cache_tree
53 test_expect_success
'git-add in subdir invalidates cache-tree' '
54 test_when_finished "git reset --hard; git read-tree HEAD" &&
56 echo "I changed this file" >dirx/foo &&
58 test_invalid_cache_tree
61 test_expect_success
'git-add in subdir does not invalidate sibling cache-tree' '
62 git tag no-children &&
63 test_when_finished "git reset --hard no-children; git read-tree HEAD" &&
67 echo "I changed this file" >dir1/a &&
69 test_invalid_cache_tree dir1/
72 test_expect_success
'update-index invalidates cache-tree' '
73 test_when_finished "git reset --hard; git read-tree HEAD" &&
74 echo "I changed this file" >foo &&
75 git update-index --add foo &&
76 test_invalid_cache_tree
79 test_expect_success
'write-tree establishes cache-tree' '
80 test-scrap-cache-tree &&
82 test_shallow_cache_tree
85 test_expect_success
'test-scrap-cache-tree works' '
87 test-scrap-cache-tree &&
91 test_expect_success
'second commit has cache-tree' '
93 test_shallow_cache_tree
96 test_expect_success
'reset --hard gives cache-tree' '
97 test-scrap-cache-tree &&
99 test_shallow_cache_tree
102 test_expect_success
'reset --hard without index gives cache-tree' '
105 test_shallow_cache_tree
108 test_expect_success
'checkout gives cache-tree' '
110 git checkout HEAD^ &&
111 test_shallow_cache_tree
114 test_expect_success
'checkout -b gives cache-tree' '
115 git checkout current &&
116 git checkout -b prev HEAD^ &&
117 test_shallow_cache_tree
120 test_expect_success
'checkout -B gives cache-tree' '
121 git checkout current &&
122 git checkout -B prev HEAD^ &&
123 test_shallow_cache_tree