[binutils-gdb] [pre-commit] Move codespell-log back to commit-msg stage
Tom de Vries
vries@sourceware.org
Sat Jan 3 15:04:45 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5e7cf3e91c8f8fb13f2f4d6a8639f6243c8ce003
commit 5e7cf3e91c8f8fb13f2f4d6a8639f6243c8ce003
Author: Tom de Vries <tdevries@suse.de>
Date: Sat Jan 3 16:04:41 2026 +0100
[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:
---
.pre-commit-config.yaml | 5 +++--
gdb/contrib/codespell-log.sh | 30 ++----------------------------
2 files changed, 5 insertions(+), 30 deletions(-)
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 <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
More information about the Binutils-cvs
mailing list