summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2022-07-23 01:53:14 +0000
committerJunio C Hamano <gitster@pobox.com>2022-07-22 21:45:23 -0700
commit8f240b8bbb63591f15c10e43debaf564e63a66bd (patch)
treec8196e3c6655afe3c14072ac3bc146281c31a021 /builtin
parente4cdfe84a0d2ac560bf0a2ab0e9beade5f71a844 (diff)
downloadgit-8f240b8bbb63591f15c10e43debaf564e63a66bd.tar.gz
merge: do not abort early if one strategy fails to handle the merge
builtin/merge is setup to allow multiple strategies to be specified, and it will find the "best" result and use it. This is defeated if some of the merge strategies abort early when they cannot handle the merge. Fix the logic that calls recursive and ort to not do such an early abort, but instead return "2" or "unhandled" so that the next strategy can try to handle the merge. Coming up with a testcase for this is somewhat difficult, since recursive and ort both handle nearly any two-headed merge (there is a separate code path that checks for non-two-headed merges and already returns "2" for them). So use a somewhat synthetic testcase of having the index not match HEAD before the merge starts, since all merge strategies will abort for that. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/merge.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index b43876f68e..c120ad619c 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -754,8 +754,10 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
else
clean = merge_recursive(&o, head, remoteheads->item,
reversed, &result);
- if (clean < 0)
- exit(128);
+ if (clean < 0) {
+ rollback_lock_file(&lock);
+ return 2;
+ }
if (write_locked_index(&the_index, &lock,
COMMIT_LOCK | SKIP_IF_UNCHANGED))
die(_("unable to write %s"), get_index_file());