From f88f5a6faceaee1d7fb1e55fd49eed2e88f33728 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 5 Aug 2021 16:26:32 +0200 Subject: fix path handling in gitolite hook --- lib/gitolite3/hooks/common/post-receive | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/gitolite3/hooks/common/post-receive b/lib/gitolite3/hooks/common/post-receive index 9731280..a5f9ab6 100755 --- a/lib/gitolite3/hooks/common/post-receive +++ b/lib/gitolite3/hooks/common/post-receive @@ -15,28 +15,25 @@ WEB_EXEC_INIT=${GL_OPTION_WEB_EXEC_INIT:-} [ -n "$WEB_BRANCH" ] || exit 0 -# which git branch to check out WEB_BASEDIR=${GL_OPTION_WEB_BASEDIR:-/var/www/gitolite3} GIT_WORK_TREE="$WEB_BASEDIR/$GL_REPO" -export GIT_WORK_TREE - -pwd -echo "Checking out content to $GIT_WORK_TREE ..." if [ -e "$GIT_WORK_TREE" ]; then - git checkout -f "$WEB_BRANCH" + echo "Refreshing content in $GIT_WORK_TREE ..." + git -C "$GIT_WORK_TREE" checkout -f "$WEB_BRANCH" chmod -R u=rw,go=r,a+X "$GIT_WORK_TREE" else - git clone --quiet --branch "$WEB_BRANCH" . + echo "Checking out content to $GIT_WORK_TREE ..." + git -C "$WEB_BASEDIR" clone --quiet --branch "$WEB_BRANCH" "$PWD" chmod -R u=rw,go=r,a+X "$GIT_WORK_TREE" if [ -n "$WEB_EXEC_INIT" ]; then - ( cd "$WEB_BASEDIR" && echo "$WEB_EXEC_INIT" | sh - ) + ( cd "$GIT_WORK_TREE" && echo "$WEB_EXEC_INIT" | sh - ) fi fi if [ -n "$WEB_EXEC" ]; then - ( cd "$WEB_BASEDIR" && echo "$WEB_EXEC" | sh - ) + ( cd "$GIT_WORK_TREE" && echo "$WEB_EXEC" | sh - ) fi echo "Checkout completed succesfully!" -- cgit v1.2.3