Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 8f29299

Browse files
committed
merge-base --octopus: reduce the result from get_octopus_merge_bases()
Scripts that use "merge-base --octopus" could do the reducing themselves, but most of them are expected to want to get the reduced results without having to do any work themselves. Tests are taken from a message by Василий Макаров <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> --- We might want to vet the existing callers of the underlying get_octopus_merge_bases() and find out if _all_ of them are doing anything extra (like deduping) because the machinery can return duplicate results. And if that is the case, then we may want to move the dedupling down the callchain instead of having it here.
1 parent e2f5df4 commit 8f29299

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

builtin/merge-base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static int handle_octopus(int count, const char **args, int show_all)
7373
for (i = count - 1; i >= 0; i--)
7474
commit_list_insert(get_commit_reference(args[i]), &revs);
7575

76-
result = get_octopus_merge_bases(revs);
76+
result = reduce_heads(get_octopus_merge_bases(revs));
7777

7878
if (!result)
7979
return 1;

t/t6010-merge-base.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,43 @@ test_expect_success 'criss-cross merge-base for octopus-step' '
230230
test_cmp expected.sorted actual.sorted
231231
'
232232

233+
test_expect_success 'merge-base --octopus --all for complex tree' '
234+
# Best common ancestor for JE, JAA and JDD is JC
235+
# JE
236+
# / |
237+
# / |
238+
# / |
239+
# JAA / |
240+
# |\ / |
241+
# | \ | JDD |
242+
# | \ |/ | |
243+
# | JC JD |
244+
# | | /| |
245+
# | |/ | |
246+
# JA | | |
247+
# |\ /| | |
248+
# X JB | X X
249+
# \ \ | / /
250+
# \__\|/___/
251+
# J
252+
test_commit J &&
253+
test_commit JB &&
254+
git reset --hard J &&
255+
test_commit JC &&
256+
git reset --hard J &&
257+
test_commit JTEMP1 &&
258+
test_merge JA JB &&
259+
test_merge JAA JC &&
260+
git reset --hard J &&
261+
test_commit JTEMP2 &&
262+
test_merge JD JB &&
263+
test_merge JDD JC &&
264+
git reset --hard J &&
265+
test_commit JTEMP3 &&
266+
test_merge JE JC &&
267+
git rev-parse JC >expected &&
268+
git merge-base --all --octopus JAA JDD JE >actual &&
269+
test_cmp expected actual
270+
'
271+
233272
test_done

0 commit comments

Comments
 (0)