]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-ort/merge-recursive: do report errors in `merge_submodule()`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 9 Mar 2024 14:09:57 +0000 (14:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 9 Mar 2024 17:57:16 +0000 (09:57 -0800)
In 24876ebf68b (commit-reach(repo_in_merge_bases_many): report missing
commits, 2024-02-28), I taught `merge_submodule()` to handle errors
reported by `repo_in_merge_bases_many()`.

However, those errors were not passed through to the callers. That was
unintentional, and this commit remedies that.

Note that `find_first_merges()` can now also return -1 (because it
passes through that return value from `repo_in_merge_bases()`), and this
commit also adds the forgotten handling for that scenario.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-ort.c
merge-recursive.c

index 033c4348e2d2b648d8338dd5a3914337014d71dd..5d36c04f50986584b4cde9b6df5e8223c873db78 100644 (file)
@@ -1819,6 +1819,7 @@ static int merge_submodule(struct merge_options *opt,
                         _("Failed to merge submodule %s "
                           "(repository corrupt)"),
                         path);
+               ret = -1;
                goto cleanup;
        }
        if (ret2 > 0)
@@ -1829,6 +1830,7 @@ static int merge_submodule(struct merge_options *opt,
                         _("Failed to merge submodule %s "
                           "(repository corrupt)"),
                         path);
+               ret = -1;
                goto cleanup;
        }
        if (!ret2) {
@@ -1848,6 +1850,7 @@ static int merge_submodule(struct merge_options *opt,
                         _("Failed to merge submodule %s "
                           "(repository corrupt)"),
                         path);
+               ret = -1;
                goto cleanup;
        }
        if (ret2 > 0) {
@@ -1866,6 +1869,7 @@ static int merge_submodule(struct merge_options *opt,
                         _("Failed to merge submodule %s "
                           "(repository corrupt)"),
                         path);
+               ret = -1;
                goto cleanup;
        }
        if (ret2 > 0) {
@@ -1899,6 +1903,7 @@ static int merge_submodule(struct merge_options *opt,
                         _("Failed to merge submodule %s "
                           "(repository corrupt)"),
                         path);
+               ret = -1;
                break;
        case 0:
                path_msg(opt, CONFLICT_SUBMODULE_FAILED_TO_MERGE, 0,
index f3132a9ecaeb3150a4eb41f3fb920d9a70c04a0f..fc772c2b113c94e3ebfa5e6bc2330f0452778ef8 100644 (file)
@@ -1246,12 +1246,14 @@ static int merge_submodule(struct merge_options *opt,
        ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_a);
        if (ret2 < 0) {
                output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+               ret = -1;
                goto cleanup;
        }
        if (ret2 > 0)
                ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_b);
        if (ret2 < 0) {
                output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+               ret = -1;
                goto cleanup;
        }
        if (!ret2) {
@@ -1263,6 +1265,7 @@ static int merge_submodule(struct merge_options *opt,
        ret2 = repo_in_merge_bases(&subrepo, commit_a, commit_b);
        if (ret2 < 0) {
                output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+               ret = -1;
                goto cleanup;
        }
        if (ret2) {
@@ -1281,6 +1284,7 @@ static int merge_submodule(struct merge_options *opt,
        ret2 = repo_in_merge_bases(&subrepo, commit_b, commit_a);
        if (ret2 < 0) {
                output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
+               ret = -1;
                goto cleanup;
        }
        if (ret2) {
@@ -1312,6 +1316,10 @@ static int merge_submodule(struct merge_options *opt,
        parent_count = find_first_merges(&subrepo, &merges, path,
                                         commit_a, commit_b);
        switch (parent_count) {
+       case -1:
+               output(opt, 1,_("Failed to merge submodule %s (repository corrupt)"), path);
+               ret = -1;
+               break;
        case 0:
                output(opt, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
                break;