Browse Source

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
maint
Junio C Hamano 16 years ago
parent
commit
ccc852c377
  1. 7
      remote.c
  2. 10
      t/t6040-tracking-info.sh

7
remote.c

@ -1170,8 +1170,9 @@ struct branch *branch_get(const char *name)
for (i = 0; i < ret->merge_nr; i++) { for (i = 0; i < ret->merge_nr; i++) {
ret->merge[i] = xcalloc(1, sizeof(**ret->merge)); ret->merge[i] = xcalloc(1, sizeof(**ret->merge));
ret->merge[i]->src = xstrdup(ret->merge_name[i]); ret->merge[i]->src = xstrdup(ret->merge_name[i]);
remote_find_tracking(ret->remote, if (remote_find_tracking(ret->remote, ret->merge[i])
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; base = branch->merge[0]->dst;
if (!prefixcmp(base, "refs/remotes/")) { if (!prefixcmp(base, "refs/remotes/")) {
base += strlen("refs/remotes/"); base += strlen("refs/remotes/");
} else if (!prefixcmp(base, "refs/heads/")) {
base += strlen("refs/heads/");
} }
if (!num_theirs) if (!num_theirs)
strbuf_addf(sb, "Your branch is ahead of '%s' " strbuf_addf(sb, "Your branch is ahead of '%s' "

10
t/t6040-tracking-info.sh

@ -29,7 +29,9 @@ test_expect_success setup '
git checkout -b b4 origin && git checkout -b b4 origin &&
advance e && advance e &&
advance f advance f
) ) &&
git checkout -b follower --track master &&
advance g
' '


script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p' script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
@ -56,6 +58,12 @@ test_expect_success 'checkout' '
grep "have 1 and 1 different" actual 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' ' test_expect_success 'status' '
( (
cd test && cd test &&

Loading…
Cancel
Save