test-reach: test reduce_heads
Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jul 20, 2018 at 16:33 UTC
0c89f715d06082216cc312dcd39e09cb80f7aad7
2 files changed
+26
t/helper/test-reach.c
+4
@@ -102,6 +102,10 @@ int cmd__reach(int ac, const char **av)
102
struct commit_list *list = get_merge_bases_many(A, X_nr, X_array);
103
printf("%s(A,X):\n", av[1]);
104
print_sorted_commit_ids(list);
105
+ } else if (!strcmp(av[1], "reduce_heads")) {
106
+ struct commit_list *list = reduce_heads(X);
107
+ printf("%s(X):\n", av[1]);
108
+ print_sorted_commit_ids(list);
109
}
110
111
exit(0);
t/t6600-test-reach.sh
+22
@@ -138,4 +138,26 @@ test_expect_success 'get_merge_bases_many' '
138
test_three_modes get_merge_bases_many
139
'
140
141
+test_expect_success 'reduce_heads' '
142
+ cat >input <<-\EOF &&
143
+ X:commit-1-10
144
+ X:commit-2-8
145
+ X:commit-3-6
146
+ X:commit-4-4
147
+ X:commit-1-7
148
+ X:commit-2-5
149
+ X:commit-3-3
150
+ X:commit-5-1
151
+ EOF
152
+ {
153
+ echo "reduce_heads(X):" &&
154
+ git rev-parse commit-5-1 \
155
+ commit-4-4 \
156
+ commit-3-6 \
157
+ commit-2-8 \
158
+ commit-1-10 | sort
159
+ } >expect &&
160
+ test_three_modes reduce_heads
161
+'
162
+
163
test_done