git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Retrieve version-string on shallow clone
@ 2019-09-01 11:07 Reino Wijnsma
  2019-09-02 15:52 ` Philip Oakley
  2019-09-02 15:54 ` Jeff King
  0 siblings, 2 replies; 5+ messages in thread
From: Reino Wijnsma @ 2019-09-01 11:07 UTC (permalink / raw)
  To: git

Hello git@vger.kernel.org,

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.
My question was of course not fdk-aac related, so Martin Storsjö suggested I'd try here. It basicly comes down to this:

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.
I'm not an expert git user, so I was wondering if anyone could tell what my options are here.
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?
As another option I was thinking; maybe it's possible to do git describe --tags on the remote repo?

Thanks!

-- Reino

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Retrieve version-string on shallow clone
@ 2019-09-02 14:08 Giuseppe Crinò
  2019-09-03 21:30 ` Reino Wijnsma
  0 siblings, 1 reply; 5+ messages in thread
From: Giuseppe Crinò @ 2019-09-02 14:08 UTC (permalink / raw)
  To: Reino Wijnsma; +Cc: git

> 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?
> As another option I was thinking; maybe it's possible to do git describe
> --tags on the remote repo?


To my understanding both questions are solved by

* https://stackoverflow.com/a/47720414/2219670
* https://stackoverflow.com/a/12704727/2219670

It seems to me that's the expected behaviour of git

-Giuseppe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Retrieve version-string on shallow clone
  2019-09-01 11:07 Retrieve version-string on shallow clone Reino Wijnsma
@ 2019-09-02 15:52 ` Philip Oakley
  2019-09-02 15:54 ` Jeff King
  1 sibling, 0 replies; 5+ messages in thread
From: Philip Oakley @ 2019-09-02 15:52 UTC (permalink / raw)
  To: Reino Wijnsma, git

Hi Reino

On 01/09/2019 12:07, Reino Wijnsma wrote:
> Hello git@vger.kernel.org,
>
> 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.
> My question was of course not fdk-aac related, so Martin Storsjö suggested I'd try here. It basicly comes down to this:
>
> 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.
> I'm not an expert git user, so I was wondering if anyone could tell what my options are here.
> 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?
> As another option I was thinking; maybe it's possible to do git describe --tags on the remote repo?
>
This is most likely a mental model problem.

If you only have a depth = 1 level clone, then there is no history 
available locally to use from which to describe almost anything.
Even if you had all the tags (without the actual commits they tagged) 
you still don't have that history upon which to describe them.

Start by getting a bit more history depth, then see if you need to fetch 
some of the tags (or at least any specific tags of interest).

Philip


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Retrieve version-string on shallow clone
  2019-09-01 11:07 Retrieve version-string on shallow clone Reino Wijnsma
  2019-09-02 15:52 ` Philip Oakley
@ 2019-09-02 15:54 ` Jeff King
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff King @ 2019-09-02 15:54 UTC (permalink / raw)
  To: Reino Wijnsma; +Cc: git

On Sun, Sep 01, 2019 at 01:07:44PM +0200, Reino Wijnsma wrote:

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Retrieve version-string on shallow clone
  2019-09-02 14:08 Giuseppe Crinò
@ 2019-09-03 21:30 ` Reino Wijnsma
  0 siblings, 0 replies; 5+ messages in thread
From: Reino Wijnsma @ 2019-09-03 21:30 UTC (permalink / raw)
  Cc: git

Hello Giuseppe, Philip and Jeff,

On 2019-09-02T16:08:54+0200, Giuseppe Crinò <giuscri@gmail.com> wrote:
> To my understanding both questions are solved by
> * https://stackoverflow.com/a/47720414/2219670
> * https://stackoverflow.com/a/12704727/2219670
On 2019-09-02T17:52:19+0200, Philip Oakley <philipoakley@iee.email> wrote:
> Start by getting a bit more history depth, then see if you need to fetch some of the tags (or at least any specific tags of interest).
On 2019-09-02T17:54:40+0200, Jeff King <peff@peff.net> wrote:
> But what you want is perfectly reasonable; there's just not a good way to do it yet.
> [...] There's no way to trigger this within Git's protocols.

I never thought this would be impossible, or at least very hard, to accomplish.

git ls-remote --tags --refs https://github.com/mstorsjo/fdk-aac.git
94f9d5ca2077262e838fbc8ed111da03be5389d5        refs/tags/v0.1.0
1551d17717e42e7c295da0a682ae299791ee87c7        refs/tags/v0.1.1
fa3b711888883ccb19337c0ca76aea7dd85af9c8        refs/tags/v0.1.2
db7189736b49d27225eea917fcf1581b5228c830        refs/tags/v0.1.3
d17a2ebc6d8f593ffbefacaea1bfa6d6a81356a1        refs/tags/v0.1.4
a3f40d8d974f1aacde95e0996739941bde8f5e98        refs/tags/v0.1.5
c98ba983b0cd6905a52ab34222418ca7a5ff2260        refs/tags/v0.1.6
e35d91ddd8d41515594b7fd51b6bae1b17fee530        refs/tags/v2.0.0

git ls-remote --tags --refs https://github.com/mstorsjo/fdk-aac.git | tail -n1 | cut -d/ -f3-
v2.0.0

Regrettably the remote repo doesn't include the entire version-string with revision and commit-hash (v2.0.0-185-gcc5c85d).

Having to download fdk-aac's complete commit-history (9.38MB) isn't yet all too bad. FFmpeg (https://github.com/FFmpeg/FFmpeg.git) its commit-history on the other hand is a whopping 239MB (as opposed to 15.7MB for --depth 1) and perhaps a better example here!
I'm compiling and distributing FFmpeg executables. When I compile FFmpeg I'm not interested in its entire commit-history at that moment. I'm only interested in the checked out source files and the version-string (4.3-dev-327-g83e0b71 for instance).

Since this doesn't appear to be possible at the moment, I'll let this rest.
Thank you all for your replies.

-- Reino

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-03 21:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-01 11:07 Retrieve version-string on shallow clone Reino Wijnsma
2019-09-02 15:52 ` Philip Oakley
2019-09-02 15:54 ` Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2019-09-02 14:08 Giuseppe Crinò
2019-09-03 21:30 ` Reino Wijnsma

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).