public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/git: highlight whitespace errors source files
@ 2022-07-18 14:43 Andrew Burgess
  2022-07-18 15:36 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2022-07-18 14:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

For a long time I've had this in my ~/.gitconfig:

  [core]
          whitespace = space-before-tab,indent-with-non-tab,trailing-space

which causes git to show me if I muck up and use spaces instead of
tabs, or leave in trailing whitespace.  I find this really useful.

In this commit I'd like to propose adding something similar to our
three .gitattributes files, and enable whitespace error detection for
all .h, .c, and .cc files.

Errors are highlighted during a diff, for lines being added.
---
 gdb/.gitattributes        | 6 ++++--
 gdbserver/.gitattributes  | 6 +++++-
 gdbsupport/.gitattributes | 5 ++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gdb/.gitattributes b/gdb/.gitattributes
index 8acadb9813e..c9d3dbbc4be 100644
--- a/gdb/.gitattributes
+++ b/gdb/.gitattributes
@@ -2,6 +2,8 @@
 
 # Use cpp-style diffs for .h and .c files.  This is useful
 # if you modify classes defined in those files.
+#
+# Enable highlighting of whitespace errors in .h and .c files.
 
-*.h	diff=cpp
-*.c	diff=cpp
+*.h	diff=cpp whitespace=space-before-tab,indent-with-non-tab,trailing-space
+*.c	diff=cpp whitespace=space-before-tab,indent-with-non-tab,trailing-space
diff --git a/gdbserver/.gitattributes b/gdbserver/.gitattributes
index 6df25746593..5f745545212 100644
--- a/gdbserver/.gitattributes
+++ b/gdbserver/.gitattributes
@@ -2,5 +2,9 @@
 
 # Use cpp-style diffs for .h files.  This is useful
 # if you modify classes defined in a header file.
+#
+# Enable highlighting of whitespace errors in .h and .cc files.
+
+*.h	diff=cpp whitespace=space-before-tab,indent-with-non-tab,trailing-space
+*.cc	whitespace=space-before-tab,indent-with-non-tab,trailing-space
 
-*.h	diff=cpp
diff --git a/gdbsupport/.gitattributes b/gdbsupport/.gitattributes
index 6df25746593..e9d9aee4261 100644
--- a/gdbsupport/.gitattributes
+++ b/gdbsupport/.gitattributes
@@ -2,5 +2,8 @@
 
 # Use cpp-style diffs for .h files.  This is useful
 # if you modify classes defined in a header file.
+#
+# Enable highlighting of whitespace errors in .h and .cc files.
 
-*.h	diff=cpp
+*.h	diff=cpp whitespace=space-before-tab,indent-with-non-tab,trailing-space
+*.cc	whitespace=space-before-tab,indent-with-non-tab,trailing-space
-- 
2.25.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-18 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 14:43 [PATCH] gdb/git: highlight whitespace errors source files Andrew Burgess
2022-07-18 15:36 ` Simon Marchi
2022-07-18 18:08   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).