mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
f7f904e4fd
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
36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
# -*- conf -*-
|
|
|
|
## Set merge driver for ChangeLog files
|
|
# See gnulib's lib/git-merge-changelog.c (or git-merge-changelog(1))
|
|
# for per-user setup instructions.
|
|
#
|
|
# The short version of this (optional) procedure is:
|
|
#
|
|
# (1) Install git-merge-changelog (this is the tricky part!)
|
|
#
|
|
# (2) Add something like the following to your ~/.gitconfig:
|
|
#
|
|
# [merge "merge-changelog"]
|
|
# name = GNU-style ChangeLog merge driver
|
|
# driver = git-merge-changelog %O %A %B
|
|
#
|
|
# (3) Enjoy mostly effortless ChangeLog merges, at least until the
|
|
# file gets renamed again ...
|
|
|
|
ChangeLog merge=merge-changelog
|
|
|
|
# Setup whitespace error detection.
|
|
#
|
|
# (1) Spaces before tabs,
|
|
#
|
|
# (2) Use of spaces where a tab should be used,
|
|
#
|
|
# (3) Trailing whitespace,
|
|
|
|
*.cxx whitespace=space-before-tab,indent-with-non-tab,trailing-space
|
|
*.cc whitespace=space-before-tab,indent-with-non-tab,trailing-space
|
|
*.cpp whitespace=space-before-tab,indent-with-non-tab,trailing-space
|
|
*.[cChH] whitespace=space-before-tab,indent-with-non-tab,trailing-space
|
|
*.exp whitespace=space-before-tab,indent-with-non-tab,trailing-space
|
|
*.tcl whitespace=space-before-tab,indent-with-non-tab,trailing-space
|