refuse to merge during a merge
The following is an easy mistake to make for users coming from version control systems with an "update and commit"-style workflow. 1. git pull 2. resolve conflicts 3. git pull Step 3 overrides MERGE_HEAD, starting a new merge with dirty index. IOW, probably not what the user intended. Instead, refuse to merge again if a merge is in progress. Reported-by: Dave Olszewski <cxreg@pobox.com> Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Clemens Buchacher committed
Jun 1, 2009 at 11:20 UTC
c8c562a238071843c64ea0f3a2c85481606da379
2 files changed
+7
-1
builtin-merge.c
+4
-1
@@ -836,8 +836,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
836
struct commit_list **remotes = &remoteheads;
837
838
setup_work_tree();
839
+ if (file_exists(git_path("MERGE_HEAD")))
840
+ die("You have not concluded your merge. (MERGE_HEAD exists)");
841
if (read_cache_unmerged())
840
- die("You are in the middle of a conflicted merge.");
842
+ die("You are in the middle of a conflicted merge."
843
+ " (index unmerged)");
844
845
/*
846
* Check if we are _not_ on a detached HEAD, i.e. if there is a
t/t3030-merge-recursive.sh
+3
@@ -276,6 +276,9 @@ test_expect_success 'fail if the index has unresolved entries' '
276
277
test_must_fail git merge "$c5" &&
278
test_must_fail git merge "$c5" 2> out &&
279
+ grep "You have not concluded your merge" out &&
280
+ rm -f .git/MERGE_HEAD &&
281
+ test_must_fail git merge "$c5" 2> out &&
282
grep "You are in the middle of a conflicted merge" out
283
284
'