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: "Derrick Stolee" <derrickstolee@github.com>,
	"Elijah Newren" <newren@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Martin Ågren" <martin.agren@gmail.com>,
	"Phillip Wood" <phillip.wood123@gmail.com>,
	"Elijah Newren" <newren@gmail.com>,
	"Elijah Newren" <newren@gmail.com>
Subject: [PATCH v5 05/10] rebase: fix incompatiblity checks for --[no-]reapply-cherry-picks
Date: Wed, 25 Jan 2023 04:03:49 +0000	[thread overview]
Message-ID: <3a8429f3d2b72d59d0a071d83f6fd9effe6824ed.1674619434.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1466.v5.git.1674619434.gitgitgadget@gmail.com>

From: Elijah Newren <newren@gmail.com>

--[no-]reapply-cherry-picks was traditionally only supported by the
sequencer.  Support was added for the apply backend, when --keep-base is
also specified, in commit ce5238a690 ("rebase --keep-base: imply
--reapply-cherry-picks", 2022-10-17).  Make the code error out when
--[no-]reapply-cherry-picks is specified AND the apply backend is used
AND --keep-base is not specified.  Also, clarify a number of comments
surrounding the interaction of these flags.

Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
 Documentation/git-rebase.txt           |  2 +-
 builtin/rebase.c                       | 34 ++++++++++++++++----------
 t/t3422-rebase-incompatible-options.sh | 10 ++++++++
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 846aeed1b69..8a09f12d897 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -650,7 +650,7 @@ are incompatible with the following options:
  * --exec
  * --no-keep-empty
  * --empty=
- * --reapply-cherry-picks
+ * --[no-]reapply-cherry-picks when used without --keep-base
  * --edit-todo
  * --update-refs
  * --root when used without --onto
diff --git a/builtin/rebase.c b/builtin/rebase.c
index b742cc8fb5c..05b130bfae5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1224,13 +1224,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		if (options.fork_point < 0)
 			options.fork_point = 0;
 	}
-	/*
-	 * --keep-base defaults to --reapply-cherry-picks to avoid losing
-	 * commits when using this option.
-	 */
-	if (options.reapply_cherry_picks < 0)
-		options.reapply_cherry_picks = keep_base;
-
 	if (options.root && options.fork_point > 0)
 		die(_("options '%s' and '%s' cannot be used together"), "--root", "--fork-point");
 
@@ -1406,12 +1399,27 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (options.empty != EMPTY_UNSPECIFIED)
 		imply_merge(&options, "--empty");
 
-	/*
-	 * --keep-base implements --reapply-cherry-picks by altering upstream so
-	 * it works with both backends.
-	 */
-	if (options.reapply_cherry_picks && !keep_base)
-		imply_merge(&options, "--reapply-cherry-picks");
+	if (options.reapply_cherry_picks < 0)
+		/*
+		 * We default to --no-reapply-cherry-picks unless
+		 * --keep-base is given; when --keep-base is given, we want
+		 * to default to --reapply-cherry-picks.
+		 */
+		options.reapply_cherry_picks = keep_base;
+	else if (!keep_base)
+		/*
+		 * The apply backend always searches for and drops cherry
+		 * picks.  This is often not wanted with --keep-base, so
+		 * --keep-base allows --reapply-cherry-picks to be
+		 * simulated by altering the upstream such that
+		 * cherry-picks cannot be detected and thus all commits are
+		 * reapplied.  Thus, --[no-]reapply-cherry-picks is
+		 * supported when --keep-base is specified, but not when
+		 * --keep-base is left out.
+		 */
+		imply_merge(&options, options.reapply_cherry_picks ?
+					  "--reapply-cherry-picks" :
+					  "--no-reapply-cherry-picks");
 
 	if (gpg_sign)
 		options.gpg_sign_opt = xstrfmt("-S%s", gpg_sign);
