From 367ff694281ce569edd8f6e444fc770f92f5d215 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Wed, 14 Dec 2016 21:37:55 +1300 Subject: merge: add '--continue' option as a synonym for 'git commit' 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 Signed-off-by: Junio C Hamano --- builtin/merge.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'builtin/merge.c') diff --git a/builtin/merge.c b/builtin/merge.c index b65eeaa87d..836ec281b4 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -46,6 +46,7 @@ static const char * const builtin_merge_usage[] = { N_("git merge [] [...]"), N_("git merge [] HEAD "), 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), @@ -1125,6 +1129,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) const char *best_strategy = NULL, *wt_strategy = NULL; struct commit_list *remoteheads, *p; void *branch_to_free; + int orig_argc = argc; if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(builtin_merge_usage, builtin_merge_options); @@ -1166,6 +1171,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 (orig_argc != 2) + 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"); -- cgit v1.2.1 From 042e290da6aee0a9f21cd5890ccf231c266e177e Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Wed, 14 Dec 2016 21:37:57 +1300 Subject: merge: ensure '--abort' option takes no arguments Like '--continue', the '--abort' option doesn't make any sense with other options or arguments to 'git merge' so ensure that none are present. Signed-off-by: Chris Packham Signed-off-by: Junio C Hamano --- builtin/merge.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'builtin/merge.c') diff --git a/builtin/merge.c b/builtin/merge.c index 836ec281b4..668aaffb84 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1163,6 +1163,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix) int nargc = 2; const char *nargv[] = {"reset", "--merge", NULL}; + if (orig_argc != 2) + usage_msg_opt("--abort expects no arguments", + builtin_merge_usage, builtin_merge_options); + if (!file_exists(git_path_merge_head())) die(_("There is no merge to abort (MERGE_HEAD missing).")); -- cgit v1.2.1 From c7d227df5bf7fe9d5df98a55cd637bfaf38685ea Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 15 Dec 2016 12:43:46 -0500 Subject: merge: mark usage error strings for translation The nearby error messages are already marked for translation, but these new ones aren't. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/merge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/merge.c') diff --git a/builtin/merge.c b/builtin/merge.c index 668aaffb84..599d25c4cc 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1164,7 +1164,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) const char *nargv[] = {"reset", "--merge", NULL}; if (orig_argc != 2) - usage_msg_opt("--abort expects no arguments", + usage_msg_opt(_("--abort expects no arguments"), builtin_merge_usage, builtin_merge_options); if (!file_exists(git_path_merge_head())) @@ -1180,7 +1180,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) const char *nargv[] = {"commit", NULL}; if (orig_argc != 2) - usage_msg_opt("--continue expects no arguments", + usage_msg_opt(_("--continue expects no arguments"), builtin_merge_usage, builtin_merge_options); if (!file_exists(git_path_merge_head())) -- cgit v1.2.1