From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD
Date: Wed, 15 Aug 2018 18:23:08 +0200 [thread overview]
Message-ID: <20180815162308.17747-2-pclouds@gmail.com> (raw)
In-Reply-To: <20180815162308.17747-1-pclouds@gmail.com>
--quit is supposed to be --abort but without restoring HEAD. Leaving
CHERRY_PICK_HEAD behind could make other commands mistake that
cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to
work). Clean it too.
For abort, this job of deleting CHERRY_PICK_HEAD is on "git reset" so
we don't need to do anything else.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/revert.c | 9 +++++++--
t/t3510-cherry-pick-sequence.sh | 3 ++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/builtin/revert.c b/builtin/revert.c
index 76f0a35b07..e94a4ead2b 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -7,6 +7,7 @@
#include "rerere.h"
#include "dir.h"
#include "sequencer.h"
+#include "branch.h"
/*
* This implements the builtins revert and cherry-pick.
@@ -191,8 +192,12 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
opts->gpg_sign = xstrdup_or_null(opts->gpg_sign);
opts->strategy = xstrdup_or_null(opts->strategy);
- if (cmd == 'q')
- return sequencer_remove_state(opts);
+ if (cmd == 'q') {
+ int ret = sequencer_remove_state(opts);
+ if (!ret)
+ remove_branch_state(the_repository);
+ return ret;
+ }
if (cmd == 'c')
return sequencer_continue(opts);
if (cmd == 'a')
diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
index 3505b6aa14..9d121f8ce6 100755
--- a/t/t3510-cherry-pick-sequence.sh
+++ b/t/t3510-cherry-pick-sequence.sh
@@ -103,7 +103,8 @@ test_expect_success '--quit cleans up sequencer state' '
pristine_detach initial &&
test_expect_code 1 git cherry-pick base..picked &&
git cherry-pick --quit &&
- test_path_is_missing .git/sequencer
+ test_path_is_missing .git/sequencer &&
+ test_path_is_missing .git/CHERRY_PICK_HEAD
'
test_expect_success '--quit keeps HEAD and conflicted index intact' '
--
2.18.0.1004.g6639190530
next prev parent reply other threads:[~2018-08-15 16:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-15 16:23 [PATCH 1/2] branch.c: remove explicit reference to the_repository Nguyễn Thái Ngọc Duy
2018-08-15 16:23 ` Nguyễn Thái Ngọc Duy [this message]
2018-08-15 17:09 ` [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD Stefan Beller
2018-08-15 17:17 ` Duy Nguyen
2018-08-15 17:22 ` Stefan Beller
2018-08-15 17:26 ` Junio C Hamano
2018-08-15 17:30 ` Duy Nguyen
2018-08-15 17:33 ` Junio C Hamano
2018-08-16 16:06 ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2018-08-16 17:02 ` Junio C Hamano
2018-08-15 16:48 ` [PATCH 1/2] branch.c: remove explicit reference to the_repository Elijah Newren
2018-08-15 16:52 ` Duy Nguyen
2018-08-15 16:58 ` Stefan Beller
2018-08-15 17:11 ` Duy Nguyen
2018-08-15 17:38 ` Junio C Hamano
2018-08-15 17:43 ` Duy Nguyen
2018-08-15 17:20 ` Junio C Hamano
2018-08-15 17:23 ` Duy Nguyen
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=20180815162308.17747-2-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/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).