Skip to content

Commit

Permalink
merge-ort/merge-recursive: do report errors in merge_submodule()
Browse files Browse the repository at this point in the history
In 24876eb (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 <[email protected]>
  • Loading branch information
dscho committed Mar 9, 2024
1 parent 533df4c commit 50fe1a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions merge-ort.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 50fe1a2

Please sign in to comment.