Skip to content

Commit 25fd20e

Browse files
dschogitster
authored andcommitted
merge-ort/merge-recursive: do report errors in merge_submodule()
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]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 81a34cb commit 25fd20e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

merge-ort.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,7 @@ static int merge_submodule(struct merge_options *opt,
18191819
_("Failed to merge submodule %s "
18201820
"(repository corrupt)"),
18211821
path);
1822+
ret = -1;
18221823
goto cleanup;
18231824
}
18241825
if (ret2 > 0)
@@ -1829,6 +1830,7 @@ static int merge_submodule(struct merge_options *opt,
18291830
_("Failed to merge submodule %s "
18301831
"(repository corrupt)"),
18311832
path);
1833+
ret = -1;
18321834
goto cleanup;
18331835
}
18341836
if (!ret2) {
@@ -1848,6 +1850,7 @@ static int merge_submodule(struct merge_options *opt,
18481850
_("Failed to merge submodule %s "
18491851
"(repository corrupt)"),
18501852
path);
1853+
ret = -1;
18511854
goto cleanup;
18521855
}
18531856
if (ret2 > 0) {
@@ -1866,6 +1869,7 @@ static int merge_submodule(struct merge_options *opt,
18661869
_("Failed to merge submodule %s "
18671870
"(repository corrupt)"),
18681871
path);
1872+
ret = -1;
18691873
goto cleanup;
18701874
}
18711875
if (ret2 > 0) {
@@ -1899,6 +1903,7 @@ static int merge_submodule(struct merge_options *opt,
18991903
_("Failed to merge submodule %s "
19001904
"(repository corrupt)"),
19011905
path);
1906+
ret = -1;
19021907
break;
19031908
case 0:
19041909
path_msg(opt, CONFLICT_SUBMODULE_FAILED_TO_MERGE, 0,

merge-recursive.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,12 +1246,14 @@ static int merge_submodule(struct merge_options *opt,
12461246
ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_a);
12471247
if (ret2 < 0) {
12481248
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1249+
ret = -1;
12491250
goto cleanup;
12501251
}
12511252
if (ret2 > 0)
12521253
ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_b);
12531254
if (ret2 < 0) {
12541255
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1256+
ret = -1;
12551257
goto cleanup;
12561258
}
12571259
if (!ret2) {
@@ -1263,6 +1265,7 @@ static int merge_submodule(struct merge_options *opt,
12631265
ret2 = repo_in_merge_bases(&subrepo, commit_a, commit_b);
12641266
if (ret2 < 0) {
12651267
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1268+
ret = -1;
12661269
goto cleanup;
12671270
}
12681271
if (ret2) {
@@ -1281,6 +1284,7 @@ static int merge_submodule(struct merge_options *opt,
12811284
ret2 = repo_in_merge_bases(&subrepo, commit_b, commit_a);
12821285
if (ret2 < 0) {
12831286
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1287+
ret = -1;
12841288
goto cleanup;
12851289
}
12861290
if (ret2) {
@@ -1312,6 +1316,10 @@ static int merge_submodule(struct merge_options *opt,
13121316
parent_count = find_first_merges(&subrepo, &merges, path,
13131317
commit_a, commit_b);
13141318
switch (parent_count) {
1319+
case -1:
1320+
output(opt, 1,_("Failed to merge submodule %s (repository corrupt)"), path);
1321+
ret = -1;
1322+
break;
13151323
case 0:
13161324
output(opt, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
13171325
break;

0 commit comments

Comments
 (0)