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

Re: [PATCH v2 1/2] Documentation/githooks: mention pwd, $GIT_PREFIX

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 12, 2015, 19:56 UTC
Message-ID
<xmqqzj9n7oxp.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1420931503-22857-2-git-send-email-rhansen@bbn.com>
Richard Hansen <rhansen@bbn.com> writes:
Show 19 quoted lines
> Document that hooks are run from the top-level directory and that
> GIT_PREFIX is set to the name of the original subdirectory (relative
> to the top-level directory).
>
> Signed-off-by: Richard Hansen <rhansen@bbn.com>
> ---
>  Documentation/githooks.txt | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
> index 9ef2469..c08f4fd 100644
> --- a/Documentation/githooks.txt
> +++ b/Documentation/githooks.txt
> @@ -26,6 +26,12 @@ executable by default.
>  
>  This document describes the currently defined hooks.
>  
> +Hooks are executed from the top-level directory of a repository, which
> +may not necessarily be the current directory.

I agree that it is a good idea to describe how the hook writers can go to the top-level directory and how the hook writers can discover where the hooked operation started, but these two lines cannot be the whole story---what happens when there is no top-level directory (i.e. a bare repository)?

Is this universal to all hooks, or just the ones you examined? I ask this because I know we do not go through a single interface to call out to hooks that says "cd to the root and then run the hook given as an argument".

> +The 'GIT_PREFIX' environment variable is set as returned by running
> +'git rev-parse --show-prefix' from the original current directory.

Is this also universal, or is it set only for some but not all hooks? What happens in a bare repository? What is given if you are in a non-bare repository and are already at the root level?

> +See linkgit:git-rev-parse[1].
> +
>  HOOKS
>  -----
Previous: Richard HansenNext: Richard Hansen
Message 7 of 9 in “Documentation/githooks: mention pwd, $GIT_PREFIX”
  1. 0/2 Documentation/githooks: mention pwd, $GIT_PREFIXRichard Hansen, Jan 10, 2015
  2. 1/2 Documentation/githooks: mention pwd, $GIT_PREFIXRichard Hansen, Jan 10, 2015
  3. 2/2 t1020-subdirectory.sh: check hook pwd, $GIT_PREFIXRichard Hansen, Jan 10, 2015
  4. Johannes SixtJan 10, 2015
  5. 0/2 Documentation/githooks: mention pwd, $GIT_PREFIXRichard Hansen, Jan 10, 2015
  6. 1/2 Documentation/githooks: mention pwd, $GIT_PREFIXRichard Hansen, Jan 10, 2015
  7. Junio C HamanoJan 12, 2015
  8. 2/2 t1020-subdirectory.sh: check hook pwd, $GIT_PREFIXRichard Hansen, Jan 10, 2015
  9. Junio C HamanoJan 12, 2015

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.