From e99a249b5598677db990e0943a214bb0bbd9b68e Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Dec 2023 19:31:09 -0800 Subject: [PATCH] Fix nested-git issues in pre-commit hook This has been wonky before (eg: 'git add foo; git commit' would work while 'git commit foo' would not), but between 2.40.1 and 2.42.0 something about git changed such that the pre-commit completely stopped working. So now we properly clean the tests' git invocations' environment. --- Changelog | 1 + git-pre-commit-hook | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Changelog b/Changelog index ca55e07..4dce10e 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Fixed nested-git issues in pre-commit hook - Cleaned up changelog diff --git a/git-pre-commit-hook b/git-pre-commit-hook index 85b4445..ce47614 100755 --- a/git-pre-commit-hook +++ b/git-pre-commit-hook @@ -17,6 +17,16 @@ D=$(mktemp -d) git checkout-index --prefix="$D/" -a pushd "$D" +# So we don't confuse the inner git invocations inside the tests with +# the outer git invocation that's trying to commit a change. +unset GIT_AUTHOR_DATE +unset GIT_AUTHOR_EMAIL +unset GIT_AUTHOR_NAME +unset GIT_CONFIG_PARAMETERS +unset GIT_EXEC_PATH +unset GIT_INDEX_FILE +unset GIT_PREFIX + nix-shell --arg lint true --run './test.sh lint' popd -- 2.44.1