aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/blogc-git-receiver/pre-receive.c5
-rwxr-xr-xtests/blogc-git-receiver/check_pre_receive.sh.in22
2 files changed, 25 insertions, 2 deletions
diff --git a/src/blogc-git-receiver/pre-receive.c b/src/blogc-git-receiver/pre-receive.c
index 9611567..2081b4f 100644
--- a/src/blogc-git-receiver/pre-receive.c
+++ b/src/blogc-git-receiver/pre-receive.c
@@ -125,6 +125,11 @@ bgr_pre_receive_hook(int argc, char *argv[])
}
const char *sym_tmp = bc_config_get(config, section, "symlink");
+ if (sym_tmp == NULL) {
+ bc_config_free(config);
+ goto default_sym;
+ }
+
sym = bc_str_starts_with(sym_tmp, "/") ? bc_strdup(sym_tmp) :
bc_strdup_printf("%s/%s", repo_dir, sym_tmp);
free(section);
diff --git a/tests/blogc-git-receiver/check_pre_receive.sh.in b/tests/blogc-git-receiver/check_pre_receive.sh.in
index 2a9aa91..41daaf3 100755
--- a/tests/blogc-git-receiver/check_pre_receive.sh.in
+++ b/tests/blogc-git-receiver/check_pre_receive.sh.in
@@ -94,8 +94,6 @@ cat > "${TEMP}/payload.txt" <<EOF
EOF
cat > "${TEMP}/blogc-git-receiver.ini" <<EOF
-[repo:foo2.git]
-symlink = ${TEMP}/chunda
[repo:foo2a.git]
symlink = ${TEMP}/guda
EOF
@@ -103,6 +101,26 @@ EOF
SHELL="${SELF}" HOME="${TEMP}" GIT_DIR=. BLOGC_GIT_RECEIVER_BUILDS_DIR="${TEMP}/foooo" ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEMP}/payload.txt" 2>&1 | tee "${TEMP}/output.txt"
grep "echo lol" "${TEMP}/output.txt" &> /dev/null
+[[ -h htdocs ]]
+[[ "$(cat htdocs/foo.txt)" == "lol" ]]
+
+cat >> "${TEMP}/blogc-git-receiver.ini" <<EOF
+[repo:foo2.git]
+EOF
+
+SHELL="${SELF}" HOME="${TEMP}" GIT_DIR=. BLOGC_GIT_RECEIVER_BUILDS_DIR="${TEMP}/foooo" ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEMP}/payload.txt" 2>&1 | tee "${TEMP}/output.txt"
+grep "echo lol" "${TEMP}/output.txt" &> /dev/null
+
+[[ -h htdocs ]]
+[[ "$(cat htdocs/foo.txt)" == "lol" ]]
+
+cat >> "${TEMP}/blogc-git-receiver.ini" <<EOF
+symlink = ${TEMP}/chunda
+EOF
+
+SHELL="${SELF}" HOME="${TEMP}" GIT_DIR=. BLOGC_GIT_RECEIVER_BUILDS_DIR="${TEMP}/foooo" ${TESTS_ENVIRONMENT} ./hooks/pre-receive < "${TEMP}/payload.txt" 2>&1 | tee "${TEMP}/output.txt"
+grep "echo lol" "${TEMP}/output.txt" &> /dev/null
+
[[ -h "${TEMP}/chunda" ]]
[[ "$(cat "${TEMP}/chunda/foo.txt")" == "lol" ]]