{"thread":{"id":"7091","subject":"[PATCH 2/3] git-remote: add -b option to enable tracking remote branches","startedAt":"2007-03-05T08:57:30Z","lastAt":"2007-03-05T08:57:30Z","messageCount":1,"participants":["Paolo Bonzini"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"36307","messageId":"esgm1q$33f$2@sea.gmane.org","threadId":"7091","inReplyTo":null,"subject":"[PATCH 2/3] git-remote: add -b option to enable tracking remote branches","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2007-03-05T08:57:30Z","receivedAt":"2007-03-05T08:57:30Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"This commit adds an option to git-remote, providing a way to\nswitch the default behavior of git-branch from --no-track to\n--track.\n\nWith `-b` option, local branches created off the remote repository\nwill be set up to track the remote repository, so that `git pull`\nwith no parameters does the right thing while you are on your local\nbranch.\n\nSigned-off-by: Paolo Bonzini  <bonzini@gnu.org>\n---\n Documentation/git-remote.txt |    7 ++++++-\n git-remote.perl              |    9 ++++++++-\n 2 files changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex a9fb6a9..516d890 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-remote'\n-'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>\n+'git-remote' add [-t <branch>] [-m <branch>] [-f] [-b] <name> <url>\n 'git-remote' show <name>\n 'git-remote' prune <name>\n 'git-remote' update [group]\n@@ -45,6 +45,11 @@ multiple branche without grabbing all branches.\n With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set\n up to point at remote's `<master>` branch instead of whatever\n branch the `HEAD` at the remote repository actually points at.\n++\n+With `-b` option, local branches created off the remote repository\n+will be set up to track the remote repository, so that `git pull`\n+with no parameters does the right thing while you are on your local\n+branch.\n \n 'show'::\n \ndiff --git a/git-remote.perl b/git-remote.perl\nindex bd70bf1..0a736da 100755\n--- a/git-remote.perl\n+++ b/git-remote.perl\n@@ -265,6 +265,9 @@ sub add_remote {\n \t\t$git->command('config', '--add', \"remote.$name.fetch\",\n \t\t\t      \"+refs/heads/$_:refs/remotes/$name/$_\");\n \t}\n+\tif ($opts->{'track_branch'}) {\n+\t\t$git->command('config', \"remote.$name.trackintolocalbranches\", \"true\");\n+\t}\n \tif ($opts->{'fetch'}) {\n \t\t$git->command('fetch', $name);\n \t}\n@@ -300,7 +303,7 @@ sub update_remote {\n }\n \n sub add_usage {\n-\tprint STDERR \"Usage: git remote add [-f] [-t track]* [-m master] <name> <url>\\n\";\n+\tprint STDERR \"Usage: git remote add [-f] [-b] [-t track]* [-m master] <name> <url>\\n\";\n \texit(1);\n }\n \n@@ -365,6 +368,10 @@ elsif ($ARGV[0] eq 'add') {\n \t\t\t$opts{'fetch'} = 1;\n \t\t\tnext;\n \t\t}\n+\t\tif ($opt eq '-b' || $opt eq '--track-into-branches') {\n+\t\t\t$opts{'track_branch'} = 1;\n+\t\t\tnext;\n+\t\t}\n \t\tif ($opt eq '-t' || $opt eq '--track') {\n \t\t\tif (@ARGV < 1) {\n \t\t\t\tadd_usage();\n-- \n1.4.4.2\n"}]}