From: Clemens Buchacher <drizzd@aon.at>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Dave Olszewski <cxreg@pobox.com>,
John Tapsell <johnflux@gmail.com>
Subject: [PATCH] refuse to merge during a merge
Date: Sun, 31 May 2009 12:43:59 +0200 [thread overview]
Message-ID: <20090531104359.GA19094@localhost> (raw)
In-Reply-To: <20090530083721.GA12963@localhost>
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 intented. Instead, refuse to merge
again if a merge is in progress and present the user with his options.
"git reset --hard" is not suggested, because it potentially removes
changes unrelated to the merge (if the work tree was dirty prior to
the merge).
Reported-by: Dave Olszewski <cxreg@pobox.com>
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
Ok, since I'm not seeing any more objections. Here's the code.
Clemens
builtin-merge.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/builtin-merge.c b/builtin-merge.c
index 0b58e5e..8169ded 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -834,10 +834,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
struct commit_list *common = NULL;
const char *best_strategy = NULL, *wt_strategy = NULL;
struct commit_list **remotes = &remoteheads;
+ int unmerged;
setup_work_tree();
- if (read_cache_unmerged())
- die("You are in the middle of a conflicted merge.");
+ unmerged = read_cache_unmerged();
+ if (unmerged || file_exists(git_path("MERGE_HEAD")))
+ die("You are in the middle of a %smerge. To complete "
+ "the merge %scommit the changes. To abort, "
+ "use \"git reset HEAD\".",
+ unmerged ? "conflicted " : "",
+ unmerged ? "resolve conflicts and " : "");
/*
* Check if we are _not_ on a detached HEAD, i.e. if there is a
--
1.6.3.1.147.g637c3
next prev parent reply other threads:[~2009-05-31 10:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-27 21:04 [PATCH] refuse to merge during a merge Clemens Buchacher
2009-05-28 16:00 ` Constantine Plotnikov
2009-05-28 16:12 ` John Tapsell
2009-05-30 8:37 ` Clemens Buchacher
2009-05-30 10:38 ` Jakub Narebski
2009-05-30 10:57 ` Thomas Rast
2009-05-31 10:43 ` Clemens Buchacher [this message]
2009-05-31 11:05 ` John Tapsell
2009-05-31 14:05 ` Clemens Buchacher
2009-05-31 19:36 ` Junio C Hamano
2009-06-01 9:20 ` [PATCH v3] " Clemens Buchacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090531104359.GA19094@localhost \
--to=drizzd@aon.at \
--cc=cxreg@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johnflux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).