Skip to content

Commit 81a34cb

Browse files
dschogitster
authored andcommitted
merge-recursive: prepare for merge_submodule() to report errors
The `merge_submodule()` function returns an integer that indicates whether the merge was clean (returning 1) or unclean (returning 0). Like the version in `merge-ort.c`, the version in `merge-recursive.c` does not report any errors (such as repository corruption) by returning -1 as of time of writing, even if the callers in `merge-ort.c` are prepared for exactly such errors. However, we want to teach (both variants of) the `merge_submodule()` function that trick: to report errors by returning -1. Therefore, prepare the caller in `merge-recursive.c` to handle 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 caaf1a2 commit 81a34cb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

merge-recursive.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,13 +1426,14 @@ static int merge_mode_and_contents(struct merge_options *opt,
14261426
/* FIXME: bug, what if modes didn't match? */
14271427
result->clean = (merge_status == 0);
14281428
} else if (S_ISGITLINK(a->mode)) {
1429-
result->clean = merge_submodule(opt, &result->blob.oid,
1430-
o->path,
1431-
&o->oid,
1432-
&a->oid,
1433-
&b->oid);
1434-
if (result->clean < 0)
1429+
int clean = merge_submodule(opt, &result->blob.oid,
1430+
o->path,
1431+
&o->oid,
1432+
&a->oid,
1433+
&b->oid);
1434+
if (clean < 0)
14351435
return -1;
1436+
result->clean = clean;
14361437
} else if (S_ISLNK(a->mode)) {
14371438
switch (opt->recursive_variant) {
14381439
case MERGE_VARIANT_NORMAL:

0 commit comments

Comments
 (0)