git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 09/12] rebase -r: support merge strategies other than `recursive`
Date: Thu, 25 Jul 2019 03:11:21 -0700 (PDT)	[thread overview]
Message-ID: <30405df99ff38466987e64c1dea007ff6fb9b8c8.1564049474.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.294.git.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

We already support merge strategies in the sequencer, but only for
`pick` commands.

With this commit, we now also support them in `merge` commands. The
approach is simple: if any merge strategy option is specified, or if any
merge strategy other than `recursive` is specified, we simply spawn the
`git merge` command. Otherwise, we handle the merge in-process just as
before.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Documentation/git-rebase.txt           |  2 --
 builtin/rebase.c                       |  9 ---------
 sequencer.c                            | 14 ++++++++++++--
 t/t3422-rebase-incompatible-options.sh | 10 ----------
 t/t3430-rebase-merges.sh               | 21 +++++++++++++++++++++
 5 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index f5e6ae3907..f67f96425c 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -543,8 +543,6 @@ In addition, the following pairs of options are incompatible:
  * --preserve-merges and --interactive
  * --preserve-merges and --signoff
  * --preserve-merges and --rebase-merges
- * --rebase-merges and --strategy
- * --rebase-merges and --strategy-option
 
 BEHAVIORAL DIFFERENCES
 -----------------------
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 9c52144fc4..c1ea617125 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1815,15 +1815,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			      "'--reschedule-failed-exec'"));
 	}
 
