Re: Wrong -dirty suffix set by setlocalversion (was: BUG in git diff-index)

From: Mike Mason
Date: Fri May 25 2018 - 07:56:40 EST


How about something like this? It ignores attributes that should have no
bearing on whether the kernel is considered dirty. Copied trees with no other
changes would no longer be marked with -dirty. Plus it works on read-only
media since no index updating is required.

Would this also be considered kosher, at least for the purposes of
setlocalversion?

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 71f39410691b..9da4c5e83285 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -73,8 +73,10 @@ scm_version()
printf -- '-svn%s' "`git svn find-rev $head`"
fi

- # Check for uncommitted changes
- if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then
+ # Check for uncommitted changes. Only check mtime and size.
+ # Ignore insequential ctime, uid, gid and inode differences.
+ if git -c "core.checkstat=minimal" diff-index --name-only HEAD | \
+ grep -qv "^scripts/package"; then
printf '%s' -dirty
fi