summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2010-11-09 21:49:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-11-17 21:23:55 (GMT)
commit2a22c1b35d6110e72d86a2fac4b68dbad0905adb (patch)
treed4edcb49da9517972f8d11911acb80799e3f0b39 /builtin
parent618cd75707580819f19a5f01dba406ac72219c78 (diff)
downloadgit-2a22c1b35d6110e72d86a2fac4b68dbad0905adb.zip
git-2a22c1b35d6110e72d86a2fac4b68dbad0905adb.tar.gz
git-2a22c1b35d6110e72d86a2fac4b68dbad0905adb.tar.bz2
cmd_merge(): Parse options before checking MERGE_HEAD
Reorder the initial part of builtin/merge.c:cmd_merge() so that command-line options are parsed _before_ we load the index and check for MERGE_HEAD (and exits if it exists). This does not change the behaviour of 'git merge', but is needed in preparation for the implementation of 'git merge --abort' (which requires MERGE_HEAD to be present). This patch has been improved by the following contributions: - Junio C Hamano: fixup minor style issues Thanks-to: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/merge.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 37ce4f5..478a492 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -895,22 +895,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
const char *best_strategy = NULL, *wt_strategy = NULL;
struct commit_list **remotes = &remoteheads;
- if (read_cache_unmerged()) {
- die_resolve_conflict("merge");
- }
- if (file_exists(git_path("MERGE_HEAD"))) {
- /*
- * There is no unmerged entry, don't advise 'git
- * add/rm <file>', just 'git commit'.
- */
- if (advice_resolve_conflict)
- die("You have not concluded your merge (MERGE_HEAD exists).\n"
- "Please, commit your changes before you can merge.");
- else
- die("You have not concluded your merge (MERGE_HEAD exists).");
- }
-
- resolve_undo_clear();
/*
* Check if we are _not_ on a detached HEAD, i.e. if there is a
* current branch.
@@ -929,6 +913,23 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, builtin_merge_options,
builtin_merge_usage, 0);
+
+ if (read_cache_unmerged())
+ die_resolve_conflict("merge");
+
+ if (file_exists(git_path("MERGE_HEAD"))) {
+ /*
+ * There is no unmerged entry, don't advise 'git
+ * add/rm <file>', just 'git commit'.
+ */
+ if (advice_resolve_conflict)
+ die("You have not concluded your merge (MERGE_HEAD exists).\n"
+ "Please, commit your changes before you can merge.");
+ else
+ die("You have not concluded your merge (MERGE_HEAD exists).");
+ }
+ resolve_undo_clear();
+
if (verbosity < 0)
show_diffstat = 0;