diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-01-21 17:21:58 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-01-21 17:21:58 -0800 |
| commit | fc2735f427fdf6c5a46688f3aa9750b82f1058fe (patch) | |
| tree | 465ee377c561d9dfb8d37a538e1b72402249eadd | |
| parent | 60ce816cb637f8fac5e8e5b8a53dff8707b2c04c (diff) | |
| parent | 772f8ff826fcb15cba94bfd8f23eb0917f3e9edc (diff) | |
Merge branch 'es/hooks-and-local-env'
Doc update for environment variables set when hooks are invoked.
* es/hooks-and-local-env:
githooks: discuss Git operations in foreign repositories
| -rw-r--r-- | Documentation/githooks.txt | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt index a16e62bc8c..62908602e7 100644 --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@ -27,6 +27,18 @@ repository. An exception are hooks triggered during a push ('pre-receive', 'update', 'post-receive', 'post-update', 'push-to-checkout') which are always executed in $GIT_DIR. +Environment variables, such as `GIT_DIR`, `GIT_WORK_TREE`, etc., are exported +so that Git commands run by the hook can correctly locate the repository. If +your hook needs to invoke Git commands in a foreign repository or in a +different working tree of the same repository, then it should clear these +environment variables so they do not interfere with Git operations at the +foreign location. For example: + +------------ +local_desc=$(git describe) +foreign_desc=$(unset $(git rev-parse --local-env-vars); git -C ../foreign-repo describe) +------------ + Hooks can get their arguments via the environment, command-line arguments, and stdin. See the documentation for each hook below for details. |
