pw_presubmit: Unset some Git environment variables in hooks

Git sets environment variables that are visible when running hooks.
These cause problems when running Git from a hook in a submodule.

Fixed: 364
Change-Id: I3d9c2e715d26247e4eda352efb0a668eb9c0ba6b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/42160
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
diff --git a/pw_presubmit/py/pw_presubmit/install_hook.py b/pw_presubmit/py/pw_presubmit/install_hook.py
index 632bd92..62363f9 100755
--- a/pw_presubmit/py/pw_presubmit/install_hook.py
+++ b/pw_presubmit/py/pw_presubmit/install_hook.py
@@ -60,6 +60,12 @@
         line('#!/bin/sh')
         line(f'# {hook} hook generated by {__file__}')
         line()
+        line('# Unset Git environment variables, which are set when this is ')
+        line('# run as a Git hook. These environment variables cause issues ')
+        line('# when trying to run Git commands on other repos from a ')
+        line('# submodule hook.')
+        line('unset $(git rev-parse --local-env-vars)')
+        line()
         line(command)
 
     hook_path.chmod(0o755)