Skip to contentSkip to conversation

branch, config: teach branch.autosetuprebase about 'merges' mode

PATCH New Alex Reed via GitGitGadget 1 participant 1 message Jan 20, 2021 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 branch, config: teach branch.autosetuprebase about 'merges' mode

From: Alex Reed <[email protected]>

branch.autoSetupRebase now honors the 'merges' flag, allowing tracking branches to be auto-populated with 'branch.<name>.rebase = merges'. This allows complex workflows to more easily retain non-trivial merges while rebasing branches on pull operations. Seeding new branches with 'branch.<name>.rebase = true' is not always sufficient (read: not project default) and requiring developers to manually reconfigure every new branch is cumbersome and error-prone.

---
branch, config: teach branch.autosetuprebase about 'merges' mode

branch.autoSetupRebase now honors the 'merges' flag, allowing tracking branches to be auto-populated with 'branch..rebase = merges'. This allows complex workflows to more easily retain non-trivial merges while rebasing branches on pull operations. Seeding new branches with 'branch..rebase = true' is not always sufficient (read: not project default) and requiring developers to manually reconfigure every new branch is cumbersome and error-prone.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-948%2Facr4%2Fautosetuprebase-merges-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-948/acr4/autosetuprebase-merges-v1
Pull-Request: https://github.com/git/git/pull/948

 Documentation/config/branch.txt |  2 +
 branch.c                        | 70 ++++++++++++++++++++-------------
 cache.h                         |  3 +-
 config.c                        |  2 +
 t/t3200-branch.sh               | 45 +++++++++++++++++++++
 t/t5601-clone.sh                | 14 ++++++-
 6 files changed, 107 insertions(+), 29 deletions(-)
Documentation/config/branch.txt +2 -0
index cc5f3249fc5..98410bf003f 100644
@@ -21,6 +21,8 @@ branch.autoSetupRebase::
 	remote-tracking branches.
 	When `always`, rebase will be set to true for all tracking
 	branches.
+	When `merges`, rebase will be set to `merges` for all tracking
+	branches.
 	See "branch.autoSetupMerge" for details on how to set up a
 	branch to track another branch.
 	This option defaults to never.
branch.c +43 -27

111 lines not on this page · raw message

cache.h +2 -1
index eefa93b08f8..5a378bcd534 100644
@@ -995,7 +995,8 @@ enum rebase_setup_type {
 	AUTOREBASE_NEVER = 0,
 	AUTOREBASE_LOCAL,
 	AUTOREBASE_REMOTE,
-	AUTOREBASE_ALWAYS
+	AUTOREBASE_ALWAYS,
+	AUTOREBASE_MERGES
 };
 
 enum push_default_type {
config.c +2 -0
index 4c0cf3a1c15..28d813f2595 100644
@@ -1443,6 +1443,8 @@ static int git_default_branch_config(const char *var, const char *value)
 			autorebase = AUTOREBASE_REMOTE;
 		else if (!strcmp(value, "always"))
 			autorebase = AUTOREBASE_ALWAYS;
+		else if (!strcmp(value, "merges"))
+			autorebase = AUTOREBASE_MERGES;
 		else
 			return error(_("malformed value for %s"), var);
 		return 0;
t/t3200-branch.sh +45 -0

51 lines not on this page · raw message

t/t5601-clone.sh +13 -1
index 7df3c5373ae..10983191439 100755
@@ -210,7 +210,7 @@ test_expect_success 'clone a void' '
 	test_cmp target-6/.git/config target-7/.git/config
 '
 
-test_expect_success 'clone respects global branch.autosetuprebase' '
+test_expect_success 'clone respects global branch.autosetuprebase remote' '
 	(
 		test_config="$HOME/.gitconfig" &&
 		git config -f "$test_config" branch.autosetuprebase remote &&
@@ -222,6 +222,18 @@ test_expect_success 'clone respects global branch.autosetuprebase' '
 	)
 '
 
+test_expect_success 'clone respects global branch.autosetuprebase merges' '
+	(
+		test_config="$HOME/.gitconfig" &&
+		git config -f "$test_config" branch.autosetuprebase merges &&
+		rm -fr dst &&
+		git clone src dst &&
+		cd dst &&
+		actual="z$(git config branch.master.rebase)" &&
+		test zmerges = $actual
+	)
+'
+
 test_expect_success 'respect url-encoding of file://' '
 	git init x+y &&
 	git clone "file://$PWD/x+y" xy-url-1 &&

base-commit: 66e871b6647ffea61a77a0f82c7ef3415f1ee79c

Signature · 1 line
gitgitgadget