git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Paolo Bonzini <bonzini@gnu.org>
Date
Jul 12, 2009, 12:17 UTC
Message-ID
<1247401053-20429-2-git-send-email-bonzini@gnu.org>
In-Reply-To
<1247401053-20429-1-git-send-email-bonzini@gnu.org>

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 <bonzini@gnu.org>
---
 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
Previous: Paolo BonziniNext: Paolo Bonzini
Message 2 of 8 in “Tracking setup improvements: per-remote config, autosetuppush”
  1. 0/6 Tracking setup improvements: per-remote config, autosetuppushPaolo Bonzini, Jul 12, 2009
  2. 1/6 config: allow false and true values for branch.autosetuprebasePaolo Bonzini, Jul 12, 2009
  3. 2/6 branch: install_branch_config and struct tracking refactoringPaolo Bonzini, Jul 12, 2009
  4. 3/6 introduce a struct tracking_configPaolo Bonzini, Jul 12, 2009
  5. 4/6 remote: add per-remote autosetupmerge and autosetuprebase configurationPaolo Bonzini, Jul 12, 2009
  6. 5/6 move deletion of merge configuration to branch.cPaolo Bonzini, Jul 12, 2009
  7. 6/6 branch, checkout: introduce autosetuppushPaolo Bonzini, Jul 12, 2009
  8. Junio C HamanoJul 12, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.