Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test-reach: test in_merge_bases
Signed-off-by: Derrick Stolee <[email protected]>
  • Loading branch information
derrickstolee committed Jul 20, 2018
commit 10bda4970fc7c6f012061d8d2466266ab89866fe
6 changes: 6 additions & 0 deletions t/helper/test-reach.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
int cmd__reach(int ac, const char **av)
{
struct object_id oid_A, oid_B;
struct commit *A, *B;
struct strbuf buf = STRBUF_INIT;
struct repository *r = the_repository;

Expand All @@ -17,6 +18,7 @@ int cmd__reach(int ac, const char **av)
if (ac < 2)
exit(1);

A = B = NULL;

while (strbuf_getline(&buf, stdin) != EOF) {
struct object_id oid;
Expand Down Expand Up @@ -44,10 +46,12 @@ int cmd__reach(int ac, const char **av)
switch (buf.buf[0]) {
case 'A':
oidcpy(&oid_A, &oid);
A = c;
break;

case 'B':
oidcpy(&oid_B, &oid);
B = c;
break;

default:
Expand All @@ -58,6 +62,8 @@ int cmd__reach(int ac, const char **av)

if (!strcmp(av[1], "ref_newer"))
printf("%s(A,B):%d\n", av[1], ref_newer(&oid_A, &oid_B));
else if (!strcmp(av[1], "in_merge_bases"))
printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B));

exit(0);
}
18 changes: 18 additions & 0 deletions t/t6600-test-reach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,22 @@ test_expect_success 'ref_newer:hit' '
test_three_modes ref_newer
'

test_expect_success 'in_merge_bases:hit' '
cat >input <<-\EOF &&
A:commit-5-7
B:commit-8-8
EOF
echo "in_merge_bases(A,B):1" >expect &&
test_three_modes in_merge_bases
'

test_expect_success 'in_merge_bases:miss' '
cat >input <<-\EOF &&
A:commit-6-8
B:commit-5-9
EOF
echo "in_merge_bases(A,B):0" >expect &&
test_three_modes in_merge_bases
'

test_done