Re: Retrieve version-string on shallow clone
- From
Jeff King <peff@peff.net>
- Date
- Sep 2, 2019, 15:54 UTC
- Message-ID
- <20190902155440.GE18593@sigill.intra.peff.net>
- In-Reply-To
- <26d7f32e-2df5-ce39-cd20-8cd82dc8587c@xs4all.nl>
On Sun, Sep 01, 2019 at 01:07:44PM +0200, Reino Wijnsma wrote:
Show 12 quoted lines
> git clone https://github.com/mstorsjo/fdk-aac.git > [...] > > git describe --tags > v2.0.0-185-gcc5c85d > > git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git > > git describe --tags > fatal: No names found, cannot describe anything. > > The tags get lost while doing a shallow clone.
Right. As noted elsewhere in the thread, this is the expected behavior of Git. But what you want is perfectly reasonable; there's just not a good way to do it yet.
> 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?
I don't think there's a good way to do this. But I also think it's not quite what you want, as you'd end up transferring a lot of extra data (and deeper shallow fetches load the server more, as we can't use reachability bitmaps, and we have to do extra on-the-fly delta compression).
> As another option I was thinking; maybe it's possible to do git > describe --tags on the remote repo?
This seems like it's more directly what you want, and doesn't have a lot of downsides. There's no way to trigger this within Git's protocols. If it's an ssh server you control, you can of course run git-describe yourself on the server. For a hosting site like GitHub, you'd need support from the host's non-Git API. I don't _think_ anything like that exists right now in GitHub's API, though.
-Peff