hook templates have incorrect directory calculation when GIT_DIR is not set #7300

Closed
opened 2025-11-02 07:22:26 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @Spongman on GitHub (May 6, 2021).

GIT_DIR=${GIT_DIR:-$(dirname $0)}

for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do

if GIT_DIR is not set then that first line evaluates to the hooks directory containing the script, and thus the 2nd line evaluates to .../hooks/hooks/...

the script should read:

GIT_DIR=${GIT_DIR:-$(dirname $0)/..}

for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do
Originally created by @Spongman on GitHub (May 6, 2021). ```bash GIT_DIR=${GIT_DIR:-$(dirname $0)} for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do ``` if `GIT_DIR` is not set then that first line evaluates to the `hooks` directory containing the script, and thus the 2nd line evaluates to `.../hooks/hooks/...` the script should read: ```bash GIT_DIR=${GIT_DIR:-$(dirname $0)/..} for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do ```
GiteaMirror added the type/bug label 2025-11-02 07:22:26 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7300