scm.sh: Honor -f in git, derive release hash from VCS file ids #110
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/fix/20260916-scm-sh-honor-f-in-git-derive-release-hash-from-vcs-file-ids"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR makes the release hash depend only on the committed tree. The old scheme md5summed the working tree, and
md5sumfollows symlinks, so a project whose tree links to files outside the repo, such asjw-ws's pi config, hashed differently depending on which targets happened to exist on the machine, andjw-wswas released afresh every night. The first commit makesscm.sh ls-files -fhonest in git (a mode filter instead of a silent no-op), and the second derives the hash from the committed file ids via a new-soption, so the result is the same on every machine. Expect one extra release per project the first time it runs against the new scheme, then stable hashes.scm.sh ls-files: Honor -f in Git repositories
In CVS, the
-foption keeps directory entries out ofscm.shls-file's listing; in Git, it's a silent no-op. Notably symlinks are not excluded despite-f.Implement
-ffor git with a mode filter ongit ls-files -soutput: only100644and100755entries are listed, so the option means the same thing in both code paths.For Git, this actually means a behaviour change which needs to be fixed:
The dist archive targets
tar-filesandcpio-filesinmake/list-files.mkand thescm_files()helper inscripts/pkg.shthen may no longer pass it to get unchanged behaviour.The targets
list-filesandlist-text-fileskeep it, so the text-files cache now matches its documented regular-files-only membership.calculate_hash(): Derive hash from VCS file ids
The source hash is an
md5sumover all versioned files in the working tree.md5sumfollows symlinks, so a project with links to files outside the tree may produce different hashes depending on files outside the repo.Compute the hash over the VCS file ids instead. Add a
-soption toscm.sh ls-filesthat lists each versioned file together with its content id. The listing is sorted by path rather than by id, so an entry keeps its position when its content changes.For Git repos,
git ls-tree -r HEADreports the blob of a symlink's target string and the pinned commit of a submodule, so the resulting hash depends only on the committed tree, never on the working tree or on the machine.calculate_hash()and theHASHvariable inmake/pkg-dist.mkfeed the id listing, minus the release metadata files, directly tomd5sum.calculate_hash()fails loudly when the pipeline fails, with its callers refusing to proceed on an empty result.The scheme change invalidates the stored
HASHvalues, so every project gets one more release the first time it runs against the new code, and the hashes are stable again afterwards.