For git trees newvers.sh attempts to report that the sources used to build do not exactly match a commit hash (and append -dirty to the hash) via: if $git_cmd --work-tree=${VCSDIR}/.. diff-index \ --name-only HEAD | read dummy; then git="${git}-dirty" modified=true fi However this falsely reports that the tree is modified if metadata on a file does not match git's expectation - for example, I have no changes in a tree: % git diff-index --name-only HEAD % git diff % Touch a file: % touch sys/sys/param.h % Now diff-index --name-only HEAD returns the touched file: % git diff-index --name-only HEAD sys/sys/param.h % But there are actually no changes: % git diff % And running 'git diff' clears the "metadata changed" status: % git diff-index --name-only HEAD %
The full git diff-index output (i.e., without --name-only) reports: :100644 100644 728b9afe3828cfe7916731637677afddd0ad1fb1 0000000000000000000000000000000000000000 M sys/conf/newvers.sh The all-zeros SHA hash means that the working tree file must be checked.
A commit references this bug: Author: emaste Date: Fri Nov 2 21:20:46 UTC 2018 New revision: 340083 URL: https://svnweb.freebsd.org/changeset/base/340083 Log: newvers.sh: fix git false positive -dirty tag Assuming that any output from `git diff-index --name-only` implies changes in the working tree results in false positives: files with metadata, but not content, changes are also listed. Check that content differences exist before adding the -dirty tag to the git hash. PR: 229230 Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D15968 Changes: head/sys/conf/newvers.sh
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=b67bd2859d7d757ee9ceb8269a5790f4f1091be5 commit b67bd2859d7d757ee9ceb8269a5790f4f1091be5 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2018-11-02 21:20:46 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-09-06 17:15:05 +0000 newvers.sh: fix git false positive -dirty tag Assuming that any output from `git diff-index --name-only` implies changes in the working tree results in false positives: files with metadata, but not content, changes are also listed. Check that content differences exist before adding the -dirty tag to the git hash. PR: 229230 Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D15968 (cherry picked from commit 50b53a8dc35f38ab6920dd83409541e875d01551) (cherry picked from commit 5186028dc4a2a74d007fa65857667efb2742eaea) sys/conf/newvers.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)