Skip to content

Commit 59a8adb

Browse files
dturner-twgitster
authored andcommitted
cache-tree: subdirectory tests
Add tests to confirm that invalidation of subdirectories neither over- nor under-invalidates. Signed-off-by: David Turner <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 969dd8c commit 59a8adb

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

t/t0090-cache-tree.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ test_shallow_cache_tree () {
2222
}
2323

2424
test_invalid_cache_tree () {
25-
echo "invalid (0 subtrees)" >expect &&
26-
printf "SHA #(ref) (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >>expect &&
27-
cmp_cache_tree expect
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
2829
}
2930

3031
test_no_cache_tree () {
@@ -49,6 +50,25 @@ test_expect_success 'git-add invalidates cache-tree' '
4950
test_invalid_cache_tree
5051
'
5152

53+
test_expect_success 'git-add in subdir invalidates cache-tree' '
54+
test_when_finished "git reset --hard; git read-tree HEAD" &&
55+
mkdir dirx &&
56+
echo "I changed this file" >dirx/foo &&
57+
git add dirx/foo &&
58+
test_invalid_cache_tree
59+
'
60+
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" &&
64+
mkdir dir1 dir2 &&
65+
test_commit dir1/a &&
66+
test_commit dir2/b &&
67+
echo "I changed this file" >dir1/a &&
68+
git add dir1/a &&
69+
test_invalid_cache_tree dir1/
70+
'
71+
5272
test_expect_success 'update-index invalidates cache-tree' '
5373
test_when_finished "git reset --hard; git read-tree HEAD" &&
5474
echo "I changed this file" >foo &&

0 commit comments

Comments
 (0)