-	if (options.rebase_merges) {
-		if (strategy_options.nr)
-			die(_("cannot combine '--rebase-merges' with "
-			      "'--strategy-option'"));
-		if (options.strategy)
-			die(_("cannot combine '--rebase-merges' with "
-			      "'--strategy'"));
-	}
-
 	if (!options.root) {
 		if (argc < 1) {
 			struct branch *branch;
diff --git a/sequencer.c b/sequencer.c
index 334de14542..d228448cd8 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3256,6 +3256,9 @@ static int do_merge(struct repository *r,
 	struct commit *head_commit, *merge_commit, *i;
 	struct commit_list *bases, *j, *reversed = NULL;
 	struct commit_list *to_merge = NULL, **tail = &to_merge;
+	const char *strategy = !opts->xopts_nr &&
+		(!opts->strategy || !strcmp(opts->strategy, "recursive")) ?
+		NULL : opts->strategy;
 	struct merge_options o;
 	int merge_arg_len, oneline_offset, can_fast_forward, ret, k;
 	static struct lock_file lock;
@@ -3404,7 +3407,7 @@ static int do_merge(struct repository *r,
 		goto leave_merge;
 	}
 
-	if (to_merge->next) {
+	if (strategy || to_merge->next) {
 		/* Octopus merge */
 		struct child_process cmd = CHILD_PROCESS_INIT;
 
@@ -3418,7 +3421,14 @@ static int do_merge(struct repository *r,
 		cmd.git_cmd = 1;
 		argv_array_push(&cmd.args, "merge");
 		argv_array_push(&cmd.args, "-s");
-		argv_array_push(&cmd.args, "octopus");
+		if (!strategy)
+			argv_array_push(&cmd.args, "octopus");
+		else {
+			argv_array_push(&cmd.args, strategy);
+			for (k = 0; k < opts->xopts_nr; k++)
+				argv_array_pushf(&cmd.args,
+						 "-X%s", opts->xopts[k]);
+		}
 		argv_array_push(&cmd.args, "--no-edit");
 		argv_array_push(&cmd.args, "--no-ff");
 		argv_array_push(&cmd.args, "--no-log");
diff --git a/t/t3422-rebase-incompatible-options.sh b/t/t3422-rebase-incompatible-options.sh
index bb78a6ec86..596caf168a 100755
--- a/t/t3422-rebase-incompatible-options.sh
+++ b/t/t3422-rebase-incompatible-options.sh
@@ -75,14 +75,4 @@ test_expect_success '--preserve-merges incompatible with --rebase-merges' '
 	test_must_fail git rebase --preserve-merges --rebase-merges A
 '
 
-test_expect_success '--rebase-merges incompatible with --strategy' '
-	git checkout B^0 &&
-	test_must_fail git rebase --rebase-merges -s resolve A
-'
-
-test_expect_success '--rebase-merges incompatible with --strategy-option' '
-	git checkout B^0 &&
-	test_must_fail git rebase --rebase-merges -Xignore-space-change A
-'
-
 test_done
diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
index 42ba5b9f09..8ea6ff3548 100755
--- a/t/t3430-rebase-merges.sh
+++ b/t/t3430-rebase-merges.sh
@@ -412,4 +412,25 @@ test_expect_success '--continue after resolving conflicts after a merge' '
 	test_path_is_missing .git/MERGE_HEAD
 '
 
+test_expect_success '--rebase-merges with strategies' '
+	git checkout -b with-a-strategy F &&
+	test_tick &&
+	git merge -m "Merge conflicting-G" conflicting-G &&
+
+	: first, test with a merge strategy option &&
+	git rebase -ir -Xtheirs G &&
+	echo conflicting-G >expect &&
+	test_cmp expect G.t &&
+
+	: now, try with a merge strategy other than recursive &&
+	git reset --hard @{1} &&
+	write_script git-merge-override <<-\EOF &&
+	echo overridden$1 >>G.t
+	git add G.t
+	EOF
+	PATH="$PWD:$PATH" git rebase -ir -s override -Xxopt G &&
+	test_write_lines G overridden--xopt >expect &&
+	test_cmp expect G.t
+'
+
 test_done
-- 
gitgitgadget


  parent reply	other threads:[~2019-07-25 10:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 10:11 [PATCH 00/12] rebase -r: support merge strategies other than recursive Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 01/12] t3427: add a clarifying comment Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 02/12] t3427: simplify the `setup` test case significantly Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 03/12] t3427: move the `filter-branch` invocation into the `setup` case Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 04/12] t3427: condense the unnecessarily repetitive test cases into three Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 05/12] t3427: fix erroneous assumption Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 06/12] t3427: accommodate for the `rebase --merge` backend having been replaced Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 08/12] t3427: mark two test cases as requiring support for `git rebase -p` Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 07/12] t3427: fix another incorrect assumption Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` Johannes Schindelin via GitGitGadget [this message]
2019-07-25 10:11 ` [PATCH 10/12] t/lib-rebase: prepare for testing `git rebase --rebase-merges` Johannes Schindelin via GitGitGadget
2019-07-26  7:43   ` brian m. carlson
2019-07-26 14:01     ` Johannes Schindelin
2019-07-26 21:08       ` brian m. carlson
2019-07-31 11:25         ` Johannes Schindelin
2019-07-25 10:11 ` [PATCH 12/12] rebase -r: do not (re-)generate root commits with `--root` *and* `--onto` Johannes Schindelin via GitGitGadget
2019-07-25 10:11 ` [PATCH 11/12] t3418: test `rebase -r` with merge strategies Johannes Schindelin via GitGitGadget
2019-07-25 17:10 ` [PATCH 00/12] rebase -r: support merge strategies other than recursive Junio C Hamano
2019-07-26  7:52 ` brian m. carlson
2019-07-31 15:18 ` [PATCH v2 00/16] " Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 01/16] Drop unused git-rebase--am.sh Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 02/16] t3400: stop referring to the scripted rebase Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 03/16] .gitignore: there is no longer a built-in `git-rebase--interactive` Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 04/16] sequencer: the `am` and `rebase--interactive` scripts are gone Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 05/16] rebase: fold git-rebase--common into the -p backend Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 06/16] t3427: add a clarifying comment Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 07/16] t3427: simplify the `setup` test case significantly Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 08/16] t3427: move the `filter-branch` invocation into the `setup` case Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 09/16] t3427: condense the unnecessarily repetitive test cases into three Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 11/16] t3427: accommodate for the `rebase --merge` backend having been replaced Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 10/16] t3427: fix erroneous assumption Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 12/16] t3427: fix another incorrect assumption Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 13/16] rebase -r: support merge strategies other than `recursive` Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 14/16] t/lib-rebase: prepare for testing `git rebase --rebase-merges` Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 15/16] t3418: test `rebase -r` with merge strategies Johannes Schindelin via GitGitGadget
2019-07-31 15:18   ` [PATCH v2 16/16] rebase -r: do not (re-)generate root commits with `--root` *and* `--onto` Johannes Schindelin via GitGitGadget
2019-09-04 21:40   ` [PATCH v2 17/16] t3427: accelerate this test by using fast-export and fast-import Elijah Newren
2019-09-09 20:29     ` Johannes Schindelin
2019-09-09 21:06       ` 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=30405df99ff38466987e64c1dea007ff6fb9b8c8.1564049474.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /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).