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

Bug: Git invokes hooks from wrong directory.

From
Gabriel Nützi <gnuetzi@gmail.com>
Date
Apr 27, 2021, 07:23 UTC
Message-ID
<e173a3c0-5ca9-4c0e-9a1b-ef5f6aa72340@gmail.com>
In-Reply-To
<03b67357-4d9a-ea66-ad72-f01bb25aa54c@gmail.com>
Dear Community

The following MWE in https://stackoverflow.com/questions/67273420/why-does-git-execute-hooks-from-an-other-repository/67276138#67276138

shows a bug that Git executes the hooks in `/tmp/A` instead of `/tmp/Githooks`.

# ----------
|# Make simple repo git init "/tmp/A" && cd "/tmp/A" || exit 1
|
|
|
|# Make hook to demonstrate the problem
   mkdir -p ".git/hooks" &&
|
|echo "echo 'EXECUTED!!!'" >.git/hooks/reference-transaction &&
|
|  chmod +x ".git/hooks/reference-transaction" &&
|
|  git clone -c core.hooksPath=".git/hooks" --template= 
"https://github.com/gabyx/Githooks.git" /tmp/Githooks|
# ----------
Would be nice to know, if this is indeed a bug and should be fixed?

If somebody points me to the corresponding source code, I could dive in. Thanks a lot.

BR Gabriel Nützi
Message 1 of 1 in “Bug: Git invokes hooks from wrong directory.”
  1. Gabriel NütziApr 27, 2021

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.