{"thread":{"id":"53618","subject":"name-ref on annotated-tags is null terminated, but lightweight tags arent","startedAt":"2020-06-05T16:51:13Z","lastAt":"2020-06-05T17:59:17Z","messageCount":4,"participants":["Max Resnick","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"399187","messageId":"20200605165109.jr6mjl6xz7upofdy@forgemax.local","threadId":"53618","inReplyTo":null,"subject":"name-ref on annotated-tags is null terminated, but lightweight tags arent","fromName":"Max Resnick","fromEmail":"max.resnick@forgerock.com","sentAt":"2020-06-05T16:51:09Z","receivedAt":"2020-06-05T16:51:13Z","isPatch":false,"sender":{"key":"max.resnick@forgerock.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nI was using name-rev to resolve a commits tag name. Annotated tags seem\nto have a null termination and lightweight tags dont.\n```\n/tmp\n❯ git clone https://github.com/maxres-fr/null-termination-issue.git\nCloning into 'null-termination-issue'...\nremote: Enumerating objects: 10, done.\nremote: Counting objects: 100% (10/10), done.\nremote: Compressing objects: 100% (4/4), done.\nremote: Total 10 (delta 0), reused 10 (delta 0), pack-reused 0\nUnpacking objects: 100% (10/10), 757 bytes | 189.00 KiB/s, done.\n\n/tmp\n❯ cd null-termination-issue\n\n/tmp/null-termination-issue on  master\n❯ git pull --tags\nAlready up to date.\n\n/tmp/null-termination-issue on  master\n❯ git tag --list\n\n/tmp/null-termination-issue on  master\n❯ git name-rev --tag --name-only\n38bdebc9107cab4ab3718d0581632702e74d9209\nannotated-tag^0\n\n/tmp/null-termination-issue on  master\n❯ git name-rev --tag --name-only\na340894d3ee655ae6c336a85b42d2215d52609e3\nlightweight-tag\n```\n\nWhat did you expect to happen? (Expected behavior)\n\n`git name-rev --tag --name-only ANNOTATED-COMMIT-ID` to return the name\nwithout null termination\n\nWhat happened instead? (Actual behavior)\n\n`git name-rev --tag --name-only ANNOTATED-COMMIT-ID` returns the name\nbut it's null terminated\n\nWhat's different between what you expected and what actually happened?\n\na null control character exists.\n\nAnything else you want to add:\n\nI tried this with the following git versions:\n\n2.11, 2.23, 2.26, 2.27. I've also been able to reproduce on MacOS.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n[System Info]\ngit version:\ngit version 2.27.0.rc0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nuname: Linux 5.6.0-1-amd64 #1 SMP Debian 5.6.7-1 (2020-04-29) x86_64\ncompiler info: gnuc: 9.3\nlibc info: glibc: 2.30\n\n\n[Enabled Hooks]\n\n"},{"id":"399188","messageId":"xmqqa71ho34p.fsf@gitster.c.googlers.com","threadId":"53618","inReplyTo":"20200605165109.jr6mjl6xz7upofdy@forgemax.local","subject":"Re: name-ref on annotated-tags is null terminated, but lightweight tags arent","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-05T17:04:38Z","receivedAt":"2020-06-05T17:04:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Max Resnick <max.resnick@forgerock.com> writes:\n\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> I was using name-rev to resolve a commits tag name. Annotated tags seem\n> to have a null termination and lightweight tags dont.\n\n> ❯ git name-rev --tag --name-only\n> 38bdebc9107cab4ab3718d0581632702e74d9209\n> annotated-tag^0\n>\n> /tmp/null-termination-issue on  master\n> ❯ git name-rev --tag --name-only\n> a340894d3ee655ae6c336a85b42d2215d52609e3\n> lightweight-tag\n\nPresumably the long hexadecimal are supposed to be on the same line\nas the \"name-rev\" command itself?\n\nThere is nothing broken in the above output.  The anotated tag\n(annotated-tag in your example) is an object that merely points at\nanother object (in which case, the object whose name is 38bdebc9,\nwhich I guess would be a commit) and it itself has an object name\ndifferent from 38bdebc9.  The suffix \"^0\" (which has nothing to do\nwith null-termination) means \"I do not mean the tag object itself,\nbut the object that is pointed by it\".\n\nOn the other hand, your lightweight-tag is directly pointing at the\nobject a340894d, so saying \"lightweight-tag\" is sufficient, as there\nis no extra layer of indirection (i.e. a tag object) involved.\n\nHope it helps.\n"},{"id":"399189","messageId":"20200605171607.rducvc4xretxacn5@forgemax.local","threadId":"53618","inReplyTo":"xmqqa71ho34p.fsf@gitster.c.googlers.com","subject":"Re: name-ref on annotated-tags is null terminated, but lightweight tags arent","fromName":"Max Resnick","fromEmail":"max.resnick@forgerock.com","sentAt":"2020-06-05T17:16:07Z","receivedAt":"2020-06-05T17:16:10Z","isPatch":false,"sender":{"key":"max.resnick@forgerock.com","avatar":null},"body":"\nThanks Junio for the quick response.\n\n> Presumably the long hexadecimal are supposed to be on the same line \n> as the \"name-rev\" command itself?                                   \n\nYes, sorry I didn't see that the formatting was broken before I sent.\n\n> The suffix \"^0\" (which has nothing to do \n> with null-termination) means \"I do not mean the tag object itself, \n> but the object that is pointed by it\".                             \n\nOk, thanks. I need to unpack that a bit more. I tried to dig around in\nthe man to see if there was indication if that's what was expected but\ndidn't find anything at less for name-rev.\n\n\n\nOn 20/06/05 10:04AM, Junio C Hamano wrote:\n> Max Resnick <max.resnick@forgerock.com> writes:\n> \n> > What did you do before the bug happened? (Steps to reproduce your issue)\n> > I was using name-rev to resolve a commits tag name. Annotated tags seem\n> > to have a null termination and lightweight tags dont.\n> \n> > ❯ git name-rev --tag --name-only\n> > 38bdebc9107cab4ab3718d0581632702e74d9209\n> > annotated-tag^0\n> >\n> > /tmp/null-termination-issue on  master\n> > ❯ git name-rev --tag --name-only\n> > a340894d3ee655ae6c336a85b42d2215d52609e3\n> > lightweight-tag\n> \n> Presumably the long hexadecimal are supposed to be on the same line\n> as the \"name-rev\" command itself?\n> \n> There is nothing broken in the above output.  The anotated tag\n> (annotated-tag in your example) is an object that merely points at\n> another object (in which case, the object whose name is 38bdebc9,\n> which I guess would be a commit) and it itself has an object name\n> different from 38bdebc9.  The suffix \"^0\" (which has nothing to do\n> with null-termination) means \"I do not mean the tag object itself,\n> but the object that is pointed by it\".\n> \n> On the other hand, your lightweight-tag is directly pointing at the\n> object a340894d, so saying \"lightweight-tag\" is sufficient, as there\n> is no extra layer of indirection (i.e. a tag object) involved.\n> \n> Hope it helps.\n"},{"id":"399190","messageId":"xmqq3679o0lr.fsf@gitster.c.googlers.com","threadId":"53618","inReplyTo":"20200605171607.rducvc4xretxacn5@forgemax.local","subject":"Re: name-ref on annotated-tags is null terminated, but lightweight tags arent","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-05T17:59:12Z","receivedAt":"2020-06-05T17:59:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Max Resnick <max.resnick@forgerock.com> writes:\n\n> Thanks Junio for the quick response.\n>\n>> Presumably the long hexadecimal are supposed to be on the same line \n>> as the \"name-rev\" command itself?                                   \n>\n> Yes, sorry I didn't see that the formatting was broken before I sent.\n>\n>> The suffix \"^0\" (which has nothing to do \n>> with null-termination) means \"I do not mean the tag object itself, \n>> but the object that is pointed by it\".                             \n>\n> Ok, thanks. I need to unpack that a bit more. I tried to dig around in\n> the man to see if there was indication if that's what was expected but\n> didn't find anything at less for name-rev.\n\n\"git help revisions\" has this, which may help.\n\n       <rev>^[<n>], e.g. HEAD^, v1.5.1^0\n                  A suffix ^ to a revision parameter means the first\n                  parent of that commit object.  ^<n> means the\n                  <n>th parent (i.e.  <rev>^ is equivalent to\n                  <rev>^1).  As a special rule, <rev>^0 means the\n                  commit itself and is used when <rev> is the object\n                  name of a tag object that refers to a commit\n                  object.\n\nThe help text in \"git help name-rev\" only says \"names suitable for\nhuman digestion\", which may want to be clarified.\n\nThanks.\n"}]}