{"thread":{"id":"3244","subject":"What is the working directory for post-update hook?","startedAt":"2006-02-05T09:06:51Z","lastAt":"2006-02-05T10:58:26Z","messageCount":4,"participants":["Alan Chandler","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15605","messageId":"200602050906.52016.alan@chandlerfamily.org.uk","threadId":"3244","inReplyTo":null,"subject":"What is the working directory for post-update hook?","fromName":"Alan Chandler","fromEmail":"alan@chandlerfamily.org.uk","sentAt":"2006-02-05T09:06:51Z","receivedAt":"2006-02-05T09:06:51Z","isPatch":false,"sender":{"key":"alan@chandlerfamily.org.uk","avatar":"https://gravatar.com/avatar/1862247e5ea8eac114c842f9dc3a5db6253754e24ef7171757cf97eedce48b8c?d=mp&s=160"},"body":"The document root of my website has a git repository under it (in the \nstandard .git subdirectory) and want a post update hook to checkout the \ncontents (so the web server sees it!) \n\nI will be pushing to it via ssh.\n\nDoes this mean that the post-update hook with be run with a working directory \nof the web site's document root? or something relative (such as GIT_DIR) so \nthat I don't have to do a specific cd to an absolute path.\n\n\n-- \nAlan Chandler\nhttp://www.chandlerfamily.org.uk\nOpen Source. It's the difference between trust and antitrust.\n"},{"id":"15606","messageId":"200602050937.12885.alan@chandlerfamily.org.uk","threadId":"3244","inReplyTo":"200602050906.52016.alan@chandlerfamily.org.uk","subject":"Re: What is the working directory for post-update hook?","fromName":"Alan Chandler","fromEmail":"alan@chandlerfamily.org.uk","sentAt":"2006-02-05T09:37:12Z","receivedAt":"2006-02-05T09:37:12Z","isPatch":false,"sender":{"key":"alan@chandlerfamily.org.uk","avatar":"https://gravatar.com/avatar/1862247e5ea8eac114c842f9dc3a5db6253754e24ef7171757cf97eedce48b8c?d=mp&s=160"},"body":"On Sunday 05 February 2006 09:06, Alan Chandler wrote:\n> The document root of my website has a git repository under it (in the\n> standard .git subdirectory) and want a post update hook to checkout the\n> contents (so the web server sees it!)\n>\n> I will be pushing to it via ssh.\n>\n> Does this mean that the post-update hook with be run with a working\n> directory of the web site's document root? or something relative (such as\n> GIT_DIR) so that I don't have to do a specific cd to an absolute path.\n\n\nI found it out, by getting the post update hook to e-mail me the value:-)\n\nits in the repository (ie document_root/.git)\n\n-- \nAlan Chandler\nhttp://www.chandlerfamily.org.uk\nOpen Source. It's the difference between trust and antitrust.\n"},{"id":"15607","messageId":"7vd5i2kuqi.fsf@assigned-by-dhcp.cox.net","threadId":"3244","inReplyTo":"200602050906.52016.alan@chandlerfamily.org.uk","subject":"Re: What is the working directory for post-update hook?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-05T09:41:57Z","receivedAt":"2006-02-05T09:41:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alan Chandler <alan@chandlerfamily.org.uk> writes:\n\n> The document root of my website has a git repository under it (in the \n> standard .git subdirectory) and want a post update hook to checkout the \n> contents (so the web server sees it!) \n>\n> I will be pushing to it via ssh.\n>\n> Does this mean that the post-update hook with be run with a working directory \n> of the web site's document root? or something relative (such as GIT_DIR) so \n> that I don't have to do a specific cd to an absolute path.\n\nThe current implementation happens to chdir to GIT_DIR and sets\nGIT_DIR=. in the environment, so if you have something like\nthis:\n\n\t/var/www/myproject/\n\t/var/www/myproject/.git/\n\t/var/www/myproject/.git/HEAD\n\t/var/www/myproject/.git/...\n        /var/www/myproject/README\n\nThen $(pwd) would be /var/www/myproject/.git/.  Your hook would\nprobably be able to do \"cd ..\"  to get to the project top.\n\nHowever, there is no guarantee for future implementations.\n"},{"id":"15609","messageId":"200602051058.26570.alan@chandlerfamily.org.uk","threadId":"3244","inReplyTo":"7vd5i2kuqi.fsf@assigned-by-dhcp.cox.net","subject":"Re: What is the working directory for post-update hook?","fromName":"Alan Chandler","fromEmail":"alan@chandlerfamily.org.uk","sentAt":"2006-02-05T10:58:26Z","receivedAt":"2006-02-05T10:58:26Z","isPatch":false,"sender":{"key":"alan@chandlerfamily.org.uk","avatar":"https://gravatar.com/avatar/1862247e5ea8eac114c842f9dc3a5db6253754e24ef7171757cf97eedce48b8c?d=mp&s=160"},"body":"On Sunday 05 February 2006 09:41, Junio C Hamano wrote:\n> Alan Chandler <alan@chandlerfamily.org.uk> writes:\n> > The document root of my website has a git repository under it (in the\n> > standard .git subdirectory) and want a post update hook to checkout the\n> > contents (so the web server sees it!)\n> >\n> > I will be pushing to it via ssh.\n> >\n> > Does this mean that the post-update hook with be run with a working\n> > directory of the web site's document root? or something relative (such as\n> > GIT_DIR) so that I don't have to do a specific cd to an absolute path.\n>\n> The current implementation happens to chdir to GIT_DIR and sets\n> GIT_DIR=. in the environment, so if you have something like\n> this:\n>\n> \t/var/www/myproject/\n> \t/var/www/myproject/.git/\n> \t/var/www/myproject/.git/HEAD\n> \t/var/www/myproject/.git/...\n>         /var/www/myproject/README\n>\n> Then $(pwd) would be /var/www/myproject/.git/.  Your hook would\n> probably be able to do \"cd ..\"  to get to the project top.\n>\n\nI did get it to work doing a cd .. - although you also have to unset GIT_DIR, \nbecause its is literally \".\" and not the directory that was \".\" at the time \nof setting, so a cd .. ; checkout -f then fails with an invalid repository.\n\n-- \nAlan Chandler\nhttp://www.chandlerfamily.org.uk\nOpen Source. It's the difference between trust and antitrust.\n"}]}