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

Re: What is the working directory for post-update hook?

From
Alan Chandler <alan@chandlerfamily.org.uk>
Date
Feb 5, 2006, 10:58 UTC
Message-ID
<200602051058.26570.alan@chandlerfamily.org.uk>
In-Reply-To
<7vd5i2kuqi.fsf@assigned-by-dhcp.cox.net>
On Sunday 05 February 2006 09:41, Junio C Hamano wrote:
Show 24 quoted lines
> Alan Chandler <alan@chandlerfamily.org.uk> writes:
> > The document root of my website has a git repository under it (in the
> > standard .git subdirectory) and want a post update hook to checkout the
> > contents (so the web server sees it!)
> >
> > I will be pushing to it via ssh.
> >
> > Does this mean that the post-update hook with be run with a working
> > directory of the web site's document root? or something relative (such as
> > GIT_DIR) so that I don't have to do a specific cd to an absolute path.
>
> The current implementation happens to chdir to GIT_DIR and sets
> GIT_DIR=. in the environment, so if you have something like
> this:
>
> 	/var/www/myproject/
> 	/var/www/myproject/.git/
> 	/var/www/myproject/.git/HEAD
> 	/var/www/myproject/.git/...
>         /var/www/myproject/README
>
> Then $(pwd) would be /var/www/myproject/.git/.  Your hook would
> probably be able to do "cd .."  to get to the project top.
>

I did get it to work doing a cd .. - although you also have to unset GIT_DIR, because its is literally "." and not the directory that was "." at the time of setting, so a cd .. ; checkout -f then fails with an invalid repository.

-- 
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
Previous: Junio C Hamano
Message 4 of 4 in “What is the working directory for post-update hook?”
  1. Alan ChandlerFeb 5, 2006
  2. Alan ChandlerFeb 5, 2006
  3. Junio C HamanoFeb 5, 2006
  4. Alan ChandlerFeb 5, 2006

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.