summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2009-04-01 23:42:49 +0200
committerJunio C Hamano <gitster@pobox.com>2009-04-01 15:48:30 -0700
commit5e6e2b487e76066d03b4f5809dc6b44b1234519a (patch)
tree758dcd08a7eecbcc13aa4298b7e60329eefabc4a /remote.c
parent57dac0bfe43a68d55e16def58b8ed305e0676d3f (diff)
downloadgit-5e6e2b487e76066d03b4f5809dc6b44b1234519a.tar.gz
Make local branches behave like remote branches when --tracked
This makes sure that local branches, when followed using --track, behave the same as remote ones (e.g. differences being reported by git status and git checkout). This fixes 1 known failure. The fix is done within branch_get(): The first natural candidate, namely remote_find_tracking(), does not have all the necessary info because in general there is no remote struct for '.', and we don't want one because it would show up in other places as well. branch_get(), on the other hand, has access to merge_names[] (in addition to merge[]) and therefore can set up the followed branch easily. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/remote.c b/remote.c
index e5d6b100d7..30d7fdec83 100644
--- a/remote.c
+++ b/remote.c
@@ -1170,8 +1170,9 @@ struct branch *branch_get(const char *name)
for (i = 0; i < ret->merge_nr; i++) {
ret->merge[i] = xcalloc(1, sizeof(**ret->merge));
ret->merge[i]->src = xstrdup(ret->merge_name[i]);
- remote_find_tracking(ret->remote,
- ret->merge[i]);
+ if (remote_find_tracking(ret->remote, ret->merge[i])
+ && !strcmp(ret->remote_name, "."))
+ ret->merge[i]->dst = xstrdup(ret->merge_name[i]);
}
}
}
@@ -1450,6 +1451,8 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
base = branch->merge[0]->dst;
if (!prefixcmp(base, "refs/remotes/")) {
base += strlen("refs/remotes/");
+ } else if (!prefixcmp(base, "refs/heads/")) {
+ base += strlen("refs/heads/");
}
if (!num_theirs)
strbuf_addf(sb, "Your branch is ahead of '%s' "