Ignore Emacs developer’s global core.whitespace

* build-aux/git-hooks/pre-commit: Use EMACS_GIT_CORE_WHITESPACE,
not the global core.whitespace, for whitespace checks when committing.
This defaults to empty, which means to use the Git default, and
this should fix Bug#80428 “C indentation in .gitattributes, macros
in .dir-locals.el”.  The environment variable is a better way to
temporarily override the default.
This commit is contained in:
Paul Eggert
2026-03-13 10:26:48 -07:00
parent 0efb47d474
commit 10979aa458

View File

@@ -74,10 +74,12 @@ done
# The '--check' option of git diff-index makes Git complain if changes # The '--check' option of git diff-index makes Git complain if changes
# introduce whitespace errors. This can be a pain when editing test # introduce whitespace errors. This can be a pain when editing test
# files that deliberately contain lines with trailing whitespace. # files that deliberately flout the normal whitespace rules.
# To work around the problem you can run a command like 'git config # To work around the problem, set EMACS_GIT_CORE_WHITESPACE temporarily
# core.whitespace -trailing-space'. It may be better to revamp the # in your environment. For example, set it to '-blank-at-eol' to commit
# tests so that trailing spaces are generated on the fly rather than # a test with blanks at line end. It may be better to revamp the
# tests so that offending lines are generated on the fly rather than
# being committed as source. # being committed as source.
exec git diff-index --check --cached $head -- exec git -c core.whitespace="$EMACS_GIT_CORE_WHITESPACE" \
diff-index --check --cached $head --