summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-05-18 11:30:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-19 01:47:40 (GMT)
commitf3f8311ec76f9bcdc7e26a125e585eb4e473a8d2 (patch)
treecaa84e1112e300a06e7361ed03624e3c8a0f804f /builtin/merge.c
parentb64335554a3691cbc134fb73a598dfd593f44b4e (diff)
downloadgit-f3f8311ec76f9bcdc7e26a125e585eb4e473a8d2.zip
git-f3f8311ec76f9bcdc7e26a125e585eb4e473a8d2.tar.gz
git-f3f8311ec76f9bcdc7e26a125e585eb4e473a8d2.tar.bz2
merge: add --quit
This allows to cancel the current merge without resetting worktree/index, which is what --abort is for. Like other --quit(s), this is often used when you forgot that you're in the middle of a merge and already switched away, doing different things. By the time you've realized, you can't even continue the merge anymore. This also makes all in-progress commands, am, merge, rebase, revert and cherry-pick, take all three --abort, --continue and --quit (bisect has a different UI). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index e9663f0..598d56e 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -73,6 +73,7 @@ static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
static int abort_current_merge;
+static int quit_current_merge;
static int continue_current_merge;
static int allow_unrelated_histories;
static int show_progress = -1;
@@ -267,6 +268,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, "quit", &quit_current_merge,
+ N_("--abort but leave index and working tree alone")),
OPT_BOOL(0, "continue", &continue_current_merge,
N_("continue the current in-progress merge")),
OPT_BOOL(0, "allow-unrelated-histories", &allow_unrelated_histories,
@@ -1252,6 +1255,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
}
+ if (quit_current_merge) {
+ if (orig_argc != 2)
+ usage_msg_opt(_("--quit expects no arguments"),
+ builtin_merge_usage,
+ builtin_merge_options);
+
+ remove_merge_branch_state(the_repository);
+ goto done;
+ }
+
if (continue_current_merge) {
int nargc = 1;
const char *nargv[] = {"commit", NULL};