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

PATH modifications for git-hook processes

From
MRMatthew Rothenberg <mroth@khanacademy.org>
Date
Apr 14, 2015, 16:04 UTC
Message-ID
<CAKuTQSGEmHHr-c+Tc2jM-JPkx6+_f3gp8Zjj8EuQy_e4=PvMzg@mail.gmail.com>

Using git 2.3.5 (on darwin, installed via homebrew), when executing a script via the commit-msg githook, the following gets *prepended* to the $PATH for the subprocess:

  /usr/local/Cellar/git/2.3.5/libexec/git-core:/usr/local/Cellar/git/2.3.5/libexec/git-core:/usr/local/bin:{rest
of path...}

I can't find any documentation about this path modification behavior in the git docs, and I'm not familiar enough with the source code to locate it there either.

In our case, the prepending of /usr/local/bin is particularly problematic, as it effectively reorders our chosen PATH hierarchy (in which user-space versions of commands are picked up prior to system installed ones).

(It's also curious that the git-core directory gets prepended twice, but that doesn't cause us any particular issues.)

My questions:
 - what is the expected PATH modification behavior for subprocesses of
git-hooks? Is this documented anywhere?
 - what would be causing /usr/local/bin to be prepended here, and can
it be adjusted via preference?
Thanks!
Next: Junio C Hamano
Message 1 of 12 in “PATH modifications for git-hook processes”
  1. Matthew RothenbergApr 14, 2015
  2. Junio C HamanoApr 14, 2015
  3. Matthew RothenbergApr 15, 2015
  4. Jeff KingApr 16, 2015
  5. Jeff KingApr 16, 2015
  6. David RodríguezApr 22, 2015
  7. Junio C HamanoApr 22, 2015
  8. stop putting argv[0] dirname at front of PATHJeff King, Apr 22, 2015
  9. Eric SunshineApr 22, 2015
  10. Jeff KingApr 22, 2015
  11. Jonathan NiederApr 22, 2015
  12. Jeff KingApr 22, 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.