Skip to content

Commit

Permalink
Merge branch 'mg/tracked-local-branches'
Browse files Browse the repository at this point in the history
* mg/tracked-local-branches:
  Make local branches behave like remote branches when --tracked
  Test for local branches being followed with --track
  • Loading branch information
gitster committed Apr 6, 2009
2 parents 87d2062 + 5e6e2b4 commit ccc852c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions remote.c
Expand Up @@ -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]);
}
}
}
Expand Down Expand Up @@ -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' "
Expand Down
10 changes: 9 additions & 1 deletion t/t6040-tracking-info.sh
Expand Up @@ -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'
Expand All @@ -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 &&
Expand Down

0 comments on commit ccc852c

Please sign in to comment.