#110879pre-commit hook ignores TYPO3_GIT_HOOK_ABORT_ON_ERROR
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
-
Gerrit Code Review pushed patch set 1 for main to change 96281 status
NewUnder Review 10/01/26, 22:37 -
Gerrit Code Review pushed patch set 1 for 14.3 to change 96521 10/08/26, 07:44
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 96522 10/08/26, 07:44
-
Olivier Dobberkau commented and changed status
Under ReviewResolved done0 %100 % 10/08/26, 08:00
Applied in changeset commit:3caf7544957d26d43bd5137c3d7ffa49eac3223b.