]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-reach(repo_get_merge_bases_many_dirty): pass on errors
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 28 Feb 2024 09:44:17 +0000 (09:44 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 29 Feb 2024 16:06:01 +0000 (08:06 -0800)
(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>
builtin/merge-base.c
commit-reach.c
commit-reach.h

index 4d1ff840bdbd846176e99186f1061b381b57f255..5a8e72950298c254d430664c6e931ca13c699590 100644 (file)
 
 static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
 {
-       struct commit_list *result, *r;
+       struct commit_list *result = NULL, *r;
 
-       result = repo_get_merge_bases_many_dirty(the_repository, rev[0],
-                                                rev_nr - 1, rev + 1);
+       if (repo_get_merge_bases_many_dirty(the_repository, rev[0],
+                                           rev_nr - 1, rev + 1, &result) < 0) {
+               free_commit_list(result);
+               return -1;
+       }
 
        if (!result)
                return 1;
index f19341da455472a9d7d704bfdd1b3d406e438916..8f9b008f876787abf12ca89af5541f0b3bdf6ba7 100644 (file)
@@ -470,17 +470,13 @@ int repo_get_merge_bases_many(struct repository *r,
        return get_merge_bases_many_0(r, one, n, twos, 1, result);
 }
 
-struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
-                                                   struct commit *one,
-                                                   int n,
-                                                   struct commit **twos)
+int repo_get_merge_bases_many_dirty(struct repository *r,
+                                   struct commit *one,
+                                   int n,
+                                   struct commit **twos,
+                                   struct commit_list **result)
 {
-       struct commit_list *result = NULL;
-       if (get_merge_bases_many_0(r, one, n, twos, 0, &result) < 0) {
-               free_commit_list(result);
-               return NULL;
-       }
-       return result;
+       return get_merge_bases_many_0(r, one, n, twos, 0, result);
 }
 
 int repo_get_merge_bases(struct repository *r,
index 458043f4d58311af6aa5c5962aa8ef59617dd134..bf63cc468fd311a9ef658a23cec3db4fbbbac767 100644 (file)
@@ -18,9 +18,10 @@ int repo_get_merge_bases_many(struct repository *r,
                              struct commit **twos,
                              struct commit_list **result);
 /* To be used only when object flags after this call no longer matter */
-struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
-                                                   struct commit *one, int n,
-                                                   struct commit **twos);
+int repo_get_merge_bases_many_dirty(struct repository *r,
+                                   struct commit *one, int n,
+                                   struct commit **twos,
+                                   struct commit_list **result);
 
 int get_octopus_merge_bases(struct commit_list *in, struct commit_list **result);