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 Василий Макаров <einmalfel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- 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.
Junio C Hamano committed
Dec 30, 2013 at 11:58 UTC
8f29299136c2f11730d876cd62637a9e37d4c388
2 files changed
+40
-1
builtin/merge-base.c
+1
-1
@@ -73,7 +73,7 @@ static int handle_octopus(int count, const char **args, int show_all)
73
for (i = count - 1; i >= 0; i--)
74
commit_list_insert(get_commit_reference(args[i]), &revs);
75
76
- result = get_octopus_merge_bases(revs);
76
+ result = reduce_heads(get_octopus_merge_bases(revs));
77
78
if (!result)
79
return 1;
t/t6010-merge-base.sh
+39
@@ -230,4 +230,43 @@ test_expect_success 'criss-cross merge-base for octopus-step' '
230
test_cmp expected.sorted actual.sorted
231
'
232
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
+
272
test_done