]> git.scottworley.com Git - pinch/commitdiff
Fix nested-git issues in pre-commit hook
authorScott Worley <scottworley@scottworley.com>
Fri, 8 Dec 2023 03:31:09 +0000 (19:31 -0800)
committerScott Worley <scottworley@scottworley.com>
Fri, 8 Dec 2023 03:31:09 +0000 (19:31 -0800)
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
git-pre-commit-hook

index ca55e07d2c8783fd7ae932ffae8170510c2d248d..4dce10e72cb3b371e647cd7207159bbbfca1d3f6 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
 ## [Unreleased]
+- Fixed nested-git issues in pre-commit hook
 - Cleaned up changelog
 
 
index 85b444576abb508a61b0e5d3ab7bd88397610c35..ce476144f4f5a6d9c2e7ed8a018b7b14b7692f73 100755 (executable)
@@ -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