git 2.38.0: Change in `git archive` output

brian m. carlson sandals at crustytoothpaste.net
Sun Oct 16 23:21:09 UTC 2022


On 2022-10-16 at 21:57:40, kpcyrd wrote:
> hello,

Hey,

> multiple people in Arch Linux noticed the output of our `git archive`
> command doesn't match the tarball served by github anymore.
> 
> First I suspected an update in our gzip package until I found this line in
> the git 2.38.0 release notes:
> 
> > * Teach "git archive" to (optionally and then by default) avoid
> >   spawning an external "gzip" process when creating ".tar.gz" (and
> >   ".tgz") archives.
> 
> I've then found this commit that could be considered a breaking change in
> `git archive`:
> 
> https://github.com/git/git/commit/4f4be00d302bc52d0d9d5a3d4738bb525066c710
> 
> I don't know if there's some kind of gzip standard that could be used to
> align the git internal gzip implementation with gnu gzip.
> 
> I'm not saying this is necessarily a bug or regression but it makes it
> harder to reproduce github tar balls from a git repository. Just sharing
> what I've debugged. :)

This isn't a bug, because Git doesn't guarantee that archives produced
by different versions will be bit-for-bit identical.  It does guarantee
that an archive of the same commit or tree using the same version of Git
and associated tools running with the same configuration and environment
will be consistent (that is, a given version of Git produces
deterministic archives).

I will also point out that GitHub also doesn't guarantee bit-for-bit
identical archives.  It does currently use git archive under the hood,
but that could change at any moment without notice.

Zip files also contain two sets of timestamps: local and UTC, and
therefore there's an additional element in which archives can differ
depending on the time zone.  In addition, using the export-subst
functionality can result in short object IDs of different lengths
depending on the number of objects in the repository, so archive can
differ for that reason as well.

So it's not the case that you can expect identical archives from Git and
GitHub.  If you need to compute a hash over an archive, you need to
store the archive somewhere (on GitHub, that would be as a release
asset).
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: not available
URL: <http://lists.reproducible-builds.org/pipermail/rb-general/attachments/20221016/3dc9176c/attachment.sig>


More information about the rb-general mailing list