3 test_description='basic commit reachability tests'
7 # Construct a grid-like commit graph with points (x,y)
8 # with 1 <= x <= 10, 1 <= y <= 10, where (x,y) has
9 # parents (x-1, y) and (x, y-1), keeping in mind that
10 # we drop a parent if a coordinate is nonpositive.
26 # We use branch 'commit-x-y' to refer to (x,y).
27 # This grid allows interesting reachability and
28 # non-reachability queries: (x,y) can reach (x',y')
29 # if and only if x' <= x and y' <= y.
30 test_expect_success 'setup' '
31 for i in $(test_seq 1 10)
34 git branch -f commit-1-$i
36 for j in $(test_seq 1 9)
38 git reset --hard commit-$j-1 &&
41 git branch -f commit-$x-1 &&
43 for i in $(test_seq 2 10)
45 git merge commit-$j-$i -m "$x-$i" &&
46 git branch -f commit-$x-$i
49 git commit-graph write --reachable &&
50 mv .git/objects/info/commit-graph commit-graph-full &&
51 git show-ref -s commit-5-5 | git commit-graph write --stdin-commits &&
52 mv .git/objects/info/commit-graph commit-graph-half &&
53 git config core.commitGraph true
57 test_when_finished rm -rf .git/objects/info/commit-graph &&
58 test-tool reach $1 <input >actual &&
59 test_cmp expect actual &&
60 cp commit-graph-full .git/objects/info/commit-graph &&
61 test-tool reach $1 <input >actual &&
62 test_cmp expect actual &&
63 cp commit-graph-half .git/objects/info/commit-graph &&
64 test-tool reach $1 <input >actual &&
65 test_cmp expect actual
68 test_expect_success 'ref_newer:miss' '
73 echo "ref_newer(A,B):0" >expect &&
74 test_three_modes ref_newer
77 test_expect_success 'ref_newer:hit' '
82 echo "ref_newer(A,B):1" >expect &&
83 test_three_modes ref_newer
86 test_expect_success 'in_merge_bases:hit' '
91 echo "in_merge_bases(A,B):1" >expect &&
92 test_three_modes in_merge_bases
95 test_expect_success 'in_merge_bases:miss' '
100 echo "in_merge_bases(A,B):0" >expect &&
101 test_three_modes in_merge_bases
104 test_expect_success 'is_descendant_of:hit' '
105 cat >input <<-\EOF &&
111 echo "is_descendant_of(A,X):1" >expect &&
112 test_three_modes is_descendant_of
115 test_expect_success 'is_descendant_of:miss' '
116 cat >input <<-\EOF &&
122 echo "is_descendant_of(A,X):0" >expect &&
123 test_three_modes is_descendant_of
126 test_expect_success 'get_merge_bases_many' '
127 cat >input <<-\EOF &&
134 echo "get_merge_bases_many(A,X):" &&
135 git rev-parse commit-5-6 \
138 test_three_modes get_merge_bases_many
141 test_expect_success 'reduce_heads' '
142 cat >input <<-\EOF &&
153 echo "reduce_heads(X):" &&
154 git rev-parse commit-5-1 \
160 test_three_modes reduce_heads
163 test_expect_success 'can_all_from_reach:hit' '
164 cat >input <<-\EOF &&
182 echo "can_all_from_reach(X,Y):1" >expect &&
183 test_three_modes can_all_from_reach
186 test_expect_success 'can_all_from_reach:miss' '
187 cat >input <<-\EOF &&
204 echo "can_all_from_reach(X,Y):0" >expect &&
205 test_three_modes can_all_from_reach
208 test_expect_success 'commit_contains:hit' '
209 cat >input <<-\EOF &&
220 echo "commit_contains(_,A,X,_):1" >expect &&
221 test_three_modes commit_contains &&
222 test_three_modes commit_contains --tag
225 test_expect_success 'commit_contains:miss' '
226 cat >input <<-\EOF &&
237 echo "commit_contains(_,A,X,_):0" >expect &&
238 test_three_modes commit_contains &&
239 test_three_modes commit_contains --tag