From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH] gdb/git: highlight whitespace errors source files
Date: Mon, 18 Jul 2022 15:43:59 +0100 [thread overview]
Message-ID: <20220718144359.1473453-1-aburgess@redhat.com> (raw)
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
next reply other threads:[~2022-07-18 14:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 14:43 Andrew Burgess [this message]
2022-07-18 15:36 ` Simon Marchi
2022-07-18 18:08 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220718144359.1473453-1-aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).