diff --git a/t/t3422-rebase-incompatible-options.sh b/t/t3422-rebase-incompatible-options.sh
index f86274990b0..826f3b94ae6 100755
--- a/t/t3422-rebase-incompatible-options.sh
+++ b/t/t3422-rebase-incompatible-options.sh
@@ -60,6 +60,16 @@ test_rebase_am_only () {
 		test_must_fail git rebase $opt --exec 'true' A
 	"
 
+	test_expect_success "$opt incompatible with --no-reapply-cherry-picks" "
+		git checkout B^0 &&
+		test_must_fail git rebase $opt --no-reapply-cherry-picks A
+	"
+
+	test_expect_success "$opt incompatible with --reapply-cherry-picks" "
+		git checkout B^0 &&
+		test_must_fail git rebase $opt --reapply-cherry-picks A
+	"
+
 	test_expect_success "$opt incompatible with --update-refs" "
 		git checkout B^0 &&
 		test_must_fail git rebase $opt --update-refs A
-- 
gitgitgadget


  parent reply	other threads:[~2023-01-25  4:04 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19  5:36 [PATCH] rebase: mark --update-refs as requiring the merge backend Elijah Newren via GitGitGadget
2023-01-19 21:47 ` Derrick Stolee
2023-01-20  1:54   ` Elijah Newren
2023-01-20 15:27   ` Junio C Hamano
2023-01-20 16:47     ` Elijah Newren
2023-01-20  4:56 ` [PATCH v2 0/2] " Elijah Newren via GitGitGadget
2023-01-20  4:56   ` [PATCH v2 1/2] rebase: remove completely useless -C option Elijah Newren via GitGitGadget
2023-01-20  5:40     ` Eric Sunshine
2023-01-20  6:42       ` Elijah Newren
2023-01-20  9:55     ` Martin Ågren
2023-01-20 15:32       ` Elijah Newren
2023-01-20 12:05     ` Junio C Hamano
2023-01-20 15:31       ` Elijah Newren
2023-01-20 16:15         ` Junio C Hamano
2023-01-21  4:52           ` Elijah Newren
2023-01-22  0:02             ` Junio C Hamano
2023-01-20  4:56   ` [PATCH v2 2/2] rebase: mark --update-refs as requiring the merge backend Elijah Newren via GitGitGadget
2023-01-20 16:46     ` Phillip Wood
2023-01-21  1:34       ` Elijah Newren
2023-01-21  1:55   ` [PATCH v3 0/7] rebase: fix several code/testing/documentation issues around flag incompatibilities Elijah Newren via GitGitGadget
2023-01-21  1:55     ` [PATCH v3 1/7] rebase: mark --update-refs as requiring the merge backend Elijah Newren via GitGitGadget
2023-01-21  1:55     ` [PATCH v3 2/7] rebase: flag --apply and --merge as incompatible Elijah Newren via GitGitGadget
2023-01-21  1:55     ` [PATCH v3 3/7] rebase: remove --allow-empty-message from incompatible opts Elijah Newren via GitGitGadget
2023-01-21 15:09       ` Phillip Wood
2023-01-21  1:55     ` [PATCH v3 4/7] rebase: fix docs about incompatibilities with --root Elijah Newren via GitGitGadget
2023-01-21  1:55     ` [PATCH v3 5/7] rebase: add coverage of other incompatible options Elijah Newren via GitGitGadget
2023-01-21 15:20       ` Phillip Wood
2023-01-21 19:25         ` Phillip Wood
2023-01-22  5:11           ` Elijah Newren
2023-01-21  1:55     ` [PATCH v3 6/7] rebase: clarify the OPT_CMDMODE incompatibilities Elijah Newren via GitGitGadget
2023-01-21  1:55     ` [PATCH v3 7/7] rebase: fix formatting of rebase --reapply-cherry-picks option in docs Elijah Newren via GitGitGadget
2023-01-21 15:21       ` Phillip Wood
2023-01-22  6:12     ` [PATCH v4 0/9] rebase: fix several code/testing/documentation issues around flag incompatibilities Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 1/9] rebase: mark --update-refs as requiring the merge backend Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 2/9] rebase: flag --apply and --merge as incompatible Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 3/9] rebase: remove --allow-empty-message from incompatible opts Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 4/9] rebase: fix docs about incompatibilities with --root Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 5/9] rebase: add coverage of other incompatible options Elijah Newren via GitGitGadget
2023-01-23 20:08         ` Phillip Wood
2023-01-24  2:36           ` Elijah Newren
2023-01-24 10:27             ` Phillip Wood
2023-01-24 13:16               ` Phillip Wood
2023-01-24 14:48                 ` Junio C Hamano
2023-01-24 15:41                 ` Elijah Newren
2023-01-24 16:48                   ` Phillip Wood
2023-01-24 17:12                     ` Elijah Newren
2023-01-24 19:21                       ` Phillip Wood
2023-01-22  6:12       ` [PATCH v4 6/9] rebase: clarify the OPT_CMDMODE incompatibilities Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 7/9] rebase: fix formatting of rebase --reapply-cherry-picks option in docs Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 8/9] rebase: put rebase_options initialization in single place Elijah Newren via GitGitGadget
2023-01-22  6:12       ` [PATCH v4 9/9] rebase: provide better error message for apply options vs. merge config Elijah Newren via GitGitGadget
2023-01-23 15:56       ` [PATCH v4 0/9] rebase: fix several code/testing/documentation issues around flag incompatibilities Derrick Stolee
2023-01-24  2:05         ` Elijah Newren
2023-01-25  4:03       ` [PATCH v5 00/10] " Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 01/10] rebase: mark --update-refs as requiring the merge backend Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 02/10] rebase: flag --apply and --merge as incompatible Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 03/10] rebase: remove --allow-empty-message from incompatible opts Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 04/10] rebase: fix docs about incompatibilities with --root Elijah Newren via GitGitGadget
2023-01-25  4:03         ` Elijah Newren via GitGitGadget [this message]
2023-01-25 14:14           ` [PATCH v5 05/10] rebase: fix incompatiblity checks for --[no-]reapply-cherry-picks Phillip Wood
2023-01-25  4:03         ` [PATCH v5 06/10] rebase: add coverage of other incompatible options Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 07/10] rebase: clarify the OPT_CMDMODE incompatibilities Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 08/10] rebase: fix formatting of rebase --reapply-cherry-picks option in docs Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 09/10] rebase: put rebase_options initialization in single place Elijah Newren via GitGitGadget
2023-01-25  4:03         ` [PATCH v5 10/10] rebase: provide better error message for apply options vs. merge config Elijah Newren via GitGitGadget
2023-01-25 14:17         ` [PATCH v5 00/10] rebase: fix several code/testing/documentation issues around flag incompatibilities Phillip Wood
2023-01-25 16:39         ` Junio C Hamano
2023-01-25 16:48           ` Elijah Newren
2023-02-02 10:29         ` rebase --merge vs --whitespace=fix, was " Johannes Schindelin
2023-02-02 23:48           ` Elijah Newren

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=3a8429f3d2b72d59d0a071d83f6fd9effe6824ed.1674619434.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=martin.agren@gmail.com \
    --cc=newren@gmail.com \
    --cc=phillip.wood123@gmail.com \
    --cc=sunshine@sunshineco.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).