{"thread":{"id":"19290","subject":"[PATCH 0/2] Allow tags as upstreams for --track","startedAt":"2009-05-11T14:42:52Z","lastAt":"2009-05-14T07:51:11Z","messageCount":4,"participants":["Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"113545","messageId":"1242052974-28184-1-git-send-email-git@drmicha.warpmail.net","threadId":"19290","inReplyTo":null,"subject":"[PATCH 0/2] Allow tags as upstreams for --track","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-11T14:42:52Z","receivedAt":"2009-05-11T14:42:52Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"I sent this patch during rc without a test and it received the\nappropriate reaction ;)\n\nNow, comes with test and all that...\n\nThis is about using tags as the upstream for --track (checkout,\nbranch). Currently, git allows to do that but all status generating\ncommands (status, checkout, branch -v) barf when the upstream is not a\ncommit, such as an annotated tag. So, either we should disallow this or\ndeal with it. The latter is actually easier, sometimes useful and does\nnot harm any living creatures.\n\nThe first patch exposes the issue by 2 tests: lightweight tags are OK,\nannotated tags are not.\n\nThe second patch teaches stat_tracking_info() to resolve a reference to\na commit before using it.\n\nTags as upstreams can be useful because then branch -vv gives you concise\ninformation about how much work you have done say on top of a released\nversion, in case where the \"behind\" information with respect to a branch\nwould be less informative (Where did I fork?) and confusing (Behind?\nWhat do you mean behind for a branch on top of a released version?).\n\nMichael J Gruber (2):\n  Test tracking of non-commit upstreams\n  Fix behavior with non-committish upstream references\n\n remote.c                 |    4 ++--\n t/t6040-tracking-info.sh |   14 ++++++++++++++\n 2 files changed, 16 insertions(+), 2 deletions(-)\n"},{"id":"113546","messageId":"1242052974-28184-2-git-send-email-git@drmicha.warpmail.net","threadId":"19290","inReplyTo":"1242052974-28184-1-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 1/2] Test tracking of non-commit upstreams","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-11T14:42:53Z","receivedAt":"2009-05-11T14:42:53Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"git-checkout and git-branch allow setting up an arbitrary committish as\nthe upstream reference for --track. In particular, tags are allowed. But\nthey and git-status barf on non-commit upstreams as soon as they are\nasked for trackings stats.\n\nExpose this shortcoming by adding two tests: annotated tags are affected\nbut lightweight tags are OK.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t6040-tracking-info.sh |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh\nindex 3d6db4d..2397774 100755\n--- a/t/t6040-tracking-info.sh\n+++ b/t/t6040-tracking-info.sh\n@@ -74,5 +74,19 @@ test_expect_success 'status' '\n \tgrep \"have 1 and 1 different\" actual\n '\n \n+test_expect_success 'status when tracking lightweight tags' '\n+\tgit checkout master &&\n+\tgit tag light && \n+\tgit branch --track lighttrack light >actual &&\n+\tgrep \"set up to track\" actual &&\n+\tgit checkout lighttrack\n+'\n \n+test_expect_failure 'status when tracking annotated tags' '\n+\tgit checkout master &&\n+\tgit tag -m heavy heavy && \n+\tgit branch --track heavytrack heavy >actual &&\n+\tgrep \"set up to track\" actual &&\n+\tgit checkout heavytrack\n+'\n test_done\n-- \n1.6.3.195.gad816\n"},{"id":"113547","messageId":"1242052974-28184-3-git-send-email-git@drmicha.warpmail.net","threadId":"19290","inReplyTo":"1242052974-28184-2-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 2/2] Fix behavior with non-committish upstream references","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-11T14:42:54Z","receivedAt":"2009-05-11T14:42:54Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"stat_tracking_info() assumes that upstream references (as specified by\n--track or set up automatically) are commits. By calling lookup_commit()\non them, create_objects() creates objects for them with type commit no\nmatter what their real type is; this disturbs lookup_tag() later on in the\ncall sequence, leading to git status, git branch -v  and git checkout\nerroring out.\n\nFix this by using lookup_commit_reference() instead so that (annotated)\ntags can be used as upstream references.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n remote.c                 |    4 ++--\n t/t6040-tracking-info.sh |    2 +-\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex d66e2f3..2c3e905 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1399,13 +1399,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)\n \tbase = branch->merge[0]->dst;\n \tif (!resolve_ref(base, sha1, 1, NULL))\n \t\treturn 0;\n-\ttheirs = lookup_commit(sha1);\n+\ttheirs = lookup_commit_reference(sha1);\n \tif (!theirs)\n \t\treturn 0;\n \n \tif (!resolve_ref(branch->refname, sha1, 1, NULL))\n \t\treturn 0;\n-\tours = lookup_commit(sha1);\n+\tours = lookup_commit_reference(sha1);\n \tif (!ours)\n \t\treturn 0;\n \ndiff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh\nindex 2397774..e38c597 100755\n--- a/t/t6040-tracking-info.sh\n+++ b/t/t6040-tracking-info.sh\n@@ -82,7 +82,7 @@ test_expect_success 'status when tracking lightweight tags' '\n \tgit checkout lighttrack\n '\n \n-test_expect_failure 'status when tracking annotated tags' '\n+test_expect_success 'status when tracking annotated tags' '\n \tgit checkout master &&\n \tgit tag -m heavy heavy && \n \tgit branch --track heavytrack heavy >actual &&\n-- \n1.6.3.195.gad816\n"},{"id":"113906","messageId":"4A0BCD6F.70806@warpmail.net","threadId":"19290","inReplyTo":"1242052974-28184-3-git-send-email-git@drmicha.warpmail.net","subject":"Re: [PATCH 2/2] Fix behavior with non-committish upstream references","fromName":"Michael J Gruber","fromEmail":"drmicha@warpmail.net","sentAt":"2009-05-14T07:51:11Z","receivedAt":"2009-05-14T07:51:11Z","isPatch":true,"sender":{"key":"drmicha@warpmail.net","avatar":null},"body":"Junio,\n\nI'm sorry: While checking pu I noticed that I failed to rewrite the\nsubject as intended (I did rewrite the commit message body).\n\"non-committish\" should be \"non-commit\". Feel free to amend or leave as\nis, whatever you prefer.\n\nMichael\n"}]}