Skip to content

Commit 9270239

Browse files
newrengitster
authored andcommitted
merge-recursive: make sure when we say we abort that we actually abort
In commit 65170c0 ("merge-recursive: avoid incorporating uncommitted changes in a merge", 2017-12-21), it was noted that there was a special case when merge-recursive didn't rely on unpack_trees() to enforce the index == HEAD requirement, and thus that it needed to do that enforcement itself. Unfortunately, it returned the wrong exit status, signalling that the merge completed but had conflicts, rather than that it was aborted. Fix the return code, and while we're at it, change the error message to match what unpack_trees() would have printed. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf69f2a commit 9270239

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

merge-recursive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,9 +1984,9 @@ int merge_trees(struct merge_options *o,
19841984
struct strbuf sb = STRBUF_INIT;
19851985

19861986
if (!o->call_depth && index_has_changes(&the_index, &sb)) {
1987-
err(o, _("Dirty index: cannot merge (dirty: %s)"),
1987+
err(o, _("Your local changes to the following files would be overwritten by merge:\n %s"),
19881988
sb.buf);
1989-
return 0;
1989+
return -1;
19901990
}
19911991
output(o, 0, _("Already up to date!"));
19921992
*result = head;

t/t6044-merge-unrelated-index-changes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ test_expect_success 'recursive' '
116116
test_path_is_missing .git/MERGE_HEAD
117117
'
118118

119-
test_expect_failure 'recursive, when merge branch matches merge base' '
119+
test_expect_success 'recursive, when merge branch matches merge base' '
120120
git reset --hard &&
121121
git checkout B^0 &&
122122

0 commit comments

Comments
 (0)