[PATCH] gdb/git: highlight whitespace errors source files
Andrew Burgess
aburgess@redhat.com
Mon Jul 18 14:43:59 GMT 2022
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
More information about the Gdb-patches
mailing list