{"thread":{"id":"47357","subject":"\"git describe\" documentation and behavior mismatch","startedAt":"2017-11-30T18:47:35Z","lastAt":"2017-12-15T19:25:47Z","messageCount":6,"participants":["Daniel Knittl-Frank","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"333863","messageId":"CACx-yZ10GiDT=dDeF1EUtM_K4nGd414SDfxLRqGWyXt0ub02Gg@mail.gmail.com","threadId":"47357","inReplyTo":null,"subject":"\"git describe\" documentation and behavior mismatch","fromName":"Daniel Knittl-Frank","fromEmail":"knittl89@googlemail.com","sentAt":"2017-11-30T18:47:08Z","receivedAt":"2017-11-30T18:47:35Z","isPatch":false,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"Hi Git list,\n\nthe help page/manpage of the git describe command has an example with\nthe --all flag which should prepend the ref namespace (tags/ or\nheads/):\n\n> With --all, the command can use branch heads as references, so the output shows the reference path as well:\n>\n>          [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2\n>          tags/v1.0.0-21-g975b\n>\n>          [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^\n>          heads/lt/describe-7-g975b\n\nRunning the above commands in the git.git repository yields a different result:\n\n>     $ git describe --all --abbrev=4 v1.0.5^2\n>     v1.0.0-21-g975b3\n\nNo \"reference path\" to see. It is however shown, when the output is a\nbranch name:\n\n>     $ git describe --all --abbrev=4 origin/next\n>     heads/next\n\nIs this expected behavior? IOW is the documentation outdated or is the\ngit describe command misbehaving?\n\nThanks,\nDaniel\n\n-- \ntyped with http://neo-layout.org\n"},{"id":"333864","messageId":"CACx-yZ1dJuUj5mD6WE8yqZCPMK8q-yaJ0GKUSppZ7uDkqvJ5UA@mail.gmail.com","threadId":"47357","inReplyTo":"CACx-yZ10GiDT=dDeF1EUtM_K4nGd414SDfxLRqGWyXt0ub02Gg@mail.gmail.com","subject":"Re: \"git describe\" documentation and behavior mismatch","fromName":"Daniel Knittl-Frank","fromEmail":"knittl89@googlemail.com","sentAt":"2017-11-30T19:26:26Z","receivedAt":"2017-11-30T19:26:52Z","isPatch":false,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"On Thu, Nov 30, 2017 at 7:47 PM, Daniel Knittl-Frank\n<knittl89@googlemail.com> wrote:\n> […]\n>\n> Running the above commands in the git.git repository yields a different result:\n>\n>>     $ git describe --all --abbrev=4 v1.0.5^2\n>>     v1.0.0-21-g975b3\n>\n> No \"reference path\" to see. It is however shown, when the output is a\n> branch name:\n>\n>>     $ git describe --all --abbrev=4 origin/next\n>>     heads/next\n>\n> Is this expected behavior? IOW is the documentation outdated or is the\n> git describe command misbehaving?\n\nBisecting history goes as far back as Feb 2008: commit\n212945d4a85dfa172ea55ec73b1d830ef2d8582f\n\n> Teach git-describe to verify annotated tag names before output\n\nThe warning mentioned in the commit message has since been gone. So I\nguess the documentation is outdated? Nobody has complained for the\npast 9 years, so we could call this a \"feature\" :)\n\nAn interesting fact (and intentional behavior?) is that describing a\ncommit with only a lightweight tag will properly display the tags/\nprefix. I assume this is because the annotated tags only store the\ntagname without any ref namespace, which is then picked up by git\ndescribe and displayed.\n\nI will try to come up with a patch for the man page.\n\nDaniel\n\n-- \ntyped with http://neo-layout.org\n"},{"id":"333987","messageId":"xmqqefocjrp2.fsf@gitster.mtv.corp.google.com","threadId":"47357","inReplyTo":"CACx-yZ1dJuUj5mD6WE8yqZCPMK8q-yaJ0GKUSppZ7uDkqvJ5UA@mail.gmail.com","subject":"Re: \"git describe\" documentation and behavior mismatch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-03T05:39:21Z","receivedAt":"2017-12-03T05:39:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Knittl-Frank <knittl89@googlemail.com> writes:\n\n> An interesting fact (and intentional behavior?) is that describing a\n> commit with only a lightweight tag will properly display the tags/\n> prefix. I assume this is because the annotated tags only store the\n> tagname without any ref namespace, which is then picked up by git\n> describe and displayed.\n\nI suspect that \"see if the name recorded in the tag object matches\nthe name of the ref that stores the tag after refs/tags/\" code *is*\nnot just verifying what it claims to (which may be good) but also\nunintentionally affecting the output (i.e. \"--all\" promises that the\nprefix tags/ should be shown).  Perhaps the code needs to be fixed\nif that is the case.\n\n\n"},{"id":"334614","messageId":"CACx-yZ1DGz2z6qqAX=pzeExT689y0sON+wVDaocdWk75a5SOxA@mail.gmail.com","threadId":"47357","inReplyTo":"xmqqefocjrp2.fsf@gitster.mtv.corp.google.com","subject":"Re: \"git describe\" documentation and behavior mismatch","fromName":"Daniel Knittl-Frank","fromEmail":"knittl89@googlemail.com","sentAt":"2017-12-11T18:34:42Z","receivedAt":"2017-12-11T18:35:08Z","isPatch":false,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"On Sun, Dec 3, 2017 at 6:39 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> I suspect that \"see if the name recorded in the tag object matches\n> the name of the ref that stores the tag after refs/tags/\" code *is*\n> not just verifying what it claims to (which may be good) but also\n> unintentionally affecting the output (i.e. \"--all\" promises that the\n> prefix tags/ should be shown).  Perhaps the code needs to be fixed\n> if that is the case.\n\nWhat is the course of action then? I wrote up a really dumb 2-line\npatch which simply checks if --all was specified and prepends the\noutput with \"tags/\".\n\nGood enough? Should we instead update the documentation? Still not\nsure, what the behavior _should_ be in the case of annotated tags with\nembedded names.\n\n-- >8 --\n\nFrom 7243d700aad280b11e647e04ade027c412dde54c Mon Sep 17 00:00:00 2001\nFrom: Daniel Knittl-Frank <knittl89+git@googlemail.com>\nDate: Mon, 11 Dec 2017 19:24:54 +0100\nSubject: [PATCH] Prepend \"tags/\" when describing tags with embedded name\n\nSigned-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n---\n builtin/describe.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex e14e162ef6..54aaf30562 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -272,6 +272,8 @@ static void display_name(struct commit_name *n)\n     }\n\n     if (n->tag)\n+        if (all)\n+            printf(\"tags/\");\n         printf(\"%s\", n->tag->tag);\n     else\n         printf(\"%s\", n->path);\n-- \n2.15.GIT\n\n\n\n-- \ntyped with http://neo-layout.org\n"},{"id":"334615","messageId":"CACx-yZ3FxqFvXgM-V0stODcyAdCoO83s=WwyZ2OLiJON6qqvkA@mail.gmail.com","threadId":"47357","inReplyTo":"CACx-yZ1DGz2z6qqAX=pzeExT689y0sON+wVDaocdWk75a5SOxA@mail.gmail.com","subject":"Re: \"git describe\" documentation and behavior mismatch","fromName":"Daniel Knittl-Frank","fromEmail":"knittl89@googlemail.com","sentAt":"2017-12-11T18:37:53Z","receivedAt":"2017-12-11T18:38:19Z","isPatch":false,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"Forget the above patch. I should compile my code after refactoring ...\n\nHere is the fixed version.\n\n-- >8 --\n\nFrom 8203bd0ad5baab7024ebff597c9f35a0250d09ff Mon Sep 17 00:00:00 2001\nFrom: Daniel Knittl-Frank <knittl89+git@googlemail.com>\nDate: Mon, 11 Dec 2017 19:24:54 +0100\nSubject: [PATCH] Prepend \"tags/\" when describing tags with embedded name\n\nSigned-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n---\n builtin/describe.c | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex e14e162ef6..9da6d85ea3 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -271,10 +271,13 @@ static void display_name(struct commit_name *n)\n         n->name_checked = 1;\n     }\n\n-    if (n->tag)\n+    if (n->tag) {\n+        if (all)\n+            printf(\"tags/\");\n         printf(\"%s\", n->tag->tag);\n-    else\n+    } else {\n         printf(\"%s\", n->path);\n+    }\n }\n\n static void show_suffix(int depth, const struct object_id *oid)\n-- \n2.15.GIT\n\n-- \ntyped with http://neo-layout.org\n"},{"id":"334905","messageId":"xmqqwp1npzd8.fsf@gitster.mtv.corp.google.com","threadId":"47357","inReplyTo":"CACx-yZ3FxqFvXgM-V0stODcyAdCoO83s=WwyZ2OLiJON6qqvkA@mail.gmail.com","subject":"Re: \"git describe\" documentation and behavior mismatch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-15T19:25:39Z","receivedAt":"2017-12-15T19:25:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Knittl-Frank <knittl89@googlemail.com> writes:\n\n> Forget the above patch. I should compile my code after refactoring ...\n>\n> Here is the fixed version.\n>\n> -- >8 --\n>\n> From 8203bd0ad5baab7024ebff597c9f35a0250d09ff Mon Sep 17 00:00:00 2001\n> From: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n> Date: Mon, 11 Dec 2017 19:24:54 +0100\n> Subject: [PATCH] Prepend \"tags/\" when describing tags with embedded name\n>\n> Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n> ---\n>  builtin/describe.c | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n\nI think the code makes sense, but it won't be understandable by\nthose who do not know what you discussed in the original thread.\n\nA proper commit log message, with a new test or two in t6120, would\nbe an appropriate way to fix that.\n\nCare to follow through, along the lines in\nDocumentation/SubmittingPatches?\n\nThanks.\n\n> diff --git a/builtin/describe.c b/builtin/describe.c\n> index e14e162ef6..9da6d85ea3 100644\n> --- a/builtin/describe.c\n> +++ b/builtin/describe.c\n> @@ -271,10 +271,13 @@ static void display_name(struct commit_name *n)\n>          n->name_checked = 1;\n>      }\n>\n> -    if (n->tag)\n> +    if (n->tag) {\n> +        if (all)\n> +            printf(\"tags/\");\n>          printf(\"%s\", n->tag->tag);\n> -    else\n> +    } else {\n>          printf(\"%s\", n->path);\n> +    }\n>  }\n>\n>  static void show_suffix(int depth, const struct object_id *oid)\n> -- \n> 2.15.GIT\n"}]}