summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorLibravatar Derrick Stolee <dstolee@microsoft.com>2018-07-20 16:33:18 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-07-20 15:38:55 -0700
commit6255232ec13b038a48326135f2e479797cd0d1f9 (patch)
tree4c0c45a54e5480b0d15aef52395d11ef91206e9e /t/helper
parenttest-reach: test in_merge_bases (diff)
downloadtgif-6255232ec13b038a48326135f2e479797cd0d1f9.tar.xz
test-reach: test is_descendant_of
The is_descendant_of method takes a single commit as its first parameter and a list of commits as its second parameter. Extend the input of the 'test-tool reach' command to take multiple lines of the form "X:<committish>" to construct a list of commits. Pass these to is_descendant_of and create tests that check each result. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-reach.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index f93ad5084d..dccbd48178 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -10,6 +10,7 @@ int cmd__reach(int ac, const char **av)
{
struct object_id oid_A, oid_B;
struct commit *A, *B;
+ struct commit_list *X;
struct strbuf buf = STRBUF_INIT;
struct repository *r = the_repository;
@@ -19,6 +20,7 @@ int cmd__reach(int ac, const char **av)
exit(1);
A = B = NULL;
+ X = NULL;
while (strbuf_getline(&buf, stdin) != EOF) {
struct object_id oid;
@@ -54,6 +56,10 @@ int cmd__reach(int ac, const char **av)
B = c;
break;
+ case 'X':
+ commit_list_insert(c, &X);
+ break;
+
default:
die("unexpected start of line: %c", buf.buf[0]);
}
@@ -64,6 +70,8 @@ int cmd__reach(int ac, const char **av)
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));
+ else if (!strcmp(av[1], "is_descendant_of"))
+ printf("%s(A,X):%d\n", av[1], is_descendant_of(A, X));
exit(0);
}