{"thread":{"id":"18121","subject":"[PATCHv3] Make git-clone respect branch.autosetuprebase","startedAt":"2009-03-03T20:23:45Z","lastAt":"2009-03-06T05:29:39Z","messageCount":4,"participants":["Pat Notz","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"106927","messageId":"1236111825-32159-1-git-send-email-pknotz@sandia.gov","threadId":"18121","inReplyTo":null,"subject":"[PATCHv3] Make git-clone respect branch.autosetuprebase","fromName":"Pat Notz","fromEmail":"pknotz@sandia.gov","sentAt":"2009-03-03T20:23:45Z","receivedAt":"2009-03-03T20:23:45Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"When git-clone creates an initial branch it was not\nchecking the branch.autosetuprebase configuration\noption (which may exist in ~/.gitconfig).\n\nAdded function to branch.c to handle autorebase\nconfiguration setup.\n\nSigned-off-by: Pat Notz <pknotz@sandia.gov>\n---\n\nSorry, the PATCHv2 email had a stray \"From:...\" line.\n\n branch.c         |   23 ++++++++++++++++-------\n branch.h         |    9 +++++++++\n builtin-clone.c  |    3 +++\n t/t5601-clone.sh |   14 ++++++++++++++\n 4 files changed, 42 insertions(+), 7 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 1f00e44..ee8b69d 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -32,21 +32,33 @@ 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 * remote)\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 remote == NULL;\n \tcase AUTOREBASE_REMOTE:\n-\t\treturn tracking->remote != NULL;\n+\t\treturn remote != NULL;\n \tcase AUTOREBASE_ALWAYS:\n \t\treturn 1;\n \t}\n \treturn 0;\n }\n \n+int setup_autorebase(const char *local, const char *remote_tracked_branch)\n+{\n+\tif (should_setup_rebase(remote_tracked_branch)) {\n+\t\tstruct strbuf key = STRBUF_INIT;\n+\t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n+\t\tgit_config_set(key.buf, \"true\");\n+\t\tstrbuf_release(&key);\n+\t\treturn 1;\n+\t}\n+\treturn 0;\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@@ -86,11 +98,8 @@ static int setup_tracking(const char *new_ref, const char *orig_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+\tif (setup_autorebase(new_ref, tracking.remote))\n \t\tprintf(\"This branch will rebase on pull.\\n\");\n-\t}\n \tfree(tracking.src);\n \n \treturn 0;\ndiff --git a/branch.h b/branch.h\nindex 9f0c2a2..b332c09 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -21,4 +21,13 @@ void create_branch(const char *head, const char *name, const char *start_name,\n  */\n void remove_branch_state(void);\n \n+/*\n+ * Used when creating a new branch to properly setup the autorebase flag\n+ * in the git-config file.  If the new branch (\"local\") is created from\n+ * a remote branch then remote_tracked_branch should be non-NULL.  If\n+ * the new branch is being created from another local branch then\n+ * remote_tracked_branch should be NULL.\n+ */\n+int setup_autorebase(const char *local, const char *remote_tracked_branch);\n+\n #endif\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex c338910..587c834 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -17,6 +17,7 @@\n #include \"unpack-trees.h\"\n #include \"transport.h\"\n #include \"strbuf.h\"\n+#include \"branch.h\"\n #include \"dir.h\"\n #include \"pack-refs.h\"\n #include \"sigchain.h\"\n@@ -360,6 +361,8 @@ 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+\tif (setup_autorebase(local, remote))\n+\t\tprintf(\"Default branch '%s' will rebase on pull.\\n\", local);\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":"106946","messageId":"7vsklt94ws.fsf@gitster.siamese.dyndns.org","threadId":"18121","inReplyTo":"1236111825-32159-1-git-send-email-pknotz@sandia.gov","subject":"Re: [PATCHv3] Make git-clone respect branch.autosetuprebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-04T06:29:55Z","receivedAt":"2009-03-04T06:29:55Z","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> When git-clone creates an initial branch it was not\n> checking the branch.autosetuprebase configuration\n> option (which may exist in ~/.gitconfig).\n>\n> Added function to branch.c to handle autorebase\n> configuration setup.\n>\n> Signed-off-by: Pat Notz <pknotz@sandia.gov>\n\nThanks.\n\nYour patch still has two codepaths that set the branch.*.merge and other\ninformation and they can diverge with later changes.  You can refactor\nthem even more to avoid that risk, like the attached patch.\n\nThe test is taken from your patch but runs inside a subshell, so that\nlater tests others may add to the script will be safer from the\nenvironment variable settings and chdir this test does.\n\n-- >8 --\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\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 c338910..a5f000a 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 use_local_hardlinks = 1;\n@@ -553,7 +541,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@@ -583,7 +571,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"},{"id":"107132","messageId":"1236308321-13557-1-git-send-email-pknotz@sandia.gov","threadId":"18121","inReplyTo":"7vsklt94ws.fsf@gitster.siamese.dyndns.org","subject":"[PATCHv4] Make git-clone respect branch.autosetuprebase","fromName":"Pat Notz","fromEmail":"pknotz@sandia.gov","sentAt":"2009-03-06T02:58:41Z","receivedAt":"2009-03-06T02:58:41Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"When git-clone creates an initial branch it was not\nchecking the branch.autosetuprebase configuration\noption (which may exist in ~/.gitconfig).\n\nCreate a single function for installing a branch into\nthe config file.  Both 'clone' and 'branch' now use the\nsame function for installing branches.\n\nRefactored as suggested by Junio C. Hamano.\n\nSigned-off-by: Pat Notz <pknotz@sandia.gov>\n---\n branch.c         |   54 ++++++++++++++++++++++++++++++++++++++----------------\n branch.h         |   11 +++++++++++\n builtin-clone.c  |   24 ++++++++----------------\n t/t5601-clone.sh |   15 +++++++++++++++\n 4 files changed, 72 insertions(+), 32 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 1f00e44..332223b 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -32,21 +32,52 @@ 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 verbose_flag,\n+\t\t\t   const char *local,\n+\t\t\t   const char *origin,\n+\t\t\t   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 (verbose_flag & BRANCH_CONFIG_VERBOSE)\n+\t\tprintf(\"Branch %s set up to track %s branch %s %s.\\n\",\n+\t\t\tlocal,\n+\t\t\torigin ? \"remote\" : \"local\",\n+\t\t\tremote,\n+\t\t\trebasing ? \"by rebasing\" : \"by merging\");\n+\tstrbuf_release(&key);\n+}\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 +86,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@@ -79,18 +109,10 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,\n \tif (tracking.matches > 1)\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+\tinstall_branch_config(BRANCH_CONFIG_VERBOSE,\n+\t\t\t      new_ref,\n+\t\t\t      tracking.remote,\n+\t\t\t      tracking.src ? tracking.src : orig_ref);\n \tfree(tracking.src);\n \n \treturn 0;\ndiff --git a/branch.h b/branch.h\nindex 9f0c2a2..9f7fdb0 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -21,4 +21,15 @@ 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_QUIET   00\n+#define BRANCH_CONFIG_VERBOSE 01\n+void install_branch_config(int verbose_flag,\n+\t\t\t   const char *local,\n+\t\t\t   const char *origin,\n+\t\t\t   const char *remote);\n+\n #endif\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex c338910..e1abf83 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -17,6 +17,7 @@\n #include \"unpack-trees.h\"\n #include \"transport.h\"\n #include \"strbuf.h\"\n+#include \"branch.h\"\n #include \"dir.h\"\n #include \"pack-refs.h\"\n #include \"sigchain.h\"\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 use_local_hardlinks = 1;\n@@ -553,8 +541,10 @@ 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\t\t\t      \"refs/heads/master\");\n+\t\t\tinstall_branch_config(BRANCH_CONFIG_QUIET,\n+\t\t\t\t\t     \"master\",\n+\t\t\t\t\t     option_origin,\n+\t\t\t\t\t     \"refs/heads/master\");\n \t}\n \n \tif (head_points_at) {\n@@ -583,7 +573,9 @@ 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(BRANCH_CONFIG_QUIET,\n+\t\t\t\t\t      head,\n+\t\t\t\t\t      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..fa10573 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.1.2\n"},{"id":"107149","messageId":"7vsklrw75o.fsf@gitster.siamese.dyndns.org","threadId":"18121","inReplyTo":"1236308321-13557-1-git-send-email-pknotz@sandia.gov","subject":"Re: [PATCHv4] Make git-clone respect branch.autosetuprebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-06T05:29:39Z","receivedAt":"2009-03-06T05:29:39Z","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> Signed-off-by: Pat Notz <pknotz@sandia.gov>\n\nThanks.  I do not think there is substantial difference from the one I\nqueued in 'pu', so I'd keep that one instead, but here are a few comments\nfor future reference.\n\n> diff --git a/branch.c b/branch.c\n> index 1f00e44..332223b 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -32,21 +32,52 @@ 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\"const char *origin\";\n\n> +void install_branch_config(int verbose_flag,\n> +\t\t\t   const char *local,\n> +\t\t\t   const char *origin,\n> +\t\t\t   const char *remote)\n> +{\n\nI called the parameter \"flag\" not \"verbose\" very much on purpose; we can\nintroduce flags that control aspects other than verbosity if we wanted to\nlater.  Renaming it to verbose_flag defeats the extensibility.\n\n> diff --git a/branch.h b/branch.h\n> index 9f0c2a2..9f7fdb0 100644\n> --- a/branch.h\n> +++ b/branch.h\n> @@ -21,4 +21,15 @@ 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_QUIET   00\n\nThis QUIET is also against the extensible design, as later flags may mean\nthings unrelated to verbosity.  With bitfield \"flags\" parameter, an unset\nbit simply means \"do not trigger this feature\" and it is customary to pass\n0 to such a function when the caller does not want anything special.\n"}]}