]> git.baikalelectronics.ru Git - kernel.git/commit
scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks
authorBrian Norris <briannorris@chromium.org>
Thu, 15 Nov 2018 02:11:18 +0000 (18:11 -0800)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 21 Nov 2018 14:57:33 +0000 (23:57 +0900)
commitecd3ec79a947ecc78255b93ba32007917a15cde0
tree833e59caa35fa21a7294f0efad4f3f1eeb4c5c1f
parent57719add4a9db9d4cc345c2a2d552f28c9a379d7
scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks

git-diff-index does not refresh the index for you, so using it for a
"-dirty" check can give misleading results. Commit 0247c7807cac7
("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 0247c7807cac7 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 matching) correct by stashing
the output of git-status (you have to be careful about the difference
betwen "empty stdin" and "blank line on stdin"), so just pipe the output
directly to grep and use a regex that's good enough for both the
git-status and git-diff-index version.

Cc: Christian Kujau <lists@nerdbynature.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Suggested-by: Alexander Kapshuk <alexander.kapshuk@gmail.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Tested-by: Genki Sky <sky@genki.is>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/setlocalversion