@matheusbsbs / matheus-bagliano / commits / 57ffc5f85a
Fork 0

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 <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed May 11, 2009 at 16:42 UTC 57ffc5f85a17416a718d4e7baf71d8356c9c7808
2 files changed +3 -3
remote.c
+2 -2
@@ -1296,13 +1296,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
1296 base = branch->merge[0]->dst;
1297 if (!resolve_ref(base, sha1, 1, NULL))
1298 return 0;
1299 - theirs = lookup_commit(sha1);
1299 + theirs = lookup_commit_reference(sha1);
1300 if (!theirs)
1301 return 0;
1302
1303 if (!resolve_ref(branch->refname, sha1, 1, NULL))
1304 return 0;
1305 - ours = lookup_commit(sha1);
1305 + ours = lookup_commit_reference(sha1);
1306 if (!ours)
1307 return 0;
1308
t/t6040-tracking-info.sh
+1 -1
@@ -74,7 +74,7 @@ test_expect_success 'status when tracking lightweight tags' '
74 git checkout lighttrack
75 '
76
77 -test_expect_failure 'status when tracking annotated tags' '
77 +test_expect_success 'status when tracking annotated tags' '
78 git checkout master &&
79 git tag -m heavy heavy &&
80 git branch --track heavytrack heavy >actual &&