{"thread":{"id":"7092","subject":"[PATCH 3/3] git-checkout: add --track and --no-track options","startedAt":"2007-03-05T08:57:31Z","lastAt":"2007-03-05T08:57:31Z","messageCount":1,"participants":["Paolo Bonzini"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"36308","messageId":"esgm1r$33f$3@sea.gmane.org","threadId":"7092","inReplyTo":null,"subject":"[PATCH 3/3] git-checkout: add --track and --no-track options","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2007-03-05T08:57:31Z","receivedAt":"2007-03-05T08:57:31Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"This patch adds  --track and --no-track options to \"git checkout\".  In order to\ndo so, it modifies the script to use \"git branch\" to create the branch, and\npasses the two options to \"git branch\".  The two new options are only\nallowed when -b is given on the command-line, and they are only effective\nwhen the branch is created off a remote branch.\n\nThe defaults for remote branch tracking are as for \"git branch\": it is off by\ndefault, but it can be enabled with the configuration variable\n\"remote.REMOTENAME.trackintolocalbranches\".\n---\n Documentation/git-checkout.txt |   15 +++++++++++++--\n git-checkout.sh                |   17 +++++++++++------\n 2 files changed, 24 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex 1ae77be..f5b2d50 100644\n--- a/Documentation/git-checkout.txt\n+++ b/Documentation/git-checkout.txt\n@@ -8,7 +8,7 @@ git-checkout - Checkout and switch to a branch\n SYNOPSIS\n --------\n [verse]\n-'git-checkout' [-q] [-f] [-b <new_branch> [-l]] [-m] [<branch>]\n+'git-checkout' [-q] [-f] [-b [--track | --no-track] <new_branch> [-l]] [-m] [<branch>]\n 'git-checkout' [<tree-ish>] <paths>...\n \n DESCRIPTION\n@@ -18,7 +18,8 @@ When <paths> are not given, this command switches branches by\n updating the index and working tree to reflect the specified\n branch, <branch>, and updating HEAD to be <branch> or, if\n specified, <new_branch>.  Using -b will cause <new_branch> to\n-be created.\n+be created; in this case you can use the --track or --no-track\n+options, which will be passed to `git branch`.\n \n When <paths> are given, this command does *not* switch\n branches.  It updates the named paths in the working tree from\n@@ -45,6 +46,16 @@ OPTIONS\n \tby gitlink:git-check-ref-format[1].  Some of these checks\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+\tsetup so that git-pull will automatically retrieve data from\n+\tthe remote branch.\n+\n+--no-track::\n+\tWhen -b is given and a branch is created off a remote branch,\n+\tdon't setup so that git-pull will not retrieve data from the\n+\tremote branch independent of the configuration settings.\n+\n -l::\n \tCreate the new branch's ref log.  This activates recording of\n \tall changes to made the branch ref, enabling use of date\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex 14835a4..6caa9fd 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -12,6 +12,7 @@ new=\n new_name=\n force=\n branch=\n+track=\n newbranch=\n newbranch_log=\n merge=\n@@ -33,7 +34,10 @@ while [ \"$#\" != \"0\" ]; do\n \t\t\tdie \"git checkout: we do not like '$newbranch' as a branch name.\"\n \t\t;;\n \t\"-l\")\n-\t\tnewbranch_log=1\n+\t\tnewbranch_log=-l\n+\t\t;;\n+\t\"--track\"|\"--no-track\")\n+\t\ttrack=\"$arg\"\n \t\t;;\n \t\"-f\")\n \t\tforce=1\n@@ -85,6 +89,11 @@ while [ \"$#\" != \"0\" ]; do\n     esac\n done\n \n+case \"$new_branch,$track\" in\n+,--*)\n+\tdie \"git checkout: --track and --no-track require -b\"\n+esac\n+\n case \"$force$merge\" in\n 11)\n \tdie \"git checkout: -f and -m are incompatible\"\n@@ -235,11 +244,7 @@ fi\n #\n if [ \"$?\" -eq 0 ]; then\n \tif [ \"$newbranch\" ]; then\n-\t\tif [ \"$newbranch_log\" ]; then\n-\t\t\tmkdir -p $(dirname \"$GIT_DIR/logs/refs/heads/$newbranch\")\n-\t\t\ttouch \"$GIT_DIR/logs/refs/heads/$newbranch\"\n-\t\tfi\n-\t\tgit-update-ref -m \"checkout: Created from $new_name\" \"refs/heads/$newbranch\" $new || exit\n+\t\tgit-branch $track $newbranch_log \"$newbranch\" \"$new_name\" || exit\n \t\tbranch=\"$newbranch\"\n \tfi\n \tif test -n \"$branch\"\n-- \n1.4.4.2\n"}]}