apache / buildstream-plugins

BuildStream plugins
https://buildstream.build/
Apache License 2.0
4 stars 5 forks source link

git plugin's track-tags option isn't enough for gnulib's git-version-gen #4

Open abderrahim opened 3 years ago

abderrahim commented 3 years ago

When the track-tags option of the git plugin is enabled, it generates a slimmed-down .git directory enough for git describe and git log to succeed.

However gnulib's git-version-gen script relies on git log . which doesn't work, and returns an error like

fatal: unable to read tree 1bdaa2ce628b458ab6a7c9e03023a9aed221cf75
nanonyme commented 2 years ago

Looks like simply writing .tarball-version is enough to convince git-version-gen to do nothing.

nanonyme commented 2 years ago

Turns out there are bootstrap commands where this workaround doesn't really work.

nanonyme commented 2 years ago

Reading https://github.com/coreutils/gnulib/blob/master/build-aux/git-version-gen#L157 it looks like it's mostly only using this to test that there is a commit. Git log doesn't need to show more things than the single commit.

abderrahim commented 2 years ago

Essentially what I noticed (and implemented for https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/merge_requests/9009) is that to get every corner case covered (mainly git log -1, git log -1 ., git describe --dirty), you need to add all tree objects. Basically a shallow clone until the tag, with all blob objects removed (and with loose objects for reproducibility)