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

Re: [RFC] Run hooks with a cleaner environment

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Dec 7, 2005, 17:47 UTC
Message-ID
<Pine.LNX.4.64.0512071236260.25300@iabervon.org>
In-Reply-To
<7voe3tzqn8.fsf@assigned-by-dhcp.cox.net>
On Tue, 6 Dec 2005, Junio C Hamano wrote:
Show 8 quoted lines
> Daniel Barkalow <barkalow@iabervon.org> writes:
> 
> > GIT_DIR is set to the repository that got the push,
> 
> That is done by receive-pack; it chdir()s into the repository
> and does its thing, and the hooks are called from there; I'd
> expect cwd to be the repository ('.git'), GIT_DIR to be dot
> ('.').

I thought I was seeing the full path of the repository as GIT_DIR and I didn't check the cwd.

> I think doing the "unset GIT_DIR" to be the first thing if you
> want to access some other repository is documented somewhere but
> if not please send a patch to document it.

I didn't see it in the place "grep post-update Documentation/*" returned, so we need something. (Actually, the main thing is to specify that nothing else special is set, because the GIT_DIR thing was pretty obvious, but I then didn't know if my problems were due to something else undocumented.)

> As to file descriptors, I think duping the output to original
> stderr might make sense, but I do not know what breaks, so
> interested parties may want to test it out and submit a tested
> patch for inclusion.

I'll send a patch tonight which works for me, but it should probably be checked over by people who are good at this sort of stuff. I've got a "/dev/null" patch; I'll look into a version that tries to find a controlling tty (which could be really interesting, since you could then have the hook get input from the user), or at least copy stderr if possible.

For reference, the error I was getting was a broken pipe writing to stdout (as git merge does somewhere) when I've pushed locally.

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 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.