test-reach: test in_merge_bases
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
5cd52de3264a0a93fad8a0a770445657438bf660
2 files changed
+24
t/helper/test-reach.c
+6
@@ -9,6 +9,7 @@
9
int cmd__reach(int ac, const char **av)
10
{
11
struct object_id oid_A, oid_B;
12
+ struct commit *A, *B;
13
struct strbuf buf = STRBUF_INIT;
14
struct repository *r = the_repository;
15
@@ -17,6 +18,7 @@ int cmd__reach(int ac, const char **av)
18
if (ac < 2)
19
exit(1);
20
21
+ A = B = NULL;
22
23
while (strbuf_getline(&buf, stdin) != EOF) {
24
struct object_id oid;
@@ -44,10 +46,12 @@ int cmd__reach(int ac, const char **av)
46
switch (buf.buf[0]) {
47
case 'A':
48
oidcpy(&oid_A, &oid);
49
+ A = c;
50
break;
51
52
case 'B':
53
oidcpy(&oid_B, &oid);
54
+ B = c;
55
break;
56
57
default:
@@ -58,6 +62,8 @@ int cmd__reach(int ac, const char **av)
62
63
if (!strcmp(av[1], "ref_newer"))
64
printf("%s(A,B):%d\n", av[1], ref_newer(&oid_A, &oid_B));
65
+ else if (!strcmp(av[1], "in_merge_bases"))
66
+ printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B));
67
68
exit(0);
69
}
t/t6600-test-reach.sh
+18
@@ -83,4 +83,22 @@ test_expect_success 'ref_newer:hit' '
83
test_three_modes ref_newer
84
'
85
86
+test_expect_success 'in_merge_bases:hit' '
87
+ cat >input <<-\EOF &&
88
+ A:commit-5-7
89
+ B:commit-8-8
90
+ EOF
91
+ echo "in_merge_bases(A,B):1" >expect &&
92
+ test_three_modes in_merge_bases
93
+'
94
+
95
+test_expect_success 'in_merge_bases:miss' '
96
+ cat >input <<-\EOF &&
97
+ A:commit-6-8
98
+ B:commit-5-9
99
+ EOF
100
+ echo "in_merge_bases(A,B):0" >expect &&
101
+ test_three_modes in_merge_bases
102
+'
103
+
104
test_done