{"thread":{"id":"47153","subject":"Unify annotated and non-annotated tags","startedAt":"2017-11-10T10:59:15Z","lastAt":"2017-12-23T13:34:15Z","messageCount":6,"participants":["anatoly techtonik","Igor Djordjevic","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"332158","messageId":"CAPkN8x+MELCnttE+xptKzYXsYPWqbiE59LABrwNBhFroayc+wQ@mail.gmail.com","threadId":"47153","inReplyTo":null,"subject":"Unify annotated and non-annotated tags","fromName":"anatoly techtonik","fromEmail":"techtonik@gmail.com","sentAt":"2017-11-10T10:58:49Z","receivedAt":"2017-11-10T10:59:15Z","isPatch":false,"sender":{"key":"techtonik@gmail.com","avatar":"https://gravatar.com/avatar/94c82f2698c78dcbc926e549dcfcfae48be4e89c6959287fca063cd461b75af7?d=mp&s=160"},"body":"Hi,\n\nIt is hard to work with Git tags, because on low level hash\nof non-annotated tag is pointing to commit, but hash for\nannotated tag is pointing to tag metadata.\n\nOn low level that means that there is no way to get commit\nhash from tag in a single step. If tag is annotated, you need\nto find and parse ^{} string of show-ref, if not, then look for\nstring without ^{}.\n\nSo, why not just make all tags work the same so that every\ntag has its own hash and you need to dereference it in the\nsame way to get commit hash?\n\nThis way I could get all commit hashes with just:\n\n    git show-ref --tags -d | grep \"\\^{}\"\n\nor abandon ^{} completely and show commit hashes on -d:\n\n    git show-ref --tags --dereference\n\n-- \nanatoly t.\n"},{"id":"332272","messageId":"ec4be1c2-a0cc-cec8-a566-06c11c8abe06@gmail.com","threadId":"47153","inReplyTo":"CAPkN8x+MELCnttE+xptKzYXsYPWqbiE59LABrwNBhFroayc+wQ@mail.gmail.com","subject":"Re: Unify annotated and non-annotated tags","fromName":"Igor Djordjevic","fromEmail":"igor.d.djordjevic@gmail.com","sentAt":"2017-11-11T01:46:39Z","receivedAt":"2017-11-11T01:46:47Z","isPatch":false,"sender":{"key":"igor.d.djordjevic@gmail.com","avatar":null},"body":"Hi Anatoly,\n\nOn 10/11/2017 11:58, anatoly techtonik wrote:\n> It is hard to work with Git tags, because on low level hash\n> of non-annotated tag is pointing to commit, but hash for\n> annotated tag is pointing to tag metadata.\n> \n> On low level that means that there is no way to get commit\n> hash from tag in a single step. If tag is annotated, you need\n> to find and parse ^{} string of show-ref, if not, then look for\n> string without ^{}.\n\nThat is not quite true, as you can always dereference any tag \n(annotated or not) using \"<tag>^0\" notation, see git-rev-parse[1]:\n\n  \"As a special rule, <rev>^0 means the commit itself and is used when \n  <rev> is the object name of a tag object that refers to a commit \n  object.\"\n \n> So, why not just make all tags work the same so that every\n> tag has its own hash and you need to dereference it in the\n> same way to get commit hash?\n> \n> This way I could get all commit hashes with just:\n> \n>     git show-ref --tags -d | grep \"\\^{}\"\n> \n> or abandon ^{} completely and show commit hashes on -d:\n> \n>     git show-ref --tags --dereference\n>\nDepending on what you would _exactly_ like to do, you could get all \ntagged commit hashes like this:\n\n\tgit rev-list --tags --no-walk\n\nNote that each commit will be listed only once, even if more tags \n(annotated or not) point to it.\n\nIf you would like to mimic output of \"git show-ref\", repeating \ncommits for each tag pointing to it and showing full tag name as \nwell, you could do something like this, for example:\n\n\tfor tag in $(git for-each-ref --format=\"%(refname)\" refs/tags)\n\tdo\n\t\tprintf '%s %s\\n' \"$(git rev-parse $tag^0)\" \"$tag\"\n\tdone\n\n\nHope that helps a bit.\n\nRegards, Buga\n\n[1] https://git-scm.com/docs/git-rev-parse#git-rev-parse-emltrevgtemegemHEADv1510em\n"},{"id":"332273","messageId":"xmqqh8u1efh5.fsf@gitster.mtv.corp.google.com","threadId":"47153","inReplyTo":"ec4be1c2-a0cc-cec8-a566-06c11c8abe06@gmail.com","subject":"Re: Unify annotated and non-annotated tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-11T02:06:30Z","receivedAt":"2017-11-11T02:06:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Igor Djordjevic <igor.d.djordjevic@gmail.com> writes:\n\n> If you would like to mimic output of \"git show-ref\", repeating \n> commits for each tag pointing to it and showing full tag name as \n> well, you could do something like this, for example:\n>\n> \tfor tag in $(git for-each-ref --format=\"%(refname)\" refs/tags)\n> \tdo\n> \t\tprintf '%s %s\\n' \"$(git rev-parse $tag^0)\" \"$tag\"\n> \tdone\n>\n>\n> Hope that helps a bit.\n\nIf you use for-each-ref's --format option, you could do something\nlike (pardon a long line):\n\ngit for-each-ref --format='%(if)%(*objectname)%(then)%(*objectname)%(else)%(objectname)%(end) %(refname)' refs/tags\n\nwithout any loop, I would think.\n\n\n"},{"id":"332275","messageId":"59bd5e13-01a5-6c39-04bf-c60cab4004e5@gmail.com","threadId":"47153","inReplyTo":"xmqqh8u1efh5.fsf@gitster.mtv.corp.google.com","subject":"Re: Unify annotated and non-annotated tags","fromName":"Igor Djordjevic","fromEmail":"igor.d.djordjevic@gmail.com","sentAt":"2017-11-11T02:50:46Z","receivedAt":"2017-11-11T02:50:54Z","isPatch":false,"sender":{"key":"igor.d.djordjevic@gmail.com","avatar":null},"body":"On 11/11/2017 03:06, Junio C Hamano wrote:\n\n> Igor Djordjevic <igor.d.djordjevic@gmail.com> writes:\n> \n>> If you would like to mimic output of \"git show-ref\", repeating \n>> commits for each tag pointing to it and showing full tag name as \n>> well, you could do something like this, for example:\n>>\n>> \tfor tag in $(git for-each-ref --format=\"%(refname)\" refs/tags)\n>> \tdo\n>> \t\tprintf '%s %s\\n' \"$(git rev-parse $tag^0)\" \"$tag\"\n>> \tdone\n>>\n>>\n>> Hope that helps a bit.\n> \n> If you use for-each-ref's --format option, you could do something\n> like (pardon a long line):\n> \n> git for-each-ref --format='%(if)%(*objectname)%(then)%(*objectname)%(else)%(objectname)%(end) %(refname)' refs/tags\n> \n> without any loop, I would think.\n\n... and I did have a feeling it should be possible in a single Git \ncommand :P Thanks.\n"},{"id":"333375","messageId":"CAPkN8xJU74N_kYL9f2v_vuk3C3omhYaz7uPMzbanEU=RTEPOYg@mail.gmail.com","threadId":"47153","inReplyTo":"xmqqh8u1efh5.fsf@gitster.mtv.corp.google.com","subject":"Re: Unify annotated and non-annotated tags","fromName":"anatoly techtonik","fromEmail":"techtonik@gmail.com","sentAt":"2017-11-23T07:31:14Z","receivedAt":"2017-11-23T07:31:40Z","isPatch":false,"sender":{"key":"techtonik@gmail.com","avatar":"https://gravatar.com/avatar/94c82f2698c78dcbc926e549dcfcfae48be4e89c6959287fca063cd461b75af7?d=mp&s=160"},"body":"On Sat, Nov 11, 2017 at 5:06 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Igor Djordjevic <igor.d.djordjevic@gmail.com> writes:\n>\n>> If you would like to mimic output of \"git show-ref\", repeating\n>> commits for each tag pointing to it and showing full tag name as\n>> well, you could do something like this, for example:\n>>\n>>       for tag in $(git for-each-ref --format=\"%(refname)\" refs/tags)\n>>       do\n>>               printf '%s %s\\n' \"$(git rev-parse $tag^0)\" \"$tag\"\n>>       done\n>>\n>>\n>> Hope that helps a bit.\n>\n> If you use for-each-ref's --format option, you could do something\n> like (pardon a long line):\n>\n> git for-each-ref --format='%(if)%(*objectname)%(then)%(*objectname)%(else)%(objectname)%(end) %(refname)' refs/tags\n>\n> without any loop, I would think.\n\nThanks. That helps.\n\nSo my proposal is to get rid of non-annotated tags, so to get all\ntags with commits that they point to, one would use:\n\ngit for-each-ref --format='%(*objectname) %(refname)' refs/tags\n\nFor so-called non-annotated tags just leave the message empty.\nI don't see why anyone would need non-annotated tags though.\n-- \nanatoly t.\n"},{"id":"335223","messageId":"CAPkN8x+tFDSum1jqgm6Q+Z2YS9BdGttyruc4rAywqinzbP033g@mail.gmail.com","threadId":"47153","inReplyTo":"xmqqh8u1efh5.fsf@gitster.mtv.corp.google.com","subject":"Re: Unify annotated and non-annotated tags","fromName":"anatoly techtonik","fromEmail":"techtonik@gmail.com","sentAt":"2017-12-23T13:33:48Z","receivedAt":"2017-12-23T13:34:15Z","isPatch":false,"sender":{"key":"techtonik@gmail.com","avatar":"https://gravatar.com/avatar/94c82f2698c78dcbc926e549dcfcfae48be4e89c6959287fca063cd461b75af7?d=mp&s=160"},"body":"On Sat, Nov 11, 2017 at 5:06 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Igor Djordjevic <igor.d.djordjevic@gmail.com> writes:\n>\n>> If you would like to mimic output of \"git show-ref\", repeating\n>> commits for each tag pointing to it and showing full tag name as\n>> well, you could do something like this, for example:\n>>\n>>       for tag in $(git for-each-ref --format=\"%(refname)\" refs/tags)\n>>       do\n>>               printf '%s %s\\n' \"$(git rev-parse $tag^0)\" \"$tag\"\n>>       done\n>>\n>>\n>> Hope that helps a bit.\n>\n> If you use for-each-ref's --format option, you could do something\n> like (pardon a long line):\n>\n> git for-each-ref --format='%(if)%(*objectname)%(then)%(*objectname)%(else)%(objectname)%(end) %(refname)' refs/tags\n>\n> without any loop, I would think.\n\nThis doesn't work with git 1.9.1\nhttps://github.com/rtfd/readthedocs.org/pull/3441#issuecomment-353567756\nWhen it was added? I searched through GitHub and docs, but can't find any\nhistorical records.\n\n-- \nanatoly t.\n"}]}