]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - scripts/setlocalversion
scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks
[mirror_ubuntu-bionic-kernel.git] / scripts / setlocalversion
index 71f39410691b6be14774102000507c834c8ad493..365b3c2b8f431f28a83a6641ccf2da043dc05b55 100755 (executable)
@@ -73,8 +73,16 @@ 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.
+               # First, with git-status, but --no-optional-locks is only
+               # supported in git >= 2.14, so fall back to git-diff-index if
+               # it fails. Note that git-diff-index does not refresh the
+               # index, so it may give misleading results. See
+               # git-update-index(1), git-diff-index(1), and git-status(1).
+               if {
+                       git --no-optional-locks status -uno --porcelain 2>/dev/null ||
+                       git diff-index --name-only HEAD
+               } | grep -qvE '^(.. )?scripts/package'; then
                        printf '%s' -dirty
                fi