public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Paolo Bonzini <bonzini@gnu•org>
To: git@vger•kernel.org
Subject: [PATCH 2/3] git-remote: add -b option to enable tracking remote branches
Date: Mon, 05 Mar 2007 09:57:30 +0100	[thread overview]
Message-ID: <esgm1q$33f$2@sea.gmane.org> (raw)

This commit adds an option to git-remote, providing a way to
switch the default behavior of git-branch from --no-track to
--track.

With `-b` option, local branches created off the remote repository
will be set up to track the remote repository, so that `git pull`
with no parameters does the right thing while you are on your local
branch.

Signed-off-by: Paolo Bonzini  <bonzini@gnu•org>
---
 Documentation/git-remote.txt |    7 ++++++-
 git-remote.perl              |    9 ++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index a9fb6a9..516d890 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git-remote'
-'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>
+'git-remote' add [-t <branch>] [-m <branch>] [-f] [-b] <name> <url>
 'git-remote' show <name>
 'git-remote' prune <name>
 'git-remote' update [group]
@@ -45,6 +45,11 @@ multiple branche without grabbing all branches.
 With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
 up to point at remote's `<master>` branch instead of whatever
 branch the `HEAD` at the remote repository actually points at.
++
+With `-b` option, local branches created off the remote repository
+will be set up to track the remote repository, so that `git pull`
+with no parameters does the right thing while you are on your local
+branch.
 
 'show'::
 
diff --git a/git-remote.perl b/git-remote.perl
index bd70bf1..0a736da 100755
--- a/git-remote.perl
+++ b/git-remote.perl
@@ -265,6 +265,9 @@ sub add_remote {
 		$git->command('config', '--add', "remote.$name.fetch",
 			      "+refs/heads/$_:refs/remotes/$name/$_");
 	}
+	if ($opts->{'track_branch'}) {
+		$git->command('config', "remote.$name.trackintolocalbranches", "true");
+	}
 	if ($opts->{'fetch'}) {
 		$git->command('fetch', $name);
 	}
@@ -300,7 +303,7 @@ sub update_remote {
 }
 
 sub add_usage {
-	print STDERR "Usage: git remote add [-f] [-t track]* [-m master] <name> <url>\n";
+	print STDERR "Usage: git remote add [-f] [-b] [-t track]* [-m master] <name> <url>\n";
 	exit(1);
 }
 
@@ -365,6 +368,10 @@ elsif ($ARGV[0] eq 'add') {
 			$opts{'fetch'} = 1;
 			next;
 		}
+		if ($opt eq '-b' || $opt eq '--track-into-branches') {
+			$opts{'track_branch'} = 1;
+			next;
+		}
 		if ($opt eq '-t' || $opt eq '--track') {
 			if (@ARGV < 1) {
 				add_usage();
-- 
1.4.4.2

                 reply	other threads:[~2007-03-05  9:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='esgm1q$33f$2@sea.gmane.org' \
    --to=bonzini@gnu$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox