Skip to contentSkip to conversation

scripts/setlocalversion: fix false positive -dirty tag from ctime

PATCH Superseded Gregory Fong 1 participant 1 message Mar 10, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/setlocalversion: fix false positive -dirty tag from ctime

git-diff-index cannot detect that a file hasn't actually changed when the file's ctime has changed (e.g. if chmod was used but didn't actually result in any changes), which was causing setlocalversion to incorrectly add a -dirty tag. Run git-update-index beforehand to make sure that the index is correct.

---
Quick test:
make defconfig
make prepare
chmod u+w Kbuild # any chmod that doesn't result in a change will do CONFIG_LOCALVERSION_AUTO=y /bin/sh scripts/setlocalversion $PWD | grep -q dirty && echo "FAIL" || echo "OK"

 scripts/setlocalversion | 2 ++
 1 file changed, 2 insertions(+)
scripts/setlocalversion +2 -0
index 63d91e2..9e97364 100755
@@ -45,6 +45,8 @@ scm_version()
 	# Check for git and a git repo.
 	if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
 	   head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
+		# Update the index
+		git update-index -q --refresh
 
 		# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
 		# it, because this version is defined in the top level Makefile.
Signature · 1 line
1.9.1