Skip to content

Commit 3b0379c

Browse files
committed
test-reach: test reduce_heads
Signed-off-by: Derrick Stolee <[email protected]>
1 parent 7a3e381 commit 3b0379c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

t/helper/test-reach.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ int cmd__reach(int ac, const char **av)
8585
printf("%s\n", oid_to_hex(&list->item->object.oid));
8686
list = list->next;
8787
}
88+
} else if (!strcmp(av[1], "reduce_heads")) {
89+
struct commit_list *list = reduce_heads(X);
90+
printf("%s(X):\n", av[1]);
91+
while (list) {
92+
printf("%s\n", oid_to_hex(&list->item->object.oid));
93+
list = list->next;
94+
}
8895
}
8996

9097
exit(0);

t/t6600-test-reach.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,26 @@ test_expect_success 'get_merge_bases_many' '
138138
test_three_modes get_merge_bases_many
139139
'
140140

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+
printf "reduce_heads(X):\n" &&
154+
git rev-parse commit-5-1 &&
155+
git rev-parse commit-4-4 &&
156+
git rev-parse commit-3-6 &&
157+
git rev-parse commit-2-8 &&
158+
git rev-parse commit-1-10
159+
} >expect &&
160+
test_three_modes reduce_heads
161+
'
162+
141163
test_done

0 commit comments

Comments
 (0)