From: Chris Packham <judge.packham@gmail.com>
To: git@vger.kernel.org
Cc: mah@jump-ing.de, peff@peff.net, jacob.keller@gmail.com,
gitster@pobox.com, Chris Packham <judge.packham@gmail.com>
Subject: [PATCHv2 1/2] merge: Add '--continue' option as a synonym for 'git commit'
Date: Tue, 13 Dec 2016 21:48:58 +1300 [thread overview]
Message-ID: <20161213084859.13426-1-judge.packham@gmail.com> (raw)
In-Reply-To: <20161212083413.7334-1-judge.packham@gmail.com>
Teach 'git merge' the --continue option which allows 'continuing' a
merge by completing it. The traditional way of completing a merge after
resolving conflicts is to use 'git commit'. Now with commands like 'git
rebase' and 'git cherry-pick' having a '--continue' option adding such
an option to 'git merge' presents a consistent UI.
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
Notes:
Changes in v2:
- add --continue to builtin_merge_usage
- verify that no other arguments are present when --continue is used.
- add basic test
Documentation/git-merge.txt | 13 ++++++++++++-
builtin/merge.c | 22 +++++++++++++++++++++-
t/t7600-merge.sh | 8 ++++++++
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index b758d5556..765b0f26e 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -15,6 +15,7 @@ SYNOPSIS
[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
'git merge' <msg> HEAD <commit>...
'git merge' --abort
+'git merge' --continue
DESCRIPTION
-----------
@@ -61,6 +62,9 @@ reconstruct the original (pre-merge) changes. Therefore:
discouraged: while possible, it may leave you in a state that is hard to
back out of in the case of a conflict.
+The fourth syntax ("`git merge --continue`") can only be run after the
+merge has resulted in conflicts. 'git merge --continue' will take the
+currently staged changes and complete the merge.
OPTIONS
-------
@@ -99,6 +103,12 @@ commit or stash your changes before running 'git merge'.
'git merge --abort' is equivalent to 'git reset --merge' when
`MERGE_HEAD` is present.
+--continue::
+ Take the currently staged changes and complete the merge.
++
+'git merge --continue' is equivalent to 'git commit' when
+`MERGE_HEAD` is present.
+
<commit>...::
Commits, usually other branch heads, to merge into our branch.
Specifying more than one commit will create a merge with
@@ -277,7 +287,8 @@ After seeing a conflict, you can do two things:
* Resolve the conflicts. Git will mark the conflicts in
the working tree. Edit the files into shape and
- 'git add' them to the index. Use 'git commit' to seal the deal.
+ 'git add' them to the index. Use 'git merge --continue' to seal the
+ deal.
You can work through the conflict with a number of tools:
diff --git a/builtin/merge.c b/builtin/merge.c
index b65eeaa87..379685223 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -46,6 +46,7 @@ static const char * const builtin_merge_usage[] = {
N_("git merge [<options>] [<commit>...]"),
N_("git merge [<options>] <msg> HEAD <commit>"),
N_("git merge --abort"),
+ N_("git merge --continue"),
NULL
};
@@ -65,6 +66,7 @@ static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
static int abort_current_merge;
+static int continue_current_merge;
static int allow_unrelated_histories;
static int show_progress = -1;
static int default_to_upstream = 1;
@@ -223,6 +225,8 @@ static struct option builtin_merge_options[] = {
OPT__VERBOSITY(&verbosity),
OPT_BOOL(0, "abort", &abort_current_merge,
N_("abort the current in-progress merge")),
+ OPT_BOOL(0, "continue", &continue_current_merge,
+ N_("continue the current in-progress merge")),
OPT_BOOL(0, "allow-unrelated-histories", &allow_unrelated_histories,
N_("allow merging unrelated histories")),
OPT_SET_INT(0, "progress", &show_progress, N_("force progress reporting"), 1),
@@ -739,7 +743,7 @@ static void abort_commit(struct commit_list *remoteheads, const char *err_msg)
if (err_msg)
error("%s", err_msg);
fprintf(stderr,
- _("Not committing merge; use 'git commit' to complete the merge.\n"));
+ _("Not committing merge; use 'git merge --continue' to complete the merge.\n"));
write_merge_state(remoteheads);
exit(1);
}
@@ -1166,6 +1170,22 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
}
+ if (continue_current_merge) {
+ int nargc = 1;
+ const char *nargv[] = {"commit", NULL};
+
+ if (argc)
+ usage_msg_opt("--continue expects no arguments",
+ builtin_merge_usage, builtin_merge_options);
+
+ if (!file_exists(git_path_merge_head()))
+ die(_("There is no merge in progress (MERGE_HEAD missing)."));
+
+ /* Invoke 'git commit' */
+ ret = cmd_commit(nargc, nargv, prefix);
+ goto done;
+ }
+
if (read_cache_unmerged())
die_resolve_conflict("merge");
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 85248a14b..44b34ef3a 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -154,6 +154,7 @@ test_expect_success 'test option parsing' '
test_must_fail git merge -s foobar c1 &&
test_must_fail git merge -s=foobar c1 &&
test_must_fail git merge -m &&
+ test_must_fail git merge --continue foobar &&
test_must_fail git merge
'
@@ -763,4 +764,11 @@ test_expect_success 'merge nothing into void' '
)
'
+test_expect_success 'merge can be completed with --continue' '
+ git reset --hard c0 &&
+ git merge --no-ff --no-commit c1 &&
+ git merge --continue &&
+ verify_parents $c0 $c1
+'
+
test_done
--
2.11.0.24.ge6920cf
next prev parent reply other threads:[~2016-12-13 8:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-09 7:57 Any interest in 'git merge --continue' as a command Chris Packham
2016-12-09 9:11 ` Jeff King
2016-12-09 10:37 ` Jacob Keller
2016-12-09 19:16 ` Junio C Hamano
2016-12-10 8:49 ` Chris Packham
2016-12-10 9:00 ` Jeff King
2016-12-10 10:58 ` Jacob Keller
2016-12-12 8:34 ` [RFC/PATCH] merge: Add '--continue' option as a synonym for 'git commit' Chris Packham
2016-12-12 9:02 ` Markus Hitter
2016-12-13 8:33 ` Chris Packham
2016-12-12 9:40 ` Jeff King
2016-12-13 8:48 ` Chris Packham [this message]
2016-12-13 8:48 ` [PATCHv2 2/2] completion: add --continue option for merge Chris Packham
2016-12-13 11:59 ` [PATCHv2 1/2] merge: Add '--continue' option as a synonym for 'git commit' Jeff King
2016-12-13 18:02 ` Junio C Hamano
2016-12-14 8:37 ` [PATCHv3 1/3] " Chris Packham
2016-12-14 8:37 ` [PATCH 2/3] completion: add --continue option for merge Chris Packham
2016-12-14 8:37 ` [PATCH 3/3] merge: Ensure '--abort' option takes no arguments Chris Packham
2016-12-14 15:20 ` [PATCHv3 1/3] merge: Add '--continue' option as a synonym for 'git commit' Jeff King
2016-12-14 17:01 ` Junio C Hamano
2016-12-14 18:04 ` Junio C Hamano
2016-12-15 7:29 ` Chris Packham
2016-12-15 17:36 ` Junio C Hamano
2016-12-15 17:43 ` Jeff King
2016-12-10 8:59 ` Any interest in 'git merge --continue' as a command Jeff King
2016-12-10 18:16 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161213084859.13426-1-judge.packham@gmail.com \
--to=judge.packham@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.keller@gmail.com \
--cc=mah@jump-ing.de \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).