git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* post-receive hook
@ 2008-05-30  8:10 david
  2008-05-30  9:06 ` Johan Herland
  0 siblings, 1 reply; 3+ messages in thread
From: david @ 2008-05-30  8:10 UTC (permalink / raw)
  To: git

I'm trying to setup a post-receive hook to do a checkout -f when I push to 
a public repo (it's a web based tool and I want the executables to be 
updated with a push)

unfortunantly if I just add git checkout -f to the post-receive hooks it 
checks the files out in the .git directory.

if I do a cd .. ; git checkout -f I get an error message complaining that 
it's not in a git repository, but if I manually cd to that directory and 
do a checkout it works.

what am I missing here?

David Lang

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: post-receive hook
  2008-05-30  8:10 post-receive hook david
@ 2008-05-30  9:06 ` Johan Herland
  2008-05-30  9:43   ` david
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Herland @ 2008-05-30  9:06 UTC (permalink / raw)
  To: david; +Cc: git

On Friday 30 May 2008, david@lang.hm wrote:
> I'm trying to setup a post-receive hook to do a checkout -f when I push to 
> a public repo (it's a web based tool and I want the executables to be 
> updated with a push)
> 
> unfortunantly if I just add git checkout -f to the post-receive hooks it 
> checks the files out in the .git directory.
> 
> if I do a cd .. ; git checkout -f I get an error message complaining that 
> it's not in a git repository, but if I manually cd to that directory and 
> do a checkout it works.
> 
> what am I missing here?

I'm guessing that the post-receive hook is invoked with "GIT_DIR=.", which goes bad the moment you chdir anywhere. I have this in my own update hook script:

if [ "$GIT_DIR" = "." ]; then
	GIT_DIR=`pwd`
fi

If you do this before the "cd .. ; git checkout -f", you might have better luck.


Have fun! :)

...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: post-receive hook
  2008-05-30  9:06 ` Johan Herland
@ 2008-05-30  9:43   ` david
  0 siblings, 0 replies; 3+ messages in thread
From: david @ 2008-05-30  9:43 UTC (permalink / raw)
  To: Johan Herland; +Cc: git

On Fri, 30 May 2008, Johan Herland wrote:

> On Friday 30 May 2008, david@lang.hm wrote:
>> I'm trying to setup a post-receive hook to do a checkout -f when I push to
>> a public repo (it's a web based tool and I want the executables to be
>> updated with a push)
>>
>> unfortunantly if I just add git checkout -f to the post-receive hooks it
>> checks the files out in the .git directory.
>>
>> if I do a cd .. ; git checkout -f I get an error message complaining that
>> it's not in a git repository, but if I manually cd to that directory and
>> do a checkout it works.
>>
>> what am I missing here?
>
> I'm guessing that the post-receive hook is invoked with "GIT_DIR=.", which goes bad the moment you chdir anywhere. I have this in my own update hook script:
>
> if [ "$GIT_DIR" = "." ]; then
> 	GIT_DIR=`pwd`
> fi
>
> If you do this before the "cd .. ; git checkout -f", you might have better luck.

thanks, that solved the problem.

David Lang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-05-30  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-30  8:10 post-receive hook david
2008-05-30  9:06 ` Johan Herland
2008-05-30  9:43   ` david

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).