Skip to content
  • Brian Norris's avatar
    scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks · b064e272
    Brian Norris authored
    [ Upstream commit ff64dd48 ]
    
    git-diff-index does not refresh the index for you, so using it for a
    "-dirty" check can give misleading results. Commit 6147b1cf
    ("scripts/setlocalversion: git: Make -dirty check more robust") tried to
    fix this by switching to git-status, but it overlooked the fact that
    git-status also writes to the .git directory of the source tree, which
    is definitely not kosher for an out-of-tree (O=) build. That is getting
    reverted.
    
    Fortunately, git-status now supports avoiding writing to the index via
    the --no-optional-locks flag, as of git 2.14. It still calculates an
    up-to-date index, but it avoids writing it out to the .git directory.
    
    So, let's retry the solution from commit 6147b1cf using this new
    flag first, and if it fails, we assume this is an older version of git
    and just use the old git-diff-index method.
    
    It's hairy to get the 'grep -vq' (inverted matchi...
    b064e272