git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] git-branch: allow --track to work w/local branches
@ 2008-02-16  3:45 Jay Soffian
  2008-02-16  3:45 ` [RFC PATCH 2/2] new --rebase option to set branch.*.rebase for new branches Jay Soffian
  2008-02-16  5:10 ` [RFC PATCH 1/2] git-branch: allow --track to work w/local branches Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Jay Soffian @ 2008-02-16  3:45 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian

When given --track (or if branch.autosetupmerge is true) and basing off
a local branch, set branch.<newbranch>.remote to "." and
branch.<newbranch>.merge to the local branch. This allows us to use "git
pull" (w/o options) on the new branch.

Previously --track was silently ignored when basing off a local branch.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
 builtin-branch.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index e414c88..94ab195 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -402,6 +402,16 @@ static int setup_tracking(const char *new_ref, const char *orig_ref)
 		return error("Tracking not set up: name too long: %s",
 				new_ref);
 
+	if (!prefixcmp(orig_ref, "refs/heads/")) {
+		sprintf(key, "branch.%s.remote", new_ref);
+		git_config_set(key, ".");
+		sprintf(key, "branch.%s.merge", new_ref);
+		git_config_set(key, orig_ref);
+		printf("Branch %s set up to track local branch %s.\n",
+			       new_ref, orig_ref);
+		return 0;
+	}
+
 	memset(&tracking, 0, sizeof(tracking));
 	tracking.spec.dst = (char *)orig_ref;
 	if (for_each_remote(find_tracked_branch, &tracking) ||
-- 
1.5.4.1.1281.g75df

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-17 18:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-16  3:45 [RFC PATCH 1/2] git-branch: allow --track to work w/local branches Jay Soffian
2008-02-16  3:45 ` [RFC PATCH 2/2] new --rebase option to set branch.*.rebase for new branches Jay Soffian
2008-02-16  5:10 ` [RFC PATCH 1/2] git-branch: allow --track to work w/local branches Junio C Hamano
2008-02-16  7:07   ` Jay Soffian
2008-02-16 11:45   ` Johannes Schindelin
2008-02-17 18:05     ` Jay Soffian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).