]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[pre-commit] Move codespell-log back to commit-msg stage
authorTom de Vries <tdevries@suse.de>
Sat, 3 Jan 2026 15:04:41 +0000 (16:04 +0100)
committerTom de Vries <tdevries@suse.de>
Sat, 3 Jan 2026 15:04:41 +0000 (16:04 +0100)
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

.pre-commit-config.yaml
gdb/contrib/codespell-log.sh

index e0c80428875260318b0a51c11e6b9b2ae19d79f4..3bed91e50f69cf9ce062713e301ef34eb3621831 100644 (file)
@@ -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
index 3873fd7a5a9fa89c0c36e0aa617ffe23bdeeca44..992483d01650d120b2513b5a3120466e20c638b9 100755 (executable)
 # 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