Skip to content

Commit

Permalink
Fix behavior with non-commit upstream references
Browse files Browse the repository at this point in the history
stat_tracking_info() assumes that upstream references (as specified by
--track or set up automatically) are commits. By calling lookup_commit()
on them, create_objects() creates objects for them with type commit no
matter what their real type is; this disturbs lookup_tag() later on in the
call sequence, leading to git status, git branch -v  and git checkout
erroring out.

Fix this by using lookup_commit_reference() instead so that (annotated)
tags can be used as upstream references.

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 Junio C Hamano committed May 14, 2009
1 parent 1be570f commit 57ffc5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,13 +1296,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
base = branch->merge[0]->dst;
if (!resolve_ref(base, sha1, 1, NULL))
return 0;
theirs = lookup_commit(sha1);
theirs = lookup_commit_reference(sha1);
if (!theirs)
return 0;

if (!resolve_ref(branch->refname, sha1, 1, NULL))
return 0;
ours = lookup_commit(sha1);
ours = lookup_commit_reference(sha1);
if (!ours)
return 0;

Expand Down
2 changes: 1 addition & 1 deletion t/t6040-tracking-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test_expect_success 'status when tracking lightweight tags' '
git checkout lighttrack
'

test_expect_failure 'status when tracking annotated tags' '
test_expect_success 'status when tracking annotated tags' '
git checkout master &&
git tag -m heavy heavy &&
git branch --track heavytrack heavy >actual &&
Expand Down

0 comments on commit 57ffc5f

Please sign in to comment.