Commit
7acd390ffd9 ("[pre-commit] Move codespell-log to post-commit") moved
the codespell-log hook from the commit-msg to the post-commit stage.
This was deemed to make git rebase too slow [1], so move it back to the
commit-msg stage. Don't do this using a full revert, to keep unrelated
improvements from that commit.
Since we use codespell-log to produce warnings rather than errors, running the
hook at the commit-msg stage requires us to ignore codespell exit status, and
set verbose=true.
[1] https://sourceware.org/pipermail/gdb-patches/2025-December/223533.html
# See https://pre-commit.com/hooks.html for more hooks
minimum_pre_commit_version: 3.2.0
-default_install_hook_types: [pre-commit, post-commit]
+default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit]
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
entry: gdb/contrib/codespell-log.sh
args: [--config, gdb/contrib/setup.cfg]
always_run: true
- stages: [post-commit]
+ verbose: true
+ stages: [commit-msg]
- repo: local
hooks:
- id: check-include-guards
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Script to be used as post-commit hook to spell-check the commit log using
+# Script to be used as commit-msg hook to spell-check the commit log using
# codespell.
-#
-# Given that the post-commit hook gets no arguments from git, we need to
-# provide the commit message ourselves.
-
-# Exit on error.
-set -e
-
-tmp=
-
-cleanup()
-{
- if [ "$tmp" != "" ]; then
- rm -f "$tmp"
- fi
-}
-
-# Schedule cleanup.
-trap cleanup EXIT
-
-tmp=$(mktemp)
-git show \
- -s \
- --pretty=%B HEAD \
- > "$tmp"
-codespell \
- "$@" \
- "$tmp"
+codespell "$@" || true