Skip to content

Commit

Permalink
branch.c: use the parsed branch name
Browse files Browse the repository at this point in the history
When setting up tracking info, branch.c uses the given branch specifier
("name"). Use the parsed name ("ref.buf") instead so that

git branch --set-upstream @{-1} foo

sets up tracking info for the previous branch rather than for a branch
named "@{-1}".

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael J Gruber authored and gitster committed Aug 19, 2011
1 parent ec09954 commit e9d4f74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion branch.c
Expand Up @@ -210,7 +210,7 @@ void create_branch(const char *head,
start_name);

if (real_ref && track)
setup_tracking(name, real_ref, track);
setup_tracking(ref.buf+11, real_ref, track);

if (!dont_change_ref)
if (write_ref_sha1(lock, sha1, msg) < 0)
Expand Down
14 changes: 14 additions & 0 deletions t/t6040-tracking-info.sh
Expand Up @@ -110,4 +110,18 @@ test_expect_success '--set-upstream does not change branch' '
grep -q "^refs/heads/master$" actual &&
cmp expect2 actual2
'

test_expect_success '--set-upstream @{-1}' '
git checkout from-master &&
git checkout from-master2 &&
git config branch.from-master2.merge > expect2 &&
git branch --set-upstream @{-1} follower &&
git config branch.from-master.merge > actual &&
git config branch.from-master2.merge > actual2 &&
git branch --set-upstream from-master follower &&
git config branch.from-master.merge > expect &&
test_cmp expect2 actual2 &&
test_cmp expect actual
'

test_done

0 comments on commit e9d4f74

Please sign in to comment.