git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Phillip Wood <phillip.wood123@gmail.com>,
	Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
	Elijah Newren <newren@gmail.com>,
	Elijah Newren <newren@gmail.com>
Subject: [PATCH v2 1/2] sequencer: clear state upon dropping a become-empty commit
Date: Wed, 11 Mar 2020 15:30:22 +0000	[thread overview]
Message-ID: <84b89d7843527d7b1f3e00f122dc1e82f1ced381.1583940623.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.722.v2.git.git.1583940623.gitgitgadget@gmail.com>

From: Elijah Newren <newren@gmail.com>

In commit e98c4269c8 ("rebase (interactive-backend): fix handling of
commits that become empty", 2020-02-15), the merge backend was changed
to drop commits that did not start empty but became so after being
applied (because their changes were a subset of what was already
upstream).  This new code path did not need to go through the process of
creating a commit, since we were dropping the commit instead.
Unfortunately, this also means we bypassed the clearing of the
CHERRY_PICK_HEAD and MERGE_MSG files, which if there were no further
commits to cherry-pick would mean that the rebase would end but assume
there was still an operation in progress.  Ensure that we clear such
state files when we decide to drop the commit.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 sequencer.c             | 2 ++
 t/t3424-rebase-empty.sh | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/sequencer.c b/sequencer.c
index 7477b15422a..e528225e787 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1957,6 +1957,8 @@ static int do_pick_commit(struct repository *r,
 		flags |= ALLOW_EMPTY;
 	} else if (allow == 2) {
 		drop_commit = 1;
+		unlink(git_path_cherry_pick_head(r));
+		unlink(git_path_merge_msg(r));
 		fprintf(stderr,
 			_("dropping %s %s -- patch contents already upstream\n"),
 			oid_to_hex(&commit->object.oid), msg.subject);
diff --git a/t/t3424-rebase-empty.sh b/t/t3424-rebase-empty.sh
index 98fc2a558a0..e1e30517ea6 100755
--- a/t/t3424-rebase-empty.sh
+++ b/t/t3424-rebase-empty.sh
@@ -123,4 +123,12 @@ test_expect_success 'rebase --interactive uses default of --empty=ask' '
 	test_cmp expect actual
 '
 
+test_expect_success 'rebase --merge does not leave state laying around' '
+	git checkout -B testing localmods~2 &&
+	git rebase --merge upstream &&
+
+	test_path_is_missing .git/CHERRY_PICK_HEAD &&
+	test_path_is_missing .git/MERGE_MSG
+'
+
 test_done
-- 
gitgitgadget


  reply	other threads:[~2020-03-11 15:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11  5:13 [PATCH 0/2] Fix 2.26.0 rebase regression and documentation shortcoming Elijah Newren via GitGitGadget
2020-03-11  5:13 ` [PATCH 1/2] sequencer: clear CHERRY_PICK_HEAD upon dropping a become-empty commit Elijah Newren via GitGitGadget
2020-03-11 10:30   ` Phillip Wood
2020-03-11 18:38     ` Junio C Hamano
2020-03-11 19:27       ` Jeff King
2020-03-11 20:18         ` Junio C Hamano
2020-03-11  5:13 ` [PATCH 2/2] git-rebase.txt: highlight backend differences with commit rewording Elijah Newren via GitGitGadget
2020-03-11 15:30 ` [PATCH v2 0/2] Fix 2.26.0 rebase regression and documentation shortcoming Elijah Newren via GitGitGadget
2020-03-11 15:30   ` Elijah Newren via GitGitGadget [this message]
2020-03-11 16:34     ` [PATCH v2 1/2] sequencer: clear state upon dropping a become-empty commit Jeff King
2020-03-11 17:16       ` Elijah Newren
2020-03-11 19:33         ` Jeff King
2020-03-11 15:30   ` [PATCH v2 2/2] git-rebase.txt: highlight backend differences with commit rewording Elijah Newren via GitGitGadget
2020-03-11 16:36     ` Jeff King
2020-03-11 19:10       ` 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=84b89d7843527d7b1f3e00f122dc1e82f1ced381.1583940623.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=phillip.wood123@gmail.com \
    /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).