{"thread":{"id":"41896","subject":"Trouble with cat-file on tags","startedAt":"2016-04-01T09:26:41Z","lastAt":"2016-04-01T12:26:31Z","messageCount":4,"participants":["Sebastian Schuberth","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"282435","messageId":"ndlesh$dj1$1@ger.gmane.org","threadId":"41896","inReplyTo":null,"subject":"Trouble with cat-file on tags","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2016-04-01T09:26:41Z","receivedAt":"2016-04-01T09:26:41Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"Hi,\n\nI was trying to use cat-file to get the hash of a tag object (not the hash of the commit object the tag points to), and I'm running into some issues. At the example of a cloned gerry [1] repository:\n\n---8<---\n$ git tag test-tag\n\n$ git tag -l\ntest-tag\nv0.0.3\nv0.0.4\nv0.1.0\nv0.1.1\nv0.1.2\n\n$ git cat-file tag refs/tags/test-tag\nfatal: git cat-file refs/tags/test-tag: bad file\n---8<---\n\nSo for a newly created local tag, cat-file does not seem to work. However:\n\n---8<---\n$ git cat-file tag refs/tags/v0.1.2\nobject 91b0d21eba039e5ba0a90104c9c485735576dcbf\ntype commit\ntag v0.1.2\ntagger Travis Truman <travis_truman@cable.comcast.com> 1452693317 -0500\n\nVersion 0.1.2\n---8<---\n\nFor an existing tag, git-file suddenly *does* seem to work, although I'm puzzled why I'm getting info on the commit object here. I thought \"cat-file tag\" should explicitly make \"cat-file\" list information about the tag object itself, not about the commit object the tag points to.\n\nThoughts?\n\n[1] https://github.com/trumant/gerry\n\nRegards,\nSebastian\n"},{"id":"282436","messageId":"ndlf7q$ghe$1@ger.gmane.org","threadId":"41896","inReplyTo":"ndlesh$dj1$1@ger.gmane.org","subject":"Re: Trouble with cat-file on tags","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2016-04-01T09:32:42Z","receivedAt":"2016-04-01T09:32:42Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On 4/1/2016 11:26, Sebastian Schuberth wrote:\n\n> ---8<---\n> $ git tag test-tag\n>\n> $ git tag -l\n> test-tag\n> v0.0.3\n> v0.0.4\n> v0.1.0\n> v0.1.1\n> v0.1.2\n>\n> $ git cat-file tag refs/tags/test-tag\n> fatal: git cat-file refs/tags/test-tag: bad file\n> ---8<---\n\nAlright, I just found out why that is: Lighweight tags are not stored as \nGit objects. As soon as I make it an annoted tag by specifying a \nmessage, \"cat-file tag\" do esnot display a fatal error anymore.\n\nHowever, I still get information about the commit oject iintsead of the \ntag object. Is this expected?\n\nRegards,\nSebastian\n"},{"id":"282437","messageId":"ndlgsc$ed7$1@ger.gmane.org","threadId":"41896","inReplyTo":"ndlf7q$ghe$1@ger.gmane.org","subject":"Re: Trouble with cat-file on tags","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2016-04-01T10:00:44Z","receivedAt":"2016-04-01T10:00:44Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On 4/1/2016 11:32, Sebastian Schuberth wrote:\n\n> However, I still get information about the commit oject iintsead of the\n> tag object. Is this expected?\n\nSolved this one, too: Yes it is. I was misreading the docs:\n\n\"If <type> is specified, the raw (though uncompressed) contents of the \n<object> will be returned.\"\n\nThis means\n\n$ git cat-file tag refs/tags/v0.1.2\n\ndisplays the *contents* of the tag, not the tag itself. Which leads me \nto the next question: For a given name of an annotated tag, how to get \nthe hash of the tag object? The solution I found for now:\n\n$ git show-ref --tags -- v0.1.2\n92b67e2b0626519ef8cd4e9cacb2bdafba6d53f0 refs/tags/v0.1.2\n\nRegards,\nSebastian\n"},{"id":"282454","messageId":"20160401122631.GA12019@sigill.intra.peff.net","threadId":"41896","inReplyTo":"ndlgsc$ed7$1@ger.gmane.org","subject":"Re: Trouble with cat-file on tags","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-04-01T12:26:31Z","receivedAt":"2016-04-01T12:26:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Apr 01, 2016 at 12:00:44PM +0200, Sebastian Schuberth wrote:\n\n> This means\n> \n> $ git cat-file tag refs/tags/v0.1.2\n> \n> displays the *contents* of the tag, not the tag itself.\n\nRight. `cat-file` is about looking at object content.\n\n> Which leads me to\n> the next question: For a given name of an annotated tag, how to get the hash\n> of the tag object? The solution I found for now:\n> \n> $ git show-ref --tags -- v0.1.2\n> 92b67e2b0626519ef8cd4e9cacb2bdafba6d53f0 refs/tags/v0.1.2\n\nHere you just want to resolve the ref, without looking at the object.\nThe canonical way is:\n\n  git rev-parse --verify v0.1.2\n\nYou can also use that to peel the tag to a commit, or a commit to a tree\n(e.g., with \"v0.1.2^{commit}\").\n\n-Peff\n"}]}