Merge branch 'mg/tracked-local-branches'

* mg/tracked-local-branches:
  Make local branches behave like remote branches when --tracked
  Test for local branches being followed with --track
This commit is contained in:
Junio C Hamano 2009-04-06 00:42:31 -07:00
commit ccc852c377
2 changed files with 14 additions and 3 deletions

View File

@ -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]);
}
}
}
@ -1451,6 +1452,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' "

View File

@ -29,7 +29,9 @@ test_expect_success setup '
git checkout -b b4 origin &&
advance e &&
advance f
)
) &&
git checkout -b follower --track master &&
advance g
'
script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
@ -56,6 +58,12 @@ test_expect_success 'checkout' '
grep "have 1 and 1 different" actual
'
test_expect_success 'checkout with local tracked branch' '
git checkout master &&
git checkout follower >actual
grep "is ahead of" actual
'
test_expect_success 'status' '
(
cd test &&