git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] githooks: discuss Git operations in foreign repositories

From
PWPreston Tunnell Wilson <prestontunnellwilson@gmail.com>
Date
Jan 9, 2023, 20:12 UTC
Message-ID
<CAC-j02NxVbqu+TQvNgbwFtxmXTZBAJtG60BR+yfXcT9ubSn-jA@mail.gmail.com>
In-Reply-To
<pull.1457.v2.git.1673293508399.gitgitgadget@gmail.com>

On Mon, Jan 9, 2023 at 1:45 PM Eric Sunshine via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 22 quoted lines
>  Documentation/githooks.txt | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
> index a16e62bc8c8..62908602e7b 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)
> +------------

This looks good to me! Thank you! (And I'm sorry about top-posting *again*! I think I have the hang of it now.)

Previous: Eric Sunshine via GitGitGadgetNext: Jeff King
Message 10 of 11 in “githooks: discuss Git operations in foreign repositories”
  1. githooks: discuss Git operations in foreign repositoriesEric Sunshine via GitGitGadget, Jan 8, 2023
  2. Preston Tunnell WilsonJan 8, 2023
  3. Eric SunshineJan 8, 2023
  4. Preston Tunnell WilsonJan 9, 2023
  5. Eric SunshineJan 9, 2023
  6. Junio C HamanoJan 9, 2023
  7. Eric SunshineJan 9, 2023
  8. Junio C HamanoJan 9, 2023
  9. githooks: discuss Git operations in foreign repositoriesEric Sunshine via GitGitGadget, Jan 9, 2023
  10. Preston Tunnell WilsonJan 9, 2023
  11. Jeff KingJan 11, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.