From: Scott Worley Date: Fri, 8 Dec 2023 03:31:09 +0000 (-0800) Subject: Fix nested-git issues in pre-commit hook X-Git-Tag: v3.0.13~2 X-Git-Url: http://git.scottworley.com/pinch/commitdiff_plain/e99a249b5598677db990e0943a214bb0bbd9b68e?hp=b573564a47adba410749d11f28efd2a84d564bbf 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. --- 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