{"thread":{"id":"18116","subject":"[PATCH] Make git-clone respect branch.autosetuprebase","startedAt":"2009-03-03T18:35:52Z","lastAt":"2009-03-03T18:48:19Z","messageCount":2,"participants":["pknotz@sandia.gov","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"106907","messageId":"1236105352-21335-1-git-send-email-pknotz@sandia.gov","threadId":"18116","inReplyTo":null,"subject":"[PATCH] Make git-clone respect branch.autosetuprebase","fromName":"","fromEmail":"pknotz@sandia.gov","sentAt":"2009-03-03T18:35:52Z","receivedAt":"2009-03-03T18:35:52Z","isPatch":true,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"From: Pat Notz <pknotz@sandia.gov>\n\nWhen git-clone creates an initial branch it was not\nchecking the branch.autosetuprebase configuration\noption (which may exist in ~/.gitconfig).\n\nSigned-off-by: Pat Notz <pknotz@sandia.gov>\n---\n builtin-clone.c  |    8 ++++++++\n t/t5601-clone.sh |   14 ++++++++++++++\n 2 files changed, 22 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex c338910..f547267 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -360,6 +360,14 @@ static void install_branch_config(const char *local,\n \tstrbuf_reset(&key);\n \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n \tgit_config_set(key.buf, remote);\n+\tswitch (autorebase) {\n+\tcase AUTOREBASE_REMOTE:\n+\tcase AUTOREBASE_ALWAYS:\n+\t\tstrbuf_reset(&key);\n+\t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n+\t\tgit_config_set(key.buf, \"true\");\n+\t\tprintf(\"Default branch '%s' will rebase on pull.\\n\", local);\n+\t}\n \tstrbuf_release(&key);\n }\n \ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 44793f2..0f8b43c 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -159,4 +159,18 @@ test_expect_success 'clone a void' '\n \ttest_cmp target-6/.git/config target-7/.git/config\n '\n \n+test_expect_success 'clone respects global branch.autosetuprebase' '\n+\tHOME=\"`pwd`\" &&\n+\texport HOME &&\n+\ttest_config=\"$HOME\"/.gitconfig &&\n+\tunset GIT_CONFIG_NOGLOBAL &&\n+\tgit config -f \"$test_config\" branch.autosetuprebase remote &&\n+\trm -fr dst &&\n+\tgit clone src dst &&\n+\tcd dst &&\n+\texpected=\"ztrue\" &&\n+\tactual=\"z$(git config branch.master.rebase)\" &&\n+\ttest $expected = $actual\n+'\n+\n test_done\n-- \n1.6.1.2\n"},{"id":"106909","messageId":"7v4oyabfyk.fsf@gitster.siamese.dyndns.org","threadId":"18116","inReplyTo":"1236105352-21335-1-git-send-email-pknotz@sandia.gov","subject":"Re: [PATCH] Make git-clone respect branch.autosetuprebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-03T18:48:19Z","receivedAt":"2009-03-03T18:48:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"pknotz@sandia.gov writes:\n\n> diff --git a/builtin-clone.c b/builtin-clone.c\n> index c338910..f547267 100644\n> --- a/builtin-clone.c\n> +++ b/builtin-clone.c\n> @@ -360,6 +360,14 @@ static void install_branch_config(const char *local,\n>  \tstrbuf_reset(&key);\n>  \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n>  \tgit_config_set(key.buf, remote);\n> +\tswitch (autorebase) {\n> +\tcase AUTOREBASE_REMOTE:\n> +\tcase AUTOREBASE_ALWAYS:\n> +\t\tstrbuf_reset(&key);\n> +\t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n> +\t\tgit_config_set(key.buf, \"true\");\n> +\t\tprintf(\"Default branch '%s' will rebase on pull.\\n\", local);\n> +\t}\n>  \tstrbuf_release(&key);\n>  }\n\nI think this whole function should be moved to to branch.c to be usable\nacross \"git checkout -b\", \"git branch\" and \"git clone\", and make the two\nexisting callers in builtin-clone.c and setup_tracking() in branch.c call\nit.  \"git checkout -b\" already shares the same codepath with \"git branch\",\nand you would allow \"git clone\" to be in the family.  That would help\nsupporting new tracking options without having to maintain more than one\ncopy of the code.\n"}]}