* [PATCH] Make git-clone respect branch.autosetuprebase
@ 2009-03-03 18:35 pknotz
2009-03-03 18:48 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: pknotz @ 2009-03-03 18:35 UTC (permalink / raw)
To: git; +Cc: Pat Notz
From: Pat Notz <pknotz@sandia.gov>
When git-clone creates an initial branch it was not
checking the branch.autosetuprebase configuration
option (which may exist in ~/.gitconfig).
Signed-off-by: Pat Notz <pknotz@sandia.gov>
---
builtin-clone.c | 8 ++++++++
t/t5601-clone.sh | 14 ++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index c338910..f547267 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -360,6 +360,14 @@ static void install_branch_config(const char *local,
strbuf_reset(&key);
strbuf_addf(&key, "branch.%s.merge", local);
git_config_set(key.buf, remote);
+ switch (autorebase) {
+ case AUTOREBASE_REMOTE:
+ case AUTOREBASE_ALWAYS:
+ strbuf_reset(&key);
+ strbuf_addf(&key, "branch.%s.rebase", local);
+ git_config_set(key.buf, "true");
+ printf("Default branch '%s' will rebase on pull.\n", local);
+ }
strbuf_release(&key);
}
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 44793f2..0f8b43c 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -159,4 +159,18 @@ test_expect_success 'clone a void' '
test_cmp target-6/.git/config target-7/.git/config
'
+test_expect_success 'clone respects global branch.autosetuprebase' '
+ HOME="`pwd`" &&
+ export HOME &&
+ test_config="$HOME"/.gitconfig &&
+ unset GIT_CONFIG_NOGLOBAL &&
+ git config -f "$test_config" branch.autosetuprebase remote &&
+ rm -fr dst &&
+ git clone src dst &&
+ cd dst &&
+ expected="ztrue" &&
+ actual="z$(git config branch.master.rebase)" &&
+ test $expected = $actual
+'
+
test_done
--
1.6.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Make git-clone respect branch.autosetuprebase
2009-03-03 18:35 [PATCH] Make git-clone respect branch.autosetuprebase pknotz
@ 2009-03-03 18:48 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2009-03-03 18:48 UTC (permalink / raw)
To: pknotz; +Cc: git
pknotz@sandia.gov writes:
> diff --git a/builtin-clone.c b/builtin-clone.c
> index c338910..f547267 100644
> --- a/builtin-clone.c
> +++ b/builtin-clone.c
> @@ -360,6 +360,14 @@ static void install_branch_config(const char *local,
> strbuf_reset(&key);
> strbuf_addf(&key, "branch.%s.merge", local);
> git_config_set(key.buf, remote);
> + switch (autorebase) {
> + case AUTOREBASE_REMOTE:
> + case AUTOREBASE_ALWAYS:
> + strbuf_reset(&key);
> + strbuf_addf(&key, "branch.%s.rebase", local);
> + git_config_set(key.buf, "true");
> + printf("Default branch '%s' will rebase on pull.\n", local);
> + }
> strbuf_release(&key);
> }
I think this whole function should be moved to to branch.c to be usable
across "git checkout -b", "git branch" and "git clone", and make the two
existing callers in builtin-clone.c and setup_tracking() in branch.c call
it. "git checkout -b" already shares the same codepath with "git branch",
and you would allow "git clone" to be in the family. That would help
supporting new tracking options without having to maintain more than one
copy of the code.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-03 18:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03 18:35 [PATCH] Make git-clone respect branch.autosetuprebase pknotz
2009-03-03 18:48 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox