{"thread":{"id":"12202","subject":"[PATCH 1/2] branch: optionally setup branch.*.merge from upstream local branches","startedAt":"2008-02-19T16:24:37Z","lastAt":"2008-02-19T22:09:38Z","messageCount":6,"participants":["Jay Soffian","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"69280","messageId":"1203438278-73786-1-git-send-email-jaysoffian@gmail.com","threadId":"12202","inReplyTo":null,"subject":"[PATCH 1/2] branch: optionally setup branch.*.merge from upstream local branches","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-19T16:24:37Z","receivedAt":"2008-02-19T16:24:37Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"git branch / git checkout -b now honor --track when the upstream branch\nis local. Previously --track was silently ignored for local upstream\nbranches.\n\nThe configuration setting branch.autosetupmerge can now be set to\n\"always\" which is equivalent to using --track. Setting\nbranch.autosetupmerge to boolean true will retains the former behavior\nof only setting up branch.*.merge for remote upstream branches.\n\nIncludes test cases for the new functionality.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n- I broke out the documentation changes into a separate patch.\n\n- Incorporated Johannes' suggested change to setup_tracking().\n\n- Incorporated Junio's suggestion that explicit --track should cause a\n  failure when the starting point is not a branch.\n\n branch.c           |   44 ++++++++++++++++++++++++--------------------\n branch.h           |    2 +-\n builtin-branch.c   |   14 +++++---------\n builtin-checkout.c |   14 +++++---------\n cache.h            |    9 +++++++++\n config.c           |    8 ++++++++\n environment.c      |    1 +\n t/t3200-branch.sh  |   22 +++++++++++++++++++++-\n t/t7201-co.sh      |   24 ++++++++++++++++++++++++\n 9 files changed, 98 insertions(+), 40 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 1fc8788..daf862e 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -37,7 +37,8 @@ static int find_tracked_branch(struct remote *remote, void *priv)\n  * to infer the settings for branch.<new_ref>.{remote,merge} from the\n  * config.\n  */\n-static int setup_tracking(const char *new_ref, const char *orig_ref)\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@@ -48,30 +49,36 @@ static int setup_tracking(const char *new_ref, const char *orig_ref)\n \n \tmemset(&tracking, 0, sizeof(tracking));\n \ttracking.spec.dst = (char *)orig_ref;\n-\tif (for_each_remote(find_tracked_branch, &tracking) ||\n-\t\t\t!tracking.matches)\n+\tif (for_each_remote(find_tracked_branch, &tracking))\n \t\treturn 1;\n \n+\tif (!tracking.matches)\n+\t\tswitch (track) {\n+\t\tcase BRANCH_TRACK_ALWAYS:\n+\t\tcase BRANCH_TRACK_EXPLICIT:\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\treturn 1;\n+\t\t}\n+\n \tif (tracking.matches > 1)\n \t\treturn error(\"Not tracking: ambiguous information for ref %s\",\n \t\t\t\torig_ref);\n \n-\tif (tracking.matches == 1) {\n-\t\tsprintf(key, \"branch.%s.remote\", new_ref);\n-\t\tgit_config_set(key, tracking.remote ?  tracking.remote : \".\");\n-\t\tsprintf(key, \"branch.%s.merge\", new_ref);\n-\t\tgit_config_set(key, tracking.src);\n-\t\tfree(tracking.src);\n-\t\tprintf(\"Branch %s set up to track remote branch %s.\\n\",\n-\t\t\t       new_ref, orig_ref);\n-\t}\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+\tfree(tracking.src);\n+\tprintf(\"Branch %s set up to track %s branch %s.\\n\", new_ref,\n+\t\ttracking.remote ? \"remote\" : \"local\", orig_ref);\n \n \treturn 0;\n }\n \n void create_branch(const char *head,\n \t\t   const char *name, const char *start_name,\n-\t\t   int force, int reflog, int track)\n+\t\t   int force, int reflog, enum branch_track track)\n {\n \tstruct ref_lock *lock;\n \tstruct commit *commit;\n@@ -98,7 +105,8 @@ void create_branch(const char *head,\n \tswitch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) {\n \tcase 0:\n \t\t/* Not branching from any existing branch */\n-\t\treal_ref = NULL;\n+\t\tif (track == BRANCH_TRACK_EXPLICIT)\n+\t\t\tdie(\"Cannot setup tracking information; starting point is not a branch.\");\n \t\tbreak;\n \tcase 1:\n \t\t/* Unique completion -- good */\n@@ -126,17 +134,13 @@ void create_branch(const char *head,\n \t\tsnprintf(msg, sizeof msg, \"branch: Created from %s\",\n \t\t\t start_name);\n \n-\t/* When branching off a remote branch, set up so that git-pull\n-\t   automatically merges from there.  So far, this is only done for\n-\t   remotes registered via .git/config.  */\n \tif (real_ref && track)\n-\t\tsetup_tracking(name, real_ref);\n+\t\tsetup_tracking(name, real_ref, track);\n \n \tif (write_ref_sha1(lock, sha1, msg) < 0)\n \t\tdie(\"Failed to write ref: %s.\", strerror(errno));\n \n-\tif (real_ref)\n-\t\tfree(real_ref);\n+\tfree(real_ref);\n }\n \n void remove_branch_state(void)\ndiff --git a/branch.h b/branch.h\nindex d30abe0..9f0c2a2 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -13,7 +13,7 @@\n  * branch for (if any).\n  */\n void create_branch(const char *head, const char *name, const char *start_name,\n-\t\t   int force, int reflog, int track);\n+\t\t   int force, int reflog, enum branch_track track);\n \n /*\n  * Remove information about the state of working on the current\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 7e99103..a784445 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -30,8 +30,6 @@ static const char * const builtin_branch_usage[] = {\n static const char *head;\n static unsigned char head_sha1[20];\n \n-static int branch_track = 1;\n-\n static int branch_use_color = -1;\n static char branch_colors[][COLOR_MAXLEN] = {\n \t\"\\033[m\",\t/* reset */\n@@ -76,10 +74,6 @@ static int git_branch_config(const char *var, const char *value)\n \t\tcolor_parse(value, var, branch_colors[slot]);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"branch.autosetupmerge\")) {\n-\t\tbranch_track = git_config_bool(var, value);\n-\t\treturn 0;\n-\t}\n \treturn git_color_default_config(var, value);\n }\n \n@@ -420,14 +414,16 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n {\n \tint delete = 0, rename = 0, force_create = 0;\n \tint verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;\n-\tint reflog = 0, track;\n+\tint reflog = 0;\n+\tenum branch_track track;\n \tint kinds = REF_LOCAL_BRANCH;\n \tstruct commit_list *with_commit = NULL;\n \n \tstruct option options[] = {\n \t\tOPT_GROUP(\"Generic options\"),\n \t\tOPT__VERBOSE(&verbose),\n-\t\tOPT_BOOLEAN( 0 , \"track\",  &track, \"set up tracking mode (see git-pull(1))\"),\n+\t\tOPT_SET_INT( 0 , \"track\",  &track, \"set up tracking mode (see git-pull(1))\",\n+\t\t\tBRANCH_TRACK_EXPLICIT),\n \t\tOPT_BOOLEAN( 0 , \"color\",  &branch_use_color, \"use colored output\"),\n \t\tOPT_SET_INT('r', NULL,     &kinds, \"act on remote-tracking branches\",\n \t\t\tREF_REMOTE_BRANCH),\n@@ -458,7 +454,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tif (branch_use_color == -1)\n \t\tbranch_use_color = git_use_color_default;\n \n-\ttrack = branch_track;\n+\ttrack = git_branch_track;\n \targc = parse_options(argc, argv, options, builtin_branch_usage, 0);\n \tif (!!delete + !!rename + !!force_create > 1)\n \t\tusage_with_options(builtin_branch_usage, options);\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 0d19835..73df7f0 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -186,7 +186,7 @@ struct checkout_opts {\n \n \tchar *new_branch;\n \tint new_branch_log;\n-\tint track;\n+\tenum branch_track track;\n };\n \n struct branch_info {\n@@ -521,13 +521,8 @@ static int switch_branches(struct checkout_opts *opts,\n \treturn post_checkout_hook(old.commit, new->commit, 1);\n }\n \n-static int branch_track = 0;\n-\n static int git_checkout_config(const char *var, const char *value)\n {\n-\tif (!strcmp(var, \"branch.autosetupmerge\"))\n-\t\tbranch_track = git_config_bool(var, value);\n-\n \treturn git_default_config(var, value);\n }\n \n@@ -542,7 +537,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\tOPT__QUIET(&opts.quiet),\n \t\tOPT_STRING('b', NULL, &opts.new_branch, \"new branch\", \"branch\"),\n \t\tOPT_BOOLEAN('l', NULL, &opts.new_branch_log, \"log for new branch\"),\n-\t\tOPT_BOOLEAN( 0 , \"track\", &opts.track, \"track\"),\n+\t\tOPT_SET_INT( 0 , \"track\",  &opts.track, \"track\",\n+\t\t\tBRANCH_TRACK_EXPLICIT),\n \t\tOPT_BOOLEAN('f', NULL, &opts.force, \"force\"),\n \t\tOPT_BOOLEAN('m', NULL, &opts.merge, \"merge\"),\n \t\tOPT_END(),\n@@ -553,7 +549,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_checkout_config);\n \n-\topts.track = branch_track;\n+\topts.track = git_branch_track;\n \n \targc = parse_options(argc, argv, options, checkout_usage, 0);\n \tif (argc) {\n@@ -582,7 +578,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\targc--;\n \t}\n \n-\tif (!opts.new_branch && (opts.track != branch_track))\n+\tif (!opts.new_branch && (opts.track != git_branch_track))\n \t\tdie(\"git checkout: --track and --no-track require -b\");\n \n \tif (opts.force && opts.merge)\ndiff --git a/cache.h b/cache.h\nindex 2b59c44..a5b9ffd 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -393,6 +393,15 @@ enum safe_crlf {\n \n extern enum safe_crlf safe_crlf;\n \n+enum branch_track {\n+\tBRANCH_TRACK_NEVER = 0,\n+\tBRANCH_TRACK_REMOTE,\n+\tBRANCH_TRACK_ALWAYS,\n+\tBRANCH_TRACK_EXPLICIT,\n+};\n+\n+extern enum branch_track git_branch_track;\n+\n #define GIT_REPO_VERSION 0\n extern int repository_format_version;\n extern int check_repository_format(void);\ndiff --git a/config.c b/config.c\nindex 8064cae..556b2ec 100644\n--- a/config.c\n+++ b/config.c\n@@ -464,6 +464,14 @@ int git_default_config(const char *var, const char *value)\n \t\twhitespace_rule_cfg = parse_whitespace_rule(value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"branch.autosetupmerge\")) {\n+\t\tif (value && !strcasecmp(value, \"always\")) {\n+\t\t\tgit_branch_track = BRANCH_TRACK_ALWAYS;\n+\t\t\treturn 0;\n+\t\t}\n+\t\tgit_branch_track = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \n \t/* Add other config variables here and to Documentation/config.txt. */\n \treturn 0;\ndiff --git a/environment.c b/environment.c\nindex 3527f16..6739a3f 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -37,6 +37,7 @@ const char *excludes_file;\n int auto_crlf = 0;\t/* 1: both ways, -1: only when adding git objects */\n enum safe_crlf safe_crlf = SAFE_CRLF_WARN;\n unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;\n+enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;\n \n /* This is set by setup_git_dir_gently() and/or git_default_config() */\n char *git_work_tree_cfg;\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex d21081d..38a90ad 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -15,6 +15,9 @@ test_expect_success \\\n     'echo Hello > A &&\n      git update-index --add A &&\n      git-commit -m \"Initial commit.\" &&\n+     echo World >> A &&\n+     git update-index --add A &&\n+     git-commit -m \"Second commit.\" &&\n      HEAD=$(git rev-parse --verify HEAD)'\n \n test_expect_success \\\n@@ -171,7 +174,9 @@ test_expect_success 'test overriding tracking setup via --no-track' \\\n      ! test \"$(git config branch.my2.merge)\" = refs/heads/master'\n \n test_expect_success 'no tracking without .fetch entries' \\\n-    'git branch --track my6 s &&\n+    'git config branch.autosetupmerge true &&\n+     git branch my6 s &&\n+     git config branch.automsetupmerge false &&\n      test -z \"$(git config branch.my6.remote)\" &&\n      test -z \"$(git config branch.my6.merge)\"'\n \n@@ -192,6 +197,21 @@ test_expect_success 'test deleting branch without config' \\\n     'git branch my7 s &&\n      test \"$(git branch -d my7 2>&1)\" = \"Deleted branch my7.\"'\n \n+test_expect_success 'test --track without .fetch entries' \\\n+    'git branch --track my8 &&\n+     test \"$(git config branch.my8.remote)\" &&\n+     test \"$(git config branch.my8.merge)\"'\n+\n+test_expect_success \\\n+    'branch from non-branch HEAD w/autosetupmerge=always' \\\n+    'git config branch.autosetupmerge always &&\n+     git branch my9 HEAD^ &&\n+     git config branch.autosetupmerge false'\n+\n+test_expect_success \\\n+    'branch from non-branch HEAD w/--track causes failure' \\\n+    '!(git branch --track my10 HEAD^)'\n+\n # Keep this test last, as it changes the current branch\n cat >expect <<EOF\n 0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\ndiff --git a/t/t7201-co.sh b/t/t7201-co.sh\nindex 06959d9..0a6c6ed 100755\n--- a/t/t7201-co.sh\n+++ b/t/t7201-co.sh\n@@ -279,4 +279,28 @@ test_expect_success 'checkout with ambiguous tag/branch names' '\n \n '\n \n+test_expect_success \\\n+    'checkout w/--track sets up tracking' '\n+    git config branch.autosetupmerge false &&\n+    git checkout master &&\n+    git checkout --track -b track1 &&\n+    test \"$(git config branch.track1.remote)\" &&\n+    test \"$(git config branch.track1.merge)\"'\n+\n+test_expect_success \\\n+    'checkout w/autosetupmerge=always sets up tracking' '\n+    git config branch.autosetupmerge always &&\n+    git checkout master &&\n+    git checkout -b track2 &&\n+    test \"$(git config branch.track2.remote)\" &&\n+    test \"$(git config branch.track2.merge)\"\n+    git config branch.autosetupmerge false'\n+\n+test_expect_success \\\n+    'checkout w/--track from non-branch HEAD fails' '\n+    git checkout -b delete-me master &&\n+    rm .git/refs/heads/delete-me &&\n+    test refs/heads/delete-me = \"$(git symbolic-ref HEAD)\" &&\n+    !(git checkout --track -b track)'\n+\n test_done\n-- \n1.5.4.2.203.g1b97.dirty\n"},{"id":"69281","messageId":"1203438278-73786-2-git-send-email-jaysoffian@gmail.com","threadId":"12202","inReplyTo":"1203438278-73786-1-git-send-email-jaysoffian@gmail.com","subject":"[PATCH 2/2] doc: documentation update for the branch track changes","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-19T16:24:38Z","receivedAt":"2008-02-19T16:24:38Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Documents the branch.autosetupmerge=always setting and usage of --track\nwhen branching from a local branch.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nI was trying to change too much at once. This is the bare minimum to\ndocument the functionality changes.\n\n Documentation/config.txt       |   10 +++++++---\n Documentation/git-branch.txt   |   32 +++++++++++++++-----------------\n Documentation/git-checkout.txt |   24 +++++++++++-------------\n 3 files changed, 33 insertions(+), 33 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex fb6dae0..45bf8cd 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -379,10 +379,14 @@ apply.whitespace::\n \n branch.autosetupmerge::\n \tTells `git-branch` and `git-checkout` to setup new branches\n-\tso that linkgit:git-pull[1] will appropriately merge from that\n-\tremote branch.  Note that even if this option is not set,\n+\tso that linkgit:git-pull[1] will appropriately merge from the\n+\tstarting point branch. Note that even if this option is not set,\n \tthis behavior can be chosen per-branch using the `--track`\n-\tand `--no-track` options.  This option defaults to true.\n+\tand `--no-track` options. The valid settings are: `false` -- no\n+\tautomatic setup is done; `true` -- automatic setup is done when the\n+\tstarting point is a remote branch; `always` -- automatic setup is\n+\tdone when the starting point is either a local branch or remote\n+\tbranch. This option defaults to true.\n \n branch.<name>.remote::\n \tWhen in branch <name>, it tells `git fetch` which remote to fetch.\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex 7e8874a..c5426a5 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -35,11 +35,10 @@ working tree to it; use \"git checkout <newbranch>\" to switch to the\n new branch.\n \n When a local branch is started off a remote branch, git sets up the\n-branch so that linkgit:git-pull[1] will appropriately merge from that\n-remote branch.  If this behavior is not desired, it is possible to\n-disable it using the global `branch.autosetupmerge` configuration\n-flag.  That setting can be overridden by using the `--track`\n-and `--no-track` options.\n+branch so that linkgit:git-pull[1] will appropriately merge from\n+the remote branch. This behavior may be changed via the global\n+`branch.autosetupmerge` configuration flag. That setting can be\n+overridden by using the `--track` and `--no-track` options.\n \n With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>.\n If <oldbranch> had a corresponding reflog, it is renamed to match\n@@ -105,20 +104,19 @@ OPTIONS\n \tDisplay the full sha1s in output listing rather than abbreviating them.\n \n --track::\n-\tSet up configuration so that git-pull will automatically\n-\tretrieve data from the remote branch.  Use this if you always\n-\tpull from the same remote branch into the new branch, or if you\n-\tdon't want to use \"git pull <repository> <refspec>\" explicitly.\n-\tThis behavior is the default.  Set the\n-\tbranch.autosetupmerge configuration variable to false if you\n-\twant git-checkout and git-branch to always behave as if\n-\t'--no-track' were given.\n+\tWhen creating a new branch, set up configuration so that git-pull\n+\twill automatically retrieve data from the start point, which must be\n+\ta branch. Use this if you always pull from the same upstream branch\n+\tinto the new branch, or if you don't want to use \"git pull\n+\t<repository> <refspec>\" explicitly. This behavior is the default\n+\twhen the start point is a remote branch. Set the\n+\tbranch.autosetupmerge configuration variable to `false` if you want\n+\tgit-checkout and git-branch to always behave as if '--no-track' were\n+\tgiven. Set it to `always` if you want this behavior when the\n+\tstart-point is either a local or remote branch.\n \n --no-track::\n-\tWhen a branch is created off a remote branch,\n-\tset up configuration so that git-pull will not retrieve data\n-\tfrom the remote branch, ignoring the branch.autosetupmerge\n-\tconfiguration variable.\n+\tIgnore the branch.autosetupmerge configuration variable.\n \n <branchname>::\n \tThe name of the branch to create or delete.\ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex b4cfa04..7c7cfb1 100644\n--- a/Documentation/git-checkout.txt\n+++ b/Documentation/git-checkout.txt\n@@ -48,21 +48,19 @@ OPTIONS\n \tmay restrict the characters allowed in a branch name.\n \n --track::\n-\tWhen -b is given and a branch is created off a remote branch,\n-\tset up configuration so that git-pull will automatically\n-\tretrieve data from the remote branch.  Use this if you always\n-\tpull from the same remote branch into the new branch, or if you\n-\tdon't want to use \"git pull <repository> <refspec>\" explicitly.\n-\tThis behavior is the default.  Set the\n-\tbranch.autosetupmerge configuration variable to false if you\n-\twant git-checkout and git-branch to always behave as if\n-\t'--no-track' were given.\n+\tWhen creating a new branch, set up configuration so that git-pull\n+\twill automatically retrieve data from the start point, which must be\n+\ta branch. Use this if you always pull from the same upstream branch\n+\tinto the new branch, or if you don't want to use \"git pull\n+\t<repository> <refspec>\" explicitly. This behavior is the default\n+\twhen the start point is a remote branch. Set the\n+\tbranch.autosetupmerge configuration variable to `false` if you want\n+\tgit-checkout and git-branch to always behave as if '--no-track' were\n+\tgiven. Set it to `always` if you want this behavior when the\n+\tstart-point is either a local or remote branch.\n \n --no-track::\n-\tWhen -b is given and a branch is created off a remote branch,\n-\tset up configuration so that git-pull will not retrieve data\n-\tfrom the remote branch, ignoring the branch.autosetupmerge\n-\tconfiguration variable.\n+\tIgnore the branch.autosetupmerge configuration variable.\n \n -l::\n \tCreate the new branch's reflog.  This activates recording of\n-- \n1.5.4.2.203.g1b97.dirty\n"},{"id":"69287","messageId":"76718490802190833p68d361b4jf93ac196fe671d6b@mail.gmail.com","threadId":"12202","inReplyTo":"1203438278-73786-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH 1/2] branch: optionally setup branch.*.merge from upstream local branches","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-19T16:33:36Z","receivedAt":"2008-02-19T16:33:36Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Feb 19, 2008 11:24 AM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> git branch / git checkout -b now honor --track when the upstream branch\n> is local. Previously --track was silently ignored for local upstream\n> branches.\n>\n> The configuration setting branch.autosetupmerge can now be set to\n> \"always\" which is equivalent to using --track. Setting\n> branch.autosetupmerge to boolean true will retains the former behavior\n> of only setting up branch.*.merge for remote upstream branches.\n\nI re-used my commit message w/o thinking enough. The truth is:\n\n * '--track' fails if the starting point isn't a branch.\n\n * autosetupmerge=always sets up tracking if the starting point is a branch\n   (local or remote), otherwise (if starting point is not a branch) it is\n   ignored.\n\nj.\n"},{"id":"69291","messageId":"alpine.LSU.1.00.0802191643490.30505@racer.site","threadId":"12202","inReplyTo":"1203438278-73786-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH 1/2] branch: optionally setup branch.*.merge from upstream local branches","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-19T16:45:22Z","receivedAt":"2008-02-19T16:45:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 19 Feb 2008, Jay Soffian wrote:\n\n> +\tif (!tracking.matches)\n> +\t\tswitch (track) {\n> +\t\tcase BRANCH_TRACK_ALWAYS:\n> +\t\tcase BRANCH_TRACK_EXPLICIT:\n> +\t\t\tbreak;\n> +\t\tdefault:\n> +\t\t\treturn 1;\n> +\t\t}\n\nI'd write that as\n\n\tif (!tracking.matches &&\n\t    (track == BRANCH_TRACK_ALWAYS || track == BRANCH_TRACK_EXPLICIT))\n\t\treturn 1;\n\nbut that is really niggling about style...\n\nAs you can see, I have no real objections ;-)\n\nCiao,\nDscho\n"},{"id":"69314","messageId":"7vfxvoiqb5.fsf@gitster.siamese.dyndns.org","threadId":"12202","inReplyTo":"1203438278-73786-2-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH 2/2] doc: documentation update for the branch track changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-19T21:34:06Z","receivedAt":"2008-02-19T21:34:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> Documents the branch.autosetupmerge=always setting and usage of --track\n> when branching from a local branch.\n>\n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n> ---\n> I was trying to change too much at once. This is the bare minimum to\n> document the functionality changes.\n\nThis is very much appreciated.  Bite-sized changes make\nreviewing much more pleasant.\n\n> diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\n> index 7e8874a..c5426a5 100644\n> --- a/Documentation/git-branch.txt\n> +++ b/Documentation/git-branch.txt\n> @@ -105,20 +104,19 @@ OPTIONS\n>  \tDisplay the full sha1s in output listing rather than abbreviating them.\n>  \n>  --track::\n> -\tSet up configuration so that git-pull will automatically\n> -\tretrieve data from the remote branch.  Use this if you always\n> -\tpull from the same remote branch into the new branch, or if you\n> -\tdon't want to use \"git pull <repository> <refspec>\" explicitly.\n> -\tThis behavior is the default.  Set the\n> -\tbranch.autosetupmerge configuration variable to false if you\n> -\twant git-checkout and git-branch to always behave as if\n> -\t'--no-track' were given.\n> +\tWhen creating a new branch, set up configuration so that git-pull\n> +\twill automatically retrieve data from the start point, which must be\n> +\ta branch. Use this if you always pull from the same upstream branch\n> +\tinto the new branch, or if you don't want to use \"git pull\n> +\t<repository> <refspec>\" explicitly. ...\n\nMicronit; I think this \", or\" should be \", and\".\n\n> diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\n> index b4cfa04..7c7cfb1 100644\n> --- a/Documentation/git-checkout.txt\n> +++ b/Documentation/git-checkout.txt\n> @@ -48,21 +48,19 @@ OPTIONS\n>  \tmay restrict the characters allowed in a branch name.\n>  \n>  --track::\n> ...\n>  --no-track::\n> ...\n\nMicronit; we would want to create track-options.txt and then\ninclude::track-options.txt[] from here and in git-branch.txt\n(that can be done later).\n\nOtherwise, the patch looks fine, and I'll queue this as-is,\ntogether with your [1/2] (with the \"oops, commit message is\nstale\" amended in).  We can incrementally improve on these\nin-tree from here on.\n\nI am very tempted to squish the \"s/,or /, and/\" change in while\napplying [2/2], though.\n\nBy the way, please do not get discouraged to send-in the doc\nclean-ups.  I \"gave up (for now)\" last night because it was\ngetting late, I had other patches to review and accept/respond,\nand I felt I did not have time to comment on a patch that mixes\nclean-ups and feature enhancements at that point.\n\nIt is a good idea to organize a series so that clean-ups to\nexisting stuff that you are going to touch come first, and then\nyour own enhancements come on top, for a few reasons:\n\n (1) It is good for reviewers, because each can be looked at\n     individually.\n\n     * A clean-up is not supposed to change the behaviour and/or\n       semantics unless it is a bugfix.  An error in rewriting\n       becomes easier to spot if it is done standalone.\n       Otherwise the reviewers need to wonder \"why is it this\n       way now?  Is it a thinko, or is it because it interacts\n       with the new feature?\"\n\n     * An enhancement on top of the cleaned-up base will be\n       smaller and easier to understand what gets changed.\n\n (2) It is good for the maintainer, for the same reason as\n     above, and in addition, even when the list does not yet\n     agree with the proposed enhancements, the clean-ups to\n     allow any other future work (not limited to the\n     contributor's) may be received favorably already.  The\n     clean-up can be applied early while potentially\n     controversial enhancements are still being discussed and\n     polished.  This reduces the total amount of changes in\n     flight --- smaller number of things to keep track of.\n     \n (3) It is good for contributors, because the new work (which is\n     what the contributors are more interested in) can be done\n     on solidified base, and the patch that may need to go\n     through multiple rounds of polishing would become smaller,\n     if clean-ups are accepted independently in earlier rounds.\n\nThe same principle applies to both code and documentation.\n"},{"id":"69323","messageId":"76718490802191409w4ca693dcr6a0c1006645ad907@mail.gmail.com","threadId":"12202","inReplyTo":"7vfxvoiqb5.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] doc: documentation update for the branch track changes","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-19T22:09:38Z","receivedAt":"2008-02-19T22:09:38Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Feb 19, 2008 4:34 PM, Junio C Hamano <gitster@pobox.com> wrote:\n\n> Micronit; I think this \", or\" should be \", and\".\n\nProbably, I just kept the existing wording. Should you go over all the current\ndocs with the same fine-toothed comb you're applying here, you'd end up in a\nhole from which you might never emerge. :-)\n\n> Micronit; we would want to create track-options.txt and then\n> include::track-options.txt[] from here and in git-branch.txt\n> (that can be done later).\n\nYes, lots of opportunity for refactoring the documentation. Was trying to keep\nthe change small.\n\n> Otherwise, the patch looks fine, and I'll queue this as-is,\n> together with your [1/2] (with the \"oops, commit message is\n> stale\" amended in).  We can incrementally improve on these\n> in-tree from here on.\n>\n> I am very tempted to squish the \"s/,or /, and/\" change in while\n> applying [2/2], though.\n\nThanks, either way.\n\n> By the way, please do not get discouraged to send-in the doc\n> clean-ups.  I \"gave up (for now)\" last night because it was\n> getting late, I had other patches to review and accept/respond,\n> and I felt I did not have time to comment on a patch that mixes\n> clean-ups and feature enhancements at that point.\n\nFair enough, it was the \"now this is getting tiresome\" that raised my hackles.\nbut no worries, I think I may be getting the hang of this...\n\n> It is a good idea to organize a series so that clean-ups to\n> existing stuff that you are going to touch come first, and then\n> your own enhancements come on top, for a few reasons:\n>\n>  [...]\n\nUnderstood and appreciated. I think I didn't realize the cleanup was needed\ntill after I sent in the patches and realized, hey, I guess I need to add some\ndocumentation too... I know better for next time.\n\nThanks again for all your help on this.\n\nj.\n"}]}