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

Re: $GIT_DIR is no longer set when pre-commit hooks are called

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 27, 2018, 16:25 UTC
Message-ID
<nycvar.QRO.7.76.6.1808271824270.73@tvgsbejvaqbjf.bet>
In-Reply-To
<20180826004150.GA31168@sigill.intra.peff.net>
Hi Peff,
On Sat, 25 Aug 2018, Jeff King wrote:
Show 11 quoted lines
> On Wed, Aug 22, 2018 at 04:16:00PM -0700, Gregory Oschwald wrote:
> 
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 3bfeabc463..3670024a25 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1440,6 +1440,7 @@ int run_commit_hook(int editor_is_used, const char *index_file, const char *name
>  	int ret;
>  
>  	argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
> +	argv_array_pushf(&hook_env, "GIT_DIR=%s", get_git_dir());

We did something similar in sequencer.c, and it required setting `GIT_WORK_TREE`, too, to avoid problems in worktrees. Do you need the same here, too?

Ciao, Dscho

Show 5 quoted lines
>  	/*
>  	 * Let the hook know that no editor will be launched.
> 
> -Peff
> 
Previous: Jeff KingNext: Jeff King
Message 3 of 5 in “$GIT_DIR is no longer set when pre-commit hooks are called”
  1. Gregory OschwaldAug 22, 2018
  2. Jeff KingAug 26, 2018
  3. Johannes SchindelinAug 27, 2018
  4. Jeff KingAug 27, 2018
  5. Johannes SchindelinAug 28, 2018

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.