Skip to content

Commit 57ffc5f

Browse files
Michael J Grubergitster
authored andcommitted
Fix behavior with non-commit upstream references
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1be570f commit 57ffc5f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,13 +1296,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
12961296
base = branch->merge[0]->dst;
12971297
if (!resolve_ref(base, sha1, 1, NULL))
12981298
return 0;
1299-
theirs = lookup_commit(sha1);
1299+
theirs = lookup_commit_reference(sha1);
13001300
if (!theirs)
13011301
return 0;
13021302

13031303
if (!resolve_ref(branch->refname, sha1, 1, NULL))
13041304
return 0;
1305-
ours = lookup_commit(sha1);
1305+
ours = lookup_commit_reference(sha1);
13061306
if (!ours)
13071307
return 0;
13081308

t/t6040-tracking-info.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ test_expect_success 'status when tracking lightweight tags' '
7474
git checkout lighttrack
7575
'
7676

77-
test_expect_failure 'status when tracking annotated tags' '
77+
test_expect_success 'status when tracking annotated tags' '
7878
git checkout master &&
7979
git tag -m heavy heavy &&
8080
git branch --track heavytrack heavy >actual &&

0 commit comments

Comments
 (0)