[RFC PATCH 1/2] git-branch: allow --track to work w/local branches
- From
Jay Soffian <jaysoffian@gmail.com>
- Date
- Feb 16, 2008, 03:45 UTC
- Message-ID
- <1203133557-50013-1-git-send-email-jaysoffian@gmail.com>
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