Thread (7 messages) flat view 7 messages, 1 author, 2016-06-15
DORMANTno replies

[PATCH 1/6] config: allow false and true values for branch.autosetuprebase

From: Paolo Bonzini <hidden>
Date: 2016-06-15 22:47:03
Subsystem: documentation, the rest · Maintainers: Jonathan Corbet, Linus Torvalds

Boolean values can be clearly DWIM'ed from false to never and
from true to always.  This is nicer to the user because autosetupmerge
allows boolean values.

Signed-off-by: Paolo Bonzini <redacted>
---
 Documentation/config.txt |    4 ++--
 config.c                 |   12 ++++++------
 t/t3200-branch.sh        |   15 ++++++++++++---
 3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index cb6832b..1e37e33 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -479,12 +479,12 @@ branch.autosetuprebase::
 	When a new branch is created with 'git-branch' or 'git-checkout'
 	that tracks another branch, this variable tells git to set
 	up pull to rebase instead of merge (see "branch.<name>.rebase").
-	When `never`, rebase is never automatically set to true.
+	When `never` or `false`, rebase is never automatically set to true.
 	When `local`, rebase is set to true for tracked branches of
 	other local branches.
 	When `remote`, rebase is set to true for tracked branches of
 	remote branches.
-	When `always`, rebase will be set to true for all tracking
+	When `always` or `true`, rebase will be set to true for all tracking
 	branches.
 	See "branch.autosetupmerge" for details on how to set up a
 	branch to track another branch.
diff --git a/config.c b/config.c
index 1682273..b47a40e 100644
--- a/config.c
+++ b/config.c
@@ -557,17 +557,17 @@ static int git_default_branch_config(const char *var, const char *value)
 	}
 	if (!strcmp(var, "branch.autosetuprebase")) {
 		if (!value)
-			return config_error_nonbool(var);
-		else if (!strcmp(value, "never"))
-			autorebase = AUTOREBASE_NEVER;
+			value = "always";
+		autorebase = AUTOREBASE_NEVER;
+		if (!strcmp(value, "never"))
+			;
 		else if (!strcmp(value, "local"))
 			autorebase = AUTOREBASE_LOCAL;
 		else if (!strcmp(value, "remote"))
 			autorebase = AUTOREBASE_REMOTE;
-		else if (!strcmp(value, "always"))
+		else if (!strcmp(value, "always") ||
+			 git_config_bool (var, value))
 			autorebase = AUTOREBASE_ALWAYS;
-		else
-			return error("Malformed value for %s", var);
 		return 0;
 	}
 
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index d59a9b4..b14a3a9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -461,11 +461,20 @@ test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
 	test_must_fail git branch
 '
 
-test_expect_success 'detect misconfigured autosetuprebase (no value)' '
+test_expect_success 'boolean value (no value) for autosetuprebase' '
 	git config --unset branch.autosetuprebase &&
 	echo "[branch] autosetuprebase" >> .git/config &&
-	test_must_fail git branch &&
-	git config --unset branch.autosetuprebase
+	git config remote.local.url . &&
+	git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+	(git show-ref -q refs/remotes/local/master || git fetch local) &&
+	git branch --track myr21 local/master &&
+	git branch --track myr22 myr21 &&
+	test "$(git config branch.myr21.remote)" = local &&
+	test "$(git config branch.myr21.merge)" = refs/heads/master &&
+	test "z$(git config branch.myr21.rebase)" = ztrue &&
+	test "$(git config branch.myr22.remote)" = . &&
+	test "$(git config branch.myr22.merge)" = refs/heads/myr21 &&
+	test "z$(git config branch.myr22.rebase)" = ztrue
 '
 
 test_done
-- 
1.6.2.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help