Issue Bug Resolved

#110879pre-commit hook ignores TYPO3_GIT_HOOK_ABORT_ON_ERROR

Olivier Dobberkau 10/01/26, 22:35 updated 10/08/26, 08:00

Description

The pre-commit hook (Build/git-hooks/unix+mac/pre-commit) documents that aborting on errors can be enabled with the environment variable TYPO3_GIT_HOOK_ABORT_ON_ERROR, but the check is inverted, so the override never takes effect:

ABORT_ON_ERROR="no"
if [ -z "${TYPO3_GIT_HOOK_ABORT_ON_ERROR+x}" ]; then
    ABORT_ON_ERROR=${TYPO3_GIT_HOOK_ABORT_ON_ERROR}
fi

“${VAR+x}” is empty only when the variable is unset, so the assignment runs exactly when there is nothing to assign.

Steps to reproduce

# variable unset
ABORT_ON_ERROR="no"; if [ -z "${TYPO3_GIT_HOOK_ABORT_ON_ERROR+x}" ]; then ABORT_ON_ERROR=${TYPO3_GIT_HOOK_ABORT_ON_ERROR}; fi; echo "$ABORT_ON_ERROR"
# variable set
TYPO3_GIT_HOOK_ABORT_ON_ERROR=yes bash -c 'ABORT_ON_ERROR="no"; if [ -z "${TYPO3_GIT_HOOK_ABORT_ON_ERROR+x}" ]; then ABORT_ON_ERROR=${TYPO3_GIT_HOOK_ABORT_ON_ERROR}; fi; echo "$ABORT_ON_ERROR"'

Expected: “no” when unset, “yes” when set to yes, so that a CGL or file header error aborts the commit.
*Actual:* “” when unset, “no” when set to yes. The hook never aborts.

The check exists since the hooks moved to Build/git-hooks (afe1c84fcbf, 2018). Fix: use -n instead of -z.

Environment: TYPO3 main, macOS, bash 5.

I will create a patch for this.

Reviews 3

History 14

  1. Olivier Dobberkau commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-10-08T08:00:14+00:00" > 10/08/26, 08:00 </span>

    Applied in changeset commit:3caf7544957d26d43bd5137c3d7ffa49eac3223b.