commit-reach(repo_get_merge_bases_many_dirty): pass on errors

(Actually, this commit is only about passing on "missing commits" errors, but adding that to the commit's title would have made it too long.) The `merge_bases_many()` function was just taught to indicate parsing errors, and now the `repo_get_merge_bases_many_dirty()` function is aware of that, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Feb 28, 2024 at 09:44 UTC caaf1a2942c25c1f1a15818b718c9f641e52beef
3 files changed +16 -16
builtin/merge-base.c
+6 -3
@@ -10,10 +10,13 @@
10
11 static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
12 {
13 - struct commit_list *result, *r;
13 + struct commit_list *result = NULL, *r;
14
15 - result = repo_get_merge_bases_many_dirty(the_repository, rev[0],
16 - rev_nr - 1, rev + 1);
15 + if (repo_get_merge_bases_many_dirty(the_repository, rev[0],
16 + rev_nr - 1, rev + 1, &result) < 0) {
17 + free_commit_list(result);
18 + return -1;
19 + }
20
21 if (!result)
22 return 1;
commit-reach.c
+6 -10
@@ -470,17 +470,13 @@ int repo_get_merge_bases_many(struct repository *r,
470 return get_merge_bases_many_0(r, one, n, twos, 1, result);
471 }
472
473 -struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
474 - struct commit *one,
475 - int n,
476 - struct commit **twos)
473 +int repo_get_merge_bases_many_dirty(struct repository *r,
474 + struct commit *one,
475 + int n,
476 + struct commit **twos,
477 + struct commit_list **result)
478 {
478 - struct commit_list *result = NULL;
479 - if (get_merge_bases_many_0(r, one, n, twos, 0, &result) < 0) {
480 - free_commit_list(result);
481 - return NULL;
482 - }
483 - return result;
479 + return get_merge_bases_many_0(r, one, n, twos, 0, result);
480 }
481
482 int repo_get_merge_bases(struct repository *r,
commit-reach.h
+4 -3
@@ -18,9 +18,10 @@ int repo_get_merge_bases_many(struct repository *r,
18 struct commit **twos,
19 struct commit_list **result);
20 /* To be used only when object flags after this call no longer matter */
21 -struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
22 - struct commit *one, int n,
23 - struct commit **twos);
21 +int repo_get_merge_bases_many_dirty(struct repository *r,
22 + struct commit *one, int n,
23 + struct commit **twos,
24 + struct commit_list **result);
25
26 int get_octopus_merge_bases(struct commit_list *in, struct commit_list **result);
27