From 04e8b53f9b47486872e9aaf417b28a05cc9ec50d Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 23 Sep 2025 22:04:38 -0700 Subject: [PATCH] Remove `$GIT_DIR` from post-update hook `$GIT_DIR` is not set on the first push to a new repo. Instead, use the proper git command to avoid future issues. --- srv/git/git-shell-commands/init | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srv/git/git-shell-commands/init b/srv/git/git-shell-commands/init index ca962ce..a52cc56 100644 --- a/srv/git/git-shell-commands/init +++ b/srv/git/git-shell-commands/init @@ -46,13 +46,14 @@ git init --bare --quiet # Create post-update hook for dumb HTTP transport, generating README for summary view, # and general maintenance. -# See https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#_dumb_http) +# See https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#_dumb_http # See https://git-scm.com/docs/git-maintenance # See https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery +# Do not use $GIT_DIR, see https://stackoverflow.com/q/53121208/21084807 cat > "$path/hooks/post-update" << EOL #!/bin/sh git update-server-info -git cat-file blob HEAD:README.md | comrak --gfm > $GIT_DIR/README.html +git cat-file blob HEAD:README.md | comrak --gfm > "$(git rev-parse --git-common-dir)/README.html" git maintenance run EOL chmod a+x "$path/hooks/post-update" -- 2.47.3