merge-ort/merge-recursive: do report errors in `merge_submodule()`
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>
Johannes Schindelin committed
Mar 9, 2024 at 14:09 UTC
25fd20eb44cfcbb0652595de2144f0e077a957ec
2 files changed
+13
merge-ort.c
+5
@@ -1819,6 +1819,7 @@ static int merge_submodule(struct merge_options *opt,
1819
_("Failed to merge submodule %s "
1820
"(repository corrupt)"),
1821
path);
1822
+ ret = -1;
1823
goto cleanup;
1824
}
1825
if (ret2 > 0)
@@ -1829,6 +1830,7 @@ static int merge_submodule(struct merge_options *opt,
1830
_("Failed to merge submodule %s "
1831
"(repository corrupt)"),
1832
path);
1833
+ ret = -1;
1834
goto cleanup;
1835
}
1836
if (!ret2) {
@@ -1848,6 +1850,7 @@ static int merge_submodule(struct merge_options *opt,
1850
_("Failed to merge submodule %s "
1851
"(repository corrupt)"),
1852
path);
1853
+ ret = -1;
1854
goto cleanup;
1855
}
1856
if (ret2 > 0) {
@@ -1866,6 +1869,7 @@ static int merge_submodule(struct merge_options *opt,
1869
_("Failed to merge submodule %s "
1870
"(repository corrupt)"),
1871
path);
1872
+ ret = -1;
1873
goto cleanup;
1874
}
1875
if (ret2 > 0) {
@@ -1899,6 +1903,7 @@ static int merge_submodule(struct merge_options *opt,
1903
_("Failed to merge submodule %s "
1904
"(repository corrupt)"),
1905
path);
1906
+ ret = -1;
1907
break;
1908
case 0:
1909
path_msg(opt, CONFLICT_SUBMODULE_FAILED_TO_MERGE, 0,
merge-recursive.c
+8
@@ -1246,12 +1246,14 @@ static int merge_submodule(struct merge_options *opt,
1246
ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_a);
1247
if (ret2 < 0) {
1248
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1249
+ ret = -1;
1250
goto cleanup;
1251
}
1252
if (ret2 > 0)
1253
ret2 = repo_in_merge_bases(&subrepo, commit_base, commit_b);
1254
if (ret2 < 0) {
1255
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1256
+ ret = -1;
1257
goto cleanup;
1258
}
1259
if (!ret2) {
@@ -1263,6 +1265,7 @@ static int merge_submodule(struct merge_options *opt,
1265
ret2 = repo_in_merge_bases(&subrepo, commit_a, commit_b);
1266
if (ret2 < 0) {
1267
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1268
+ ret = -1;
1269
goto cleanup;
1270
}
1271
if (ret2) {
@@ -1281,6 +1284,7 @@ static int merge_submodule(struct merge_options *opt,
1284
ret2 = repo_in_merge_bases(&subrepo, commit_b, commit_a);
1285
if (ret2 < 0) {
1286
output(opt, 1, _("Failed to merge submodule %s (repository corrupt)"), path);
1287
+ ret = -1;
1288
goto cleanup;
1289
}
1290
if (ret2) {
@@ -1312,6 +1316,10 @@ static int merge_submodule(struct merge_options *opt,
1316
parent_count = find_first_merges(&subrepo, &merges, path,
1317
commit_a, commit_b);
1318
switch (parent_count) {
1319
+ case -1:
1320
+ output(opt, 1,_("Failed to merge submodule %s (repository corrupt)"), path);
1321
+ ret = -1;
1322
+ break;
1323
case 0:
1324
output(opt, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
1325
break;