[binutils-gdb] [pre-commit] Don't require text type for check-whitespace hook

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c6f29d01de0ee91442f29d5608a1f3332a4ce671

commit c6f29d01de0ee91442f29d5608a1f3332a4ce671
Author: Tom de Vries <[email protected]>
Date:   Tue Aug 25 14:48:26 2026 +0200

    [pre-commit] Don't require text type for check-whitespace hook
    
    The check-whitespace hook has a line:
    ...
    types: ['text']
    ...
    
    Drop this, to make the check-whitespace hook see the same files as git usage
    outside pre-commit:
    ...
    $ git diff-index --cached --check $(git hash-object -t tree /dev/null) gdb*
    ...
    
    Instead, add .gitattributes files in gdb/doc and gdb/testsuite.
    
    https://sourceware.org/bugzilla/show_bug.cgi?id=34411

Diff:
---
 .pre-commit-config.yaml      |  3 ++-
 gdb/doc/.gitattributes       | 10 ++++++++++
 gdb/testsuite/.gitattributes |  4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index bd392a57514..a4a94b0a16f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -126,7 +126,8 @@ repos:
         name: *id2
         language: unsupported_script
         entry: gdb/contrib/check-whitespace-pre-commit.py
-        types: ['text']
+        # Don't filter files on types, allowing this hook to see same files as
+        # git usage outside pre-commit.  Instead, filter files in .gitignore.
         files: *gdb_files
       - id: &id3 pre-commit-setup
         name: *id3
diff --git a/gdb/doc/.gitattributes b/gdb/doc/.gitattributes
new file mode 100644
index 00000000000..735e4eef89a
--- /dev/null
+++ b/gdb/doc/.gitattributes
@@ -0,0 +1,10 @@
+# -*- conf -*-
+
+# Binary format.
+*.pdf  binary
+*.png  binary
+
+# Text format, but diffs aren't useful.
+# Note that stack_frame.eps is an EPS file without embedded bitmap preview.
+*.svg  text -diff
+stack_frame.eps  text -diff
diff --git a/gdb/testsuite/.gitattributes b/gdb/testsuite/.gitattributes
new file mode 100644
index 00000000000..97a376c1938
--- /dev/null
+++ b/gdb/testsuite/.gitattributes
@@ -0,0 +1,4 @@
+# -*- conf -*-
+
+# Binary format.
+*.bz2  binary
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.