binutils-gdb/git: highlight whitespace errors in source files
authorAndrew Burgess <aburgess@redhat.com>
Mon, 18 Jul 2022 14:35:40 +0000 (15:35 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Mon, 25 Jul 2022 13:35:41 +0000 (14:35 +0100)
commitf7f904e4fda6fb571d40a3547ed03ec6028e6694
treed1138d480bbd07c01ac4506fbff2ad21ca8e6001
parenta6e4a48c02acf29d6bec2ff63fc909b57cf4bc78
binutils-gdb/git: highlight whitespace errors in source files

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.

I recently proposed adding something like this to the .gitattributes
files for the GDB sub-directories (gdb, gdbsupport, and gdbserver)[1],
however, the question was asked - couldn't this be done at the top
level?

So, in this commit, I propose to update the top-level .gitattributes
file, after this commit, any git diff on a C, C++, Expect, or TCL
source file, will highlight the following whitespace errors:

  (a) Use a space before a tab at the start of a line,

  (b) Use of spaces where a tab could be used at the start of a line,
  and

  (c) Any trailing whitespace.

Errors are only highlighted in the diff on new or modified lines, so
you don't get spammed for errors on context lines that you haven't
modified.

The only downside I see to adding this at the top level is if there
are any sub-directories that don't follow the tabs/spaces indentation
rules very well already, in those directories you'll end up hitting
issues any time you edit a line.  For GDB we're usually pretty good,
so having this highlighting isn't an issue.

[1] https://sourceware.org/pipermail/gdb-patches/2022-July/190843.html
.gitattributes