1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-05 17:36:18 +02:00

Merge branch 'js/merge-base-with-missing-commit' into next

Make sure failure return from merge_bases_many() is properly caught.

* js/merge-base-with-missing-commit:
  merge-ort/merge-recursive: do report errors in `merge_submodule()`
  merge-recursive: prepare for `merge_submodule()` to report errors
This commit is contained in:
Junio C Hamano 2024-03-09 15:32:31 -08:00
commit caa7a7baaa
2 changed files with 20 additions and 6 deletions

View File

@ -1821,6 +1821,7 @@ static int merge_submodule(struct merge_options *opt,
_("Failed to merge submodule %s "
"(repository corrupt)"),
path);
ret = -1;
goto cleanup;
}
if (ret2 > 0)
@ -1831,6 +1832,7 @@ static int merge_submodule(struct merge_options *opt,
_("Failed to merge submodule %s "
"(repository corrupt)"),
path);
ret = -1;
goto cleanup;
}
if (!ret2) {
@ -1850,6 +1852,7 @@ static int merge_submodule(struct merge_options *opt,
_("Failed to merge submodule %s "
"(repository corrupt)"),
path);
ret = -1;
goto cleanup;
}
if (ret2 > 0) {
@ -1868,6 +1871,7 @@ static int merge_submodule(struct merge_options *opt,
_("Failed to merge submodule %s "
"(repository corrupt)"),
path);
ret = -1;
goto cleanup;
}
if (ret2 > 0) {
@ -1901,6 +1905,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,

View File

@ -1247,12 +1247,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) {
@ -1264,6 +1266,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) {
@ -1282,6 +1285,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) {
@ -1313,6 +1317,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;
@ -1427,13 +1435,14 @@ static int merge_mode_and_contents(struct merge_options *opt,
/* FIXME: bug, what if modes didn't match? */
result->clean = (merge_status == 0);
} else if (S_ISGITLINK(a->mode)) {
result->clean = merge_submodule(opt, &result->blob.oid,
o->path,
&o->oid,
&a->oid,
&b->oid);
if (result->clean < 0)
int clean = merge_submodule(opt, &result->blob.oid,
o->path,
&o->oid,
&a->oid,
&b->oid);
if (clean < 0)
return -1;
result->clean = clean;
} else if (S_ISLNK(a->mode)) {
switch (opt->recursive_variant) {
case MERGE_VARIANT_NORMAL: