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

[RFC] Run hooks with a cleaner environment

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Dec 6, 2005, 22:43 UTC
Message-ID
<Pine.LNX.4.64.0512061716030.25300@iabervon.org>

Currently, hooks/post-update is run in the environment that receive-pack is run. This means that there are a number of things that are unpredictable. I'd like to make it set things up in a more predictable and useful way. The things I know are odd:

stdout and stdin are connected to send-pack, either by broken pipes (for local pushes) or an ignored socket (via ssh). stdin should probably be /dev/null, and stdout should be either a log file or /dev/null. stderr is still the push's stderr, which may or may not be desired.

GIT_DIR is set to the repository that got the push, which may surprise people who only use it in "GIT_DIR=foo git ..." form and don't expect it ever to be set from outside. Of course, it's potentially useful to know what repository is running the hook, but that doesn't have to be communicated in such a way that git programs will pick it up directly. Other environment variables could potentially be purged, too, but I don't think that's as important, since the user probably knows about them.

cwd is set to the push's cwd if it's local, maybe $HOME if it's over ssh. It should probably always be $HOME, unless we want it to be $GIT_DIR.

Is there anything else we want to regularize? Is there some sort of standard behavior we should match, like CVS or cron?

	-Daniel
*This .sig left intentionally blank*
Next: Paul Serice
Message 1 of 5 in “[RFC] Run hooks with a cleaner environment”
  1. Daniel BarkalowDec 6, 2005
  2. Paul SericeDec 7, 2005
  3. Junio C HamanoDec 7, 2005
  4. Daniel BarkalowDec 7, 2005
  5. Junio C HamanoDec 7, 2005

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.