{"thread":{"id":"20981","subject":"Git Hooks","startedAt":"2009-09-16T23:24:11Z","lastAt":"2009-09-16T23:31:31Z","messageCount":2,"participants":["daicoden","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"123390","messageId":"25482688.post@talk.nabble.com","threadId":"20981","inReplyTo":null,"subject":"Git Hooks","fromName":"daicoden","fromEmail":"daicoden@copypastel.com","sentAt":"2009-09-16T23:24:11Z","receivedAt":"2009-09-16T23:24:11Z","isPatch":false,"sender":{"key":"daicoden@copypastel.com","avatar":null},"body":"\nHi,\n\nI have a git repo host at /home/git/blog.git.  I have a copy checked out at\n/var/www/blog.  I have a script as follows:\n\ncd /var/www/blog\nthin -s 2 -C config.yml -R config.ru stop\ngit pull origin master\nthin -s 2 -C config.yml -R config.ru start \n\n>From a local machine I can commit to the repo, push, and then run this\nscript and the server will update just fine.  I wanted to make this\nautomatic so I wrote the following post-receive hook.\n\nif git log -n1 | grep -q \"#publish\" || git log -n1 | grep -q \"#Publish\"\nthen\n        ~/bin/update-blog\nfi\n\nIf #publish is in the commit message then it runs the first script.  I found\nthrough trial and error that when you use the command git from within a git\nhook it needs to be executed in a .git directory, so I changed the first\nscript to.\n\ncd /var/www/blog\nthin -s 2 -C config.yml -R config.ru stop\ncd .git\ngit pull origin master\ncd ..\nthin -s 2 -C config.yml -R config.ru start \n\nEverything executes, I see the messages of the server stopping, the new info\nbeing pulled, then the server starts again, but the server does not reflect\nany changes.  If I then manually stop the server, use git reset --hard, and\nthen start the server again it works fine.\n\nMy only thought is that the cause of this has something to do with git\noperating differently when you call it from within a hook.  Unfortunately, I\ndon't have any thoughts on how to fix it.\n-- \nView this message in context: http://www.nabble.com/Git-Hooks-tp25482688p25482688.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"123392","messageId":"7vzl8uv54c.fsf@alter.siamese.dyndns.org","threadId":"20981","inReplyTo":"25482688.post@talk.nabble.com","subject":"Re: Git Hooks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-16T23:31:31Z","receivedAt":"2009-09-16T23:31:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"daicoden <daicoden@copypastel.com> writes:\n\n> cd /var/www/blog\n> thin -s 2 -C config.yml -R config.ru stop\n> cd .git\n> git pull origin master\n> cd ..\n> thin -s 2 -C config.yml -R config.ru start \n\nUnless you have a strange configuration in which you have work tree files\ninside a .git directory of another repository, running \"git pull\" after\ngoing into .git directory does not make any sense.\n\nPerhaps add this\n\n\tunset GIT_DIR\n\nat the very beginning of your original script would make it work better?\n"}]}