[RFC PATCH 1/2] git-branch: allow --track to work w/local branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux