From: Tom de Vries Date: Sat, 3 Jan 2026 15:04:41 +0000 (+0100) Subject: [pre-commit] Move codespell-log back to commit-msg stage X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e7cf3e91c8f8fb13f2f4d6a8639f6243c8ce003;p=thirdparty%2Fbinutils-gdb.git [pre-commit] Move codespell-log back to commit-msg stage 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 --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0c80428875..3bed91e50f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ # 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 @@ -78,7 +78,8 @@ repos: 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 diff --git a/gdb/contrib/codespell-log.sh b/gdb/contrib/codespell-log.sh index 3873fd7a5a9..992483d0165 100755 --- a/gdb/contrib/codespell-log.sh +++ b/gdb/contrib/codespell-log.sh @@ -14,33 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# 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