From c8c562a238071843c64ea0f3a2c85481606da379 Mon Sep 17 00:00:00 2001 From: Clemens Buchacher Date: Mon, 1 Jun 2009 11:20:56 +0200 Subject: [PATCH] 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 Signed-off-by: Clemens Buchacher Signed-off-by: Junio C Hamano --- builtin-merge.c | 5 ++++- t/t3030-merge-recursive.sh | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/builtin-merge.c b/builtin-merge.c index 0b58e5eda1..9e9bd526c3 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -836,8 +836,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix) struct commit_list **remotes = &remoteheads; setup_work_tree(); + if (file_exists(git_path("MERGE_HEAD"))) + die("You have not concluded your merge. (MERGE_HEAD exists)"); if (read_cache_unmerged()) - die("You are in the middle of a conflicted merge."); + die("You are in the middle of a conflicted merge." + " (index unmerged)"); /* * Check if we are _not_ on a detached HEAD, i.e. if there is a diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 0de613dc53..9b3fa2bdcd 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -276,6 +276,9 @@ test_expect_success 'fail if the index has unresolved entries' ' test_must_fail git merge "$c5" && test_must_fail git merge "$c5" 2> out && + grep "You have not concluded your merge" out && + rm -f .git/MERGE_HEAD && + test_must_fail git merge "$c5" 2> out && grep "You are in the middle of a conflicted merge" out '