From: Paolo Bonzini <bonzini@gnu.org>
To: <git@vger.kernel.org>
Subject: [PATCH 1/6] config: allow false and true values for branch.autosetuprebase
Date: Sun, 12 Jul 2009 14:17:28 +0200 [thread overview]
Message-ID: <1247401053-20429-2-git-send-email-bonzini@gnu.org> (raw)
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
next prev parent reply other threads:[~2009-07-12 12:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-12 12:17 [PATCH 0/6] Tracking setup improvements: per-remote config, autosetuppush Paolo Bonzini
2009-07-12 12:17 ` Paolo Bonzini [this message]
2009-07-12 12:17 ` [PATCH 2/6] branch: install_branch_config and struct tracking refactoring Paolo Bonzini
2009-07-12 12:17 ` [PATCH 3/6] introduce a struct tracking_config Paolo Bonzini
2009-07-12 12:17 ` [PATCH 4/6] remote: add per-remote autosetupmerge and autosetuprebase configuration Paolo Bonzini
2009-07-12 12:17 ` [PATCH 5/6] move deletion of merge configuration to branch.c Paolo Bonzini
2009-07-12 12:17 ` [PATCH 6/6] branch, checkout: introduce autosetuppush Paolo Bonzini
2009-07-12 21:17 ` [PATCH 0/6] Tracking setup improvements: per-remote config, autosetuppush 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1247401053-20429-2-git-send-email-bonzini@gnu.org \
--to=bonzini@gnu.org \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).