From 1be570f4ebb5f3c4e0a56341db166a760829782a Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Mon, 11 May 2009 16:42:53 +0200 Subject: Test tracking of non-commit upstreams git-checkout and git-branch allow setting up an arbitrary committish as the upstream reference for --track. In particular, tags are allowed. But they and git-status barf on non-commit upstreams as soon as they are asked for trackings stats. Expose this shortcoming by adding two tests: annotated tags are affected but lightweight tags are OK. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t6040-tracking-info.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/t6040-tracking-info.sh') diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index ba9060190d..4b89ac71f5 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -66,5 +66,19 @@ test_expect_success 'status' ' grep "have 1 and 1 different" actual ' +test_expect_success 'status when tracking lightweight tags' ' + git checkout master && + git tag light && + git branch --track lighttrack light >actual && + grep "set up to track" actual && + git checkout lighttrack +' +test_expect_failure 'status when tracking annotated tags' ' + git checkout master && + git tag -m heavy heavy && + git branch --track heavytrack heavy >actual && + grep "set up to track" actual && + git checkout heavytrack +' test_done -- cgit v1.2.1 From 57ffc5f85a17416a718d4e7baf71d8356c9c7808 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Mon, 11 May 2009 16:42:54 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- t/t6040-tracking-info.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t6040-tracking-info.sh') diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index 4b89ac71f5..5211e244b8 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -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 && -- cgit v1.2.1