{"thread":{"id":"18246","subject":"Re: [PATCHv6] Make git-clone respect branch.autosetuprebase","startedAt":"2009-03-10T03:26:50Z","lastAt":"2009-03-10T08:20:42Z","messageCount":4,"participants":["Junio C Hamano","Pat Notz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"299093","messageId":"1236655610-14236-1-git-send-email-pknotz@sandia.gov","threadId":"18246","inReplyTo":"1cd1989b0903060621w60124401s9986507e356783b1@mail.gmail.com","subject":"[PATCHv5] Make git-clone respect branch.autosetuprebase","fromName":"Pat Notz","fromEmail":"pknotz@sandia.gov","sentAt":"2009-03-10T03:26:50Z","receivedAt":"2009-03-10T03:26:50Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nWhen git-clone creates an initial branch it was not checking the\nbranch.autosetuprebase configuration option (which may exist in\n~/.gitconfig).  Refactor the code used by \"git branch\" to create\na new branch, and use it instead of the insufficiently duplicated code\nin builtin-clone.\n\nMinor modification of the patch from Junio Hamano.\n---\n\nThis version fixes the verbose output to be more human friendly.  Before,\nthe branch being tracked was printed as 'refs/heads/frotz' regardless of\nwether that was a local or remote branch.  Now, a local branch is just\nprinted as 'frotz' and a remote branch is printed as 'origin/frotz'\n\n branch.c         |   49 +++++++++++++++++++++++++++++++++----------------\n branch.h         |    7 +++++++\n builtin-clone.c  |   18 +++---------------\n t/t5601-clone.sh |   15 +++++++++++++++\n 4 files changed, 58 insertions(+), 31 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 1f00e44..d20fb04 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -32,21 +32,48 @@ static int find_tracked_branch(struct remote *remote, void *priv)\n \treturn 0;\n }\n \n-static int should_setup_rebase(const struct tracking *tracking)\n+static int should_setup_rebase(const char *origin)\n {\n \tswitch (autorebase) {\n \tcase AUTOREBASE_NEVER:\n \t\treturn 0;\n \tcase AUTOREBASE_LOCAL:\n-\t\treturn tracking->remote == NULL;\n+\t\treturn origin == NULL;\n \tcase AUTOREBASE_REMOTE:\n-\t\treturn tracking->remote != NULL;\n+\t\treturn origin != NULL;\n \tcase AUTOREBASE_ALWAYS:\n \t\treturn 1;\n \t}\n \treturn 0;\n }\n \n+void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n+{\n+\tstruct strbuf key = STRBUF_INIT;\n+\tint rebasing = should_setup_rebase(origin);\n+\n+\tstrbuf_addf(&key, \"branch.%s.remote\", local);\n+\tgit_config_set(key.buf, origin ? origin : \".\");\n+\n+\tstrbuf_reset(&key);\n+\tstrbuf_addf(&key, \"branch.%s.merge\", local);\n+\tgit_config_set(key.buf, remote);\n+\n+\tif (rebasing) {\n+\t\tstrbuf_reset(&key);\n+\t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n+\t\tgit_config_set(key.buf, \"true\");\n+\t}\n+\n+\tif (flag & BRANCH_CONFIG_VERBOSE)\n+\t\tprintf(\"Branch %s set up to track %s branch %s %s.\\n\",\n+\t\t       local,\n+\t\t       origin ? \"remote\" : \"local\",\n+\t\t       remote,\n+\t\t       rebasing ? \"by rebasing\" : \"by merging\");\n+\tstrbuf_release(&key);\n+}\n+\n /*\n  * This is called when new_ref is branched off of orig_ref, and tries\n  * to infer the settings for branch.<new_ref>.{remote,merge} from the\n@@ -55,7 +82,6 @@ static int should_setup_rebase(const struct tracking *tracking)\n static int setup_tracking(const char *new_ref, const char *orig_ref,\n                           enum branch_track track)\n {\n-\tchar key[1024];\n \tstruct tracking tracking;\n \n \tif (strlen(new_ref) > 1024 - 7 - 7 - 1)\n@@ -80,19 +106,10 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,\n \t\treturn error(\"Not tracking: ambiguous information for ref %s\",\n \t\t\t\torig_ref);\n \n-\tsprintf(key, \"branch.%s.remote\", new_ref);\n-\tgit_config_set(key, tracking.remote ?  tracking.remote : \".\");\n-\tsprintf(key, \"branch.%s.merge\", new_ref);\n-\tgit_config_set(key, tracking.src ? tracking.src : orig_ref);\n-\tprintf(\"Branch %s set up to track %s branch %s.\\n\", new_ref,\n-\t\ttracking.remote ? \"remote\" : \"local\", orig_ref);\n-\tif (should_setup_rebase(&tracking)) {\n-\t\tsprintf(key, \"branch.%s.rebase\", new_ref);\n-\t\tgit_config_set(key, \"true\");\n-\t\tprintf(\"This branch will rebase on pull.\\n\");\n-\t}\n-\tfree(tracking.src);\n+\tinstall_branch_config(BRANCH_CONFIG_VERBOSE, new_ref, tracking.remote,\n+\t\t\t      tracking.src ? tracking.src : orig_ref);\n \n+\tfree(tracking.src);\n \treturn 0;\n }\n \ndiff --git a/branch.h b/branch.h\nindex 9f0c2a2..eed817a 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -21,4 +21,11 @@ void create_branch(const char *head, const char *name, const char *start_name,\n  */\n void remove_branch_state(void);\n \n+/*\n+ * Configure local branch \"local\" to merge remote branch \"remote\"\n+ * taken from origin \"origin\".\n+ */\n+#define BRANCH_CONFIG_VERBOSE 01\n+extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n+\n #endif\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex 92826cd..687df9a 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -20,6 +20,7 @@\n #include \"dir.h\"\n #include \"pack-refs.h\"\n #include \"sigchain.h\"\n+#include \"branch.h\"\n \n /*\n  * Overall FIXMEs:\n@@ -350,19 +351,6 @@ static struct ref *write_remote_refs(const struct ref *refs,\n \treturn local_refs;\n }\n \n-static void install_branch_config(const char *local,\n-\t\t\t\t  const char *origin,\n-\t\t\t\t  const char *remote)\n-{\n-\tstruct strbuf key = STRBUF_INIT;\n-\tstrbuf_addf(&key, \"branch.%s.remote\", local);\n-\tgit_config_set(key.buf, origin);\n-\tstrbuf_reset(&key);\n-\tstrbuf_addf(&key, \"branch.%s.merge\", local);\n-\tgit_config_set(key.buf, remote);\n-\tstrbuf_release(&key);\n-}\n-\n int cmd_clone(int argc, const char **argv, const char *prefix)\n {\n \tint is_bundle = 0;\n@@ -547,7 +535,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\tremote_head = NULL;\n \t\toption_no_checkout = 1;\n \t\tif (!option_bare)\n-\t\t\tinstall_branch_config(\"master\", option_origin,\n+\t\t\tinstall_branch_config(0, \"master\", option_origin,\n \t\t\t\t\t      \"refs/heads/master\");\n \t}\n \n@@ -577,7 +565,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t\t\t      head_points_at->peer_ref->name,\n \t\t\t\t      reflog_msg.buf);\n \n-\t\t\tinstall_branch_config(head, option_origin,\n+\t\t\tinstall_branch_config(0, head, option_origin,\n \t\t\t\t\t      head_points_at->name);\n \t\t}\n \t} else if (remote_head) {\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 44793f2..2335d8b 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -159,4 +159,19 @@ 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+\t(\n+\t\tHOME=$(pwd) &&\n+\t\texport HOME &&\n+\t\ttest_config=\"$HOME/.gitconfig\" &&\n+\t\tunset GIT_CONFIG_NOGLOBAL &&\n+\t\tgit config -f \"$test_config\" branch.autosetuprebase remote &&\n+\t\trm -fr dst &&\n+\t\tgit clone src dst &&\n+\t\tcd dst &&\n+\t\tactual=\"z$(git config branch.master.rebase)\" &&\n+\t\ttest ztrue = $actual\n+\t)\n+'\n+\n test_done\n-- \n1.6.2\n\n\n"},{"id":"299094","messageId":"1236659098-14400-1-git-send-email-pknotz@sandia.gov","threadId":"18246","inReplyTo":"1236655610-14236-1-git-send-email-pknotz@sandia.gov","subject":"[PATCHv6] Make git-clone respect branch.autosetuprebase","fromName":"Pat Notz","fromEmail":"pknotz@sandia.gov","sentAt":"2009-03-10T04:24:58Z","receivedAt":"2009-03-10T04:24:58Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nWhen git-clone creates an initial branch it was not checking the\nbranch.autosetuprebase configuration option (which may exist in\n~/.gitconfig).  Refactor the code used by \"git branch\" to create\na new branch, and use it instead of the insufficiently duplicated code\nin builtin-clone.\n\nMinor modification of the patch from Junio Hamano.\n---\n\nUgh.  Another resend... I need to stop working at night.\n\nThis version fixes the verbose output to be more human friendly.  Before,\nthe branch being tracked was printed as 'refs/heads/frotz' regardless of\nwether that was a local or remote branch.  Now, a local branch is just\nprinted as 'frotz' and a remote branch is printed as 'origin/frotz'\n\n branch.c         |   55 ++++++++++++++++++++++++++++++++++++++---------------\n branch.h         |    7 ++++++\n builtin-clone.c  |   18 ++--------------\n t/t5601-clone.sh |   15 ++++++++++++++\n 4 files changed, 64 insertions(+), 31 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 1f00e44..eecda64 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -32,21 +32,54 @@ static int find_tracked_branch(struct remote *remote, void *priv)\n \treturn 0;\n }\n \n-static int should_setup_rebase(const struct tracking *tracking)\n+static int should_setup_rebase(const char *origin)\n {\n \tswitch (autorebase) {\n \tcase AUTOREBASE_NEVER:\n \t\treturn 0;\n \tcase AUTOREBASE_LOCAL:\n-\t\treturn tracking->remote == NULL;\n+\t\treturn origin == NULL;\n \tcase AUTOREBASE_REMOTE:\n-\t\treturn tracking->remote != NULL;\n+\t\treturn origin != NULL;\n \tcase AUTOREBASE_ALWAYS:\n \t\treturn 1;\n \t}\n \treturn 0;\n }\n \n+void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n+{\n+\tstruct strbuf key = STRBUF_INIT;\n+\tint rebasing = should_setup_rebase(origin);\n+\n+\tstrbuf_addf(&key, \"branch.%s.remote\", local);\n+\tgit_config_set(key.buf, origin ? origin : \".\");\n+\n+\tstrbuf_reset(&key);\n+\tstrbuf_addf(&key, \"branch.%s.merge\", local);\n+\tgit_config_set(key.buf, remote);\n+\n+\tif (rebasing) {\n+\t\tstrbuf_reset(&key);\n+\t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n+\t\tgit_config_set(key.buf, \"true\");\n+\t}\n+\n+\tif (flag & BRANCH_CONFIG_VERBOSE){\n+\t\tstrbuf_reset(&key);\n+\t\tif(origin)\n+\t\t\tstrbuf_addf(&key, \"%s/%s\", origin, remote+11);\n+\t\telse\n+\t\t\tstrbuf_addf(&key, \"%s\", remote+11);\n+\t\tprintf(\"Branch %s set up to track %s branch %s %s.\\n\",\n+\t\t       local,\n+\t\t       origin ? \"remote\" : \"local\",\n+\t\t       key.buf,\n+\t\t       rebasing ? \"by rebasing\" : \"by merging\");\n+\t}\n+\tstrbuf_release(&key);\n+}\n+\n /*\n  * This is called when new_ref is branched off of orig_ref, and tries\n  * to infer the settings for branch.<new_ref>.{remote,merge} from the\n@@ -55,7 +88,6 @@ static int should_setup_rebase(const struct tracking *tracking)\n static int setup_tracking(const char *new_ref, const char *orig_ref,\n                           enum branch_track track)\n {\n-\tchar key[1024];\n \tstruct tracking tracking;\n \n \tif (strlen(new_ref) > 1024 - 7 - 7 - 1)\n@@ -80,19 +112,10 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,\n \t\treturn error(\"Not tracking: ambiguous information for ref %s\",\n \t\t\t\torig_ref);\n \n-\tsprintf(key, \"branch.%s.remote\", new_ref);\n-\tgit_config_set(key, tracking.remote ?  tracking.remote : \".\");\n-\tsprintf(key, \"branch.%s.merge\", new_ref);\n-\tgit_config_set(key, tracking.src ? tracking.src : orig_ref);\n-\tprintf(\"Branch %s set up to track %s branch %s.\\n\", new_ref,\n-\t\ttracking.remote ? \"remote\" : \"local\", orig_ref);\n-\tif (should_setup_rebase(&tracking)) {\n-\t\tsprintf(key, \"branch.%s.rebase\", new_ref);\n-\t\tgit_config_set(key, \"true\");\n-\t\tprintf(\"This branch will rebase on pull.\\n\");\n-\t}\n-\tfree(tracking.src);\n+\tinstall_branch_config(BRANCH_CONFIG_VERBOSE, new_ref, tracking.remote,\n+\t\t\t      tracking.src ? tracking.src : orig_ref);\n \n+\tfree(tracking.src);\n \treturn 0;\n }\n \ndiff --git a/branch.h b/branch.h\nindex 9f0c2a2..eed817a 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -21,4 +21,11 @@ void create_branch(const char *head, const char *name, const char *start_name,\n  */\n void remove_branch_state(void);\n \n+/*\n+ * Configure local branch \"local\" to merge remote branch \"remote\"\n+ * taken from origin \"origin\".\n+ */\n+#define BRANCH_CONFIG_VERBOSE 01\n+extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n+\n #endif\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex 92826cd..687df9a 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -20,6 +20,7 @@\n #include \"dir.h\"\n #include \"pack-refs.h\"\n #include \"sigchain.h\"\n+#include \"branch.h\"\n \n /*\n  * Overall FIXMEs:\n@@ -350,19 +351,6 @@ static struct ref *write_remote_refs(const struct ref *refs,\n \treturn local_refs;\n }\n \n-static void install_branch_config(const char *local,\n-\t\t\t\t  const char *origin,\n-\t\t\t\t  const char *remote)\n-{\n-\tstruct strbuf key = STRBUF_INIT;\n-\tstrbuf_addf(&key, \"branch.%s.remote\", local);\n-\tgit_config_set(key.buf, origin);\n-\tstrbuf_reset(&key);\n-\tstrbuf_addf(&key, \"branch.%s.merge\", local);\n-\tgit_config_set(key.buf, remote);\n-\tstrbuf_release(&key);\n-}\n-\n int cmd_clone(int argc, const char **argv, const char *prefix)\n {\n \tint is_bundle = 0;\n@@ -547,7 +535,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\tremote_head = NULL;\n \t\toption_no_checkout = 1;\n \t\tif (!option_bare)\n-\t\t\tinstall_branch_config(\"master\", option_origin,\n+\t\t\tinstall_branch_config(0, \"master\", option_origin,\n \t\t\t\t\t      \"refs/heads/master\");\n \t}\n \n@@ -577,7 +565,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t\t\t      head_points_at->peer_ref->name,\n \t\t\t\t      reflog_msg.buf);\n \n-\t\t\tinstall_branch_config(head, option_origin,\n+\t\t\tinstall_branch_config(0, head, option_origin,\n \t\t\t\t\t      head_points_at->name);\n \t\t}\n \t} else if (remote_head) {\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 44793f2..2335d8b 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -159,4 +159,19 @@ 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+\t(\n+\t\tHOME=$(pwd) &&\n+\t\texport HOME &&\n+\t\ttest_config=\"$HOME/.gitconfig\" &&\n+\t\tunset GIT_CONFIG_NOGLOBAL &&\n+\t\tgit config -f \"$test_config\" branch.autosetuprebase remote &&\n+\t\trm -fr dst &&\n+\t\tgit clone src dst &&\n+\t\tcd dst &&\n+\t\tactual=\"z$(git config branch.master.rebase)\" &&\n+\t\ttest ztrue = $actual\n+\t)\n+'\n+\n test_done\n-- \n1.6.2\n\n\n"},{"id":"107552","messageId":"7vab7tbxo0.fsf@gitster.siamese.dyndns.org","threadId":"18246","inReplyTo":"1236659098-14400-1-git-send-email-pknotz@sandia.gov","subject":"Re: [PATCHv6] Make git-clone respect branch.autosetuprebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-10T08:16:15Z","receivedAt":"2009-03-10T08:16:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Pat Notz\" <pknotz@sandia.gov> writes:\n\n> This version fixes the verbose output to be more human friendly.  Before,\n> the branch being tracked was printed as 'refs/heads/frotz' regardless of\n> wether that was a local or remote branch.  Now, a local branch is just\n> printed as 'frotz' and a remote branch is printed as 'origin/frotz'\n\nSince I've already queued the previous round in 'next', I took the liberty\nof making this into an incremental.\n\nI do not think what you did is really correct.  For clone, because we do\nnot create anything but the default \"refs/remotes/<origin>/<branch>\"\nlayout, always stripping out the first 11 bytes \"refs/heads/\" happens to\ngive a more intuitive result.  But the helper function is shared with a\nmore general \"git branch --track\" that lets you mark the new branch to\ntrack almost anything.  For example, the version from v1.6.0 gives you\nthese:\n\n    $ git branch --track maint-1.6.0 v1.6.0\n    Branch maint-1.6.0 set up to track local branch refs/tags/v1.6.0\n    $ git branch --track frotz master\n    Branch frotz set up to track local branch refs/heads/master\n\nArguably, the former should say \"track local ref refs/tags/v1.6.0\" (or the\ncommand should not even let you \"track\" a tag, which is supposed to be\nimmutable), and the latter would be helped by stripping \"refs/heads/\".\nBut the point is that stripping first 11 bytes unconditionally would be\nwrong if you happen to start tracking a tag whose name is a single byte.\n\nAlso I do not think (\"%s/%s\", origin, remote+11) is correct in general.\nYou could very well configure your tracking to:\n\n\t[remote \"origin\"]\n\tfetch = refs/heads/*:refs/remotes/upstream/*\n\nand I think the variable \"remote\" here refer to the name the ref is known\nas in the remote repository, not the name we use to keep a copy of.  IOW,\nwhen we say \"Branch frotz tracks remote 'master'\", we should say \"the\nbranch known as 'master' at the remote site, no matter what name we happen\nto call its copy locally somewhere under our refs/remotes\".\n\nIn that sense, both the version I queued and the original are lacking\na critical piece of information: which remote we are talking about.\n\nIn any case, here is your patch, made into an incremental.  I'll send out\nan alternative fix in a separate message.\n\n branch.c |   10 ++++++++--\n 1 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex d20fb04..d586843 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -65,12 +65,18 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t\tgit_config_set(key.buf, \"true\");\n \t}\n \n-\tif (flag & BRANCH_CONFIG_VERBOSE)\n+\tif (flag & BRANCH_CONFIG_VERBOSE) {\n+\t\tstrbuf_reset(&key);\n+\t\tif (origin)\n+\t\t\tstrbuf_addf(&key, \"%s/%s\", origin, remote+11);\n+\t\telse\n+\t\t\tstrbuf_addf(&key, \"%s\", remote+11);\n \t\tprintf(\"Branch %s set up to track %s branch %s %s.\\n\",\n \t\t       local,\n \t\t       origin ? \"remote\" : \"local\",\n-\t\t       remote,\n+\t\t       key.buf,\n \t\t       rebasing ? \"by rebasing\" : \"by merging\");\n+\t}\n \tstrbuf_release(&key);\n }\n \n"},{"id":"107553","messageId":"7v63ihbxgl.fsf_-_@gitster.siamese.dyndns.org","threadId":"18246","inReplyTo":"7vab7tbxo0.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Improve \"git branch --tracking\" output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-10T08:20:42Z","receivedAt":"2009-03-10T08:20:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"An earlier patch always spelled the full name of the ref that we track\n(e.g. \"refs/heads/frotz\" instead of just \"frotz\" when we mean the branch\nwhose name is \"frotz\").  Worse yet, because we now use the true name of\nthe ref at the original repository when talk about a tracking branch that\ncopies from a remote, such a full name alone still does not give enough\ninformation.\n\nThis reorganizes the verbose codepath to:\n\n - differentiate \"refs/heads/something\" and everything else; we say that\n   the branch tracks \"branch <something>\" if it begins with \"refs/heads/\",\n   and otherwise the branch tracks \"ref refs/<someother>/<something>\";\n\n - report the name of the remote when we talk about a tracking branch, by\n   saying \"branch frotz from origin\";\n\n - not say \"by merging\" at the end; it is the default and is not worth\n   reporting.\n\nSigned-off-by: Junio C Hamano <junio@pobox.com>\n---\n branch.c |   23 +++++++++++++++++------\n 1 files changed, 17 insertions(+), 6 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex d20fb04..5f889fe 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -65,12 +65,23 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t\tgit_config_set(key.buf, \"true\");\n \t}\n \n-\tif (flag & BRANCH_CONFIG_VERBOSE)\n-\t\tprintf(\"Branch %s set up to track %s branch %s %s.\\n\",\n-\t\t       local,\n-\t\t       origin ? \"remote\" : \"local\",\n-\t\t       remote,\n-\t\t       rebasing ? \"by rebasing\" : \"by merging\");\n+\tif (flag & BRANCH_CONFIG_VERBOSE) {\n+\t\tstrbuf_reset(&key);\n+\n+\t\tstrbuf_addstr(&key, origin ? \"remote\" : \"local\");\n+\n+\t\t/* Are we tracking a proper \"branch\"? */\n+\t\tif (!prefixcmp(remote, \"refs/heads/\")) {\n+\t\t\tstrbuf_addf(&key, \" branch %s\", remote + 11);\n+\t\t\tif (origin)\n+\t\t\t\tstrbuf_addf(&key, \" from %s\", origin);\n+\t\t}\n+\t\telse\n+\t\t\tstrbuf_addf(&key, \" ref %s\", remote);\n+\t\tprintf(\"Branch %s set up to track %s%s.\\n\",\n+\t\t       local, key.buf,\n+\t\t       rebasing ? \" by rebasing\" : \"\");\n+\t}\n \tstrbuf_release(&key);\n }\n \n"}]}