{"thread":{"id":"51783","subject":"Retrieve version-string on shallow clone","startedAt":"2019-09-01T11:07:43Z","lastAt":"2019-09-02T15:54:43Z","messageCount":3,"participants":["Reino Wijnsma","Philip Oakley","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"381629","messageId":"26d7f32e-2df5-ce39-cd20-8cd82dc8587c@xs4all.nl","threadId":"51783","inReplyTo":null,"subject":"Retrieve version-string on shallow clone","fromName":"Reino Wijnsma","fromEmail":"rwijnsma@xs4all.nl","sentAt":"2019-09-01T11:07:44Z","receivedAt":"2019-09-01T11:07:43Z","isPatch":false,"sender":{"key":"rwijnsma@xs4all.nl","avatar":null},"body":"Hello git@vger.kernel.org,\n\nTwo days ago I started https://github.com/mstorsjo/fdk-aac/issues/107, asking how to retrieve the fdk-aac version-string on a shallow clone.\nMy question was of course not fdk-aac related, so Martin Storsjö suggested I'd try here. It basicly comes down to this:\n\ngit clone https://github.com/mstorsjo/fdk-aac.git\n[...]\n\ngit describe --tags\nv2.0.0-185-gcc5c85d\n\ngit clone --depth 1 https://github.com/mstorsjo/fdk-aac.git\n\ngit describe --tags\nfatal: No names found, cannot describe anything.\n\nThe tags get lost while doing a shallow clone.\nI'm not an expert git user, so I was wondering if anyone could tell what my options are here.\nI'd figure one of these options would be to clone everything from tag v2.0.0 onward, but if so how would I do that?\nAs another option I was thinking; maybe it's possible to do git describe --tags on the remote repo?\n\nThanks!\n\n-- Reino\n"},{"id":"381654","messageId":"26794b96-8627-0d73-c548-91b0ea7fde83@iee.email","threadId":"51783","inReplyTo":"26d7f32e-2df5-ce39-cd20-8cd82dc8587c@xs4all.nl","subject":"Re: Retrieve version-string on shallow clone","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2019-09-02T15:52:19Z","receivedAt":"2019-09-02T15:52:21Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi Reino\n\nOn 01/09/2019 12:07, Reino Wijnsma wrote:\n> Hello git@vger.kernel.org,\n>\n> Two days ago I started https://github.com/mstorsjo/fdk-aac/issues/107, asking how to retrieve the fdk-aac version-string on a shallow clone.\n> My question was of course not fdk-aac related, so Martin Storsjö suggested I'd try here. It basicly comes down to this:\n>\n> git clone https://github.com/mstorsjo/fdk-aac.git\n> [...]\n>\n> git describe --tags\n> v2.0.0-185-gcc5c85d\n>\n> git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git\n>\n> git describe --tags\n> fatal: No names found, cannot describe anything.\n>\n> The tags get lost while doing a shallow clone.\n> I'm not an expert git user, so I was wondering if anyone could tell what my options are here.\n> I'd figure one of these options would be to clone everything from tag v2.0.0 onward, but if so how would I do that?\n> As another option I was thinking; maybe it's possible to do git describe --tags on the remote repo?\n>\nThis is most likely a mental model problem.\n\nIf you only have a depth = 1 level clone, then there is no history \navailable locally to use from which to describe almost anything.\nEven if you had all the tags (without the actual commits they tagged) \nyou still don't have that history upon which to describe them.\n\nStart by getting a bit more history depth, then see if you need to fetch \nsome of the tags (or at least any specific tags of interest).\n\nPhilip\n\n"},{"id":"381655","messageId":"20190902155440.GE18593@sigill.intra.peff.net","threadId":"51783","inReplyTo":"26d7f32e-2df5-ce39-cd20-8cd82dc8587c@xs4all.nl","subject":"Re: Retrieve version-string on shallow clone","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-09-02T15:54:40Z","receivedAt":"2019-09-02T15:54:43Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Sep 01, 2019 at 01:07:44PM +0200, Reino Wijnsma wrote:\n\n> git clone https://github.com/mstorsjo/fdk-aac.git\n> [...]\n> \n> git describe --tags\n> v2.0.0-185-gcc5c85d\n> \n> git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git\n> \n> git describe --tags\n> fatal: No names found, cannot describe anything.\n> \n> The tags get lost while doing a shallow clone.\n\nRight. As noted elsewhere in the thread, this is the expected behavior\nof Git. But what you want is perfectly reasonable; there's just not a\ngood way to do it yet.\n\n> I'd figure one of these options would be to clone everything from tag\n> v2.0.0 onward, but if so how would I do that?\n\nI don't think there's a good way to do this. But I also think it's not\nquite what you want, as you'd end up transferring a lot of extra data\n(and deeper shallow fetches load the server more, as we can't use\nreachability bitmaps, and we have to do extra on-the-fly delta\ncompression).\n\n> As another option I was thinking; maybe it's possible to do git\n> describe --tags on the remote repo?\n\nThis seems like it's more directly what you want, and doesn't have a lot\nof downsides. There's no way to trigger this within Git's protocols. If\nit's an ssh server you control, you can of course run git-describe\nyourself on the server. For a hosting site like GitHub, you'd need\nsupport from the host's non-Git API. I don't _think_ anything like that\nexists right now in GitHub's API, though.\n\n-Peff\n"}]}