cache-tree: subdirectory tests
Add tests to confirm that invalidation of subdirectories neither over- nor under-invalidates. Signed-off-by: David Turner <dturner@twitter.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Turner committed
Jul 10, 2014 at 17:31 UTC
59a8adb6fb4ed27868e7144f4531b1bfd065a9c6
1 file changed
+23
-3
t/t0090-cache-tree.sh
+23
-3
@@ -22,9 +22,10 @@ test_shallow_cache_tree () {
22
}
23
24
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
29
}
30
31
test_no_cache_tree () {
@@ -49,6 +50,25 @@ test_expect_success 'git-add invalidates cache-tree' '
50
test_invalid_cache_tree
51
'
52
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
+
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 &&