[openwrt/openwrt] .gitattributes: ignore some whitespace "violations" in .patch files
LEDE Commits
lede-commits at lists.infradead.org
Thu Dec 12 03:17:29 PST 2024
blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/ebf1866d091d5f4994cf104ab248782f90df2c88
commit ebf1866d091d5f4994cf104ab248782f90df2c88
Author: Mark Mentovai <mark at mentovai.com>
AuthorDate: Fri Jul 26 23:28:36 2024 -0400
.gitattributes: ignore some whitespace "violations" in .patch files
git's default core.whitespace[1] setting doesn't agree with .patch
files. This causes whitespace warnings when running `git apply`,
(including via `git am`) and causes red highlighting when viewing diffs
to .patch files via `git diff` (including via `git show`) when
outputting to a terminal.
These types of whitespace “violations” will now be explicitly disabled
for .patch files in the repository-wide .gitattributes file to prevent
git from suggesting that there’s anything wrong with checked-in .patch
files.
A .patch file will naturally have `space-before-tab` if a context line
(not a +/- line) begins with a tab character (as is common in patches to
files that use the tab indent convention), and will also naturally have
`trailing-space` if a context line is blank (also common).
Neither `indent-with-non-tab` nor `tab-in-indent` are enabled in
core.whitespace by default, but could also occur naturally in .patch
files, and are also explicitly disabled here for completeness to cover
cases where they may be enabled in core.whitespace at the global or
system level.
These false violations may be flagged frequently in OpenWrt, because the
repository contains many .patch files. There are currently just over
5,000 .patch files, representing slightly more than half of all files.
[1] https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_whitespace
Link: https://github.com/openwrt/openwrt/pull/16012
Signed-off-by: Mark Mentovai <mark at mentovai.com>
Link: https://github.com/openwrt/openwrt/pull/16015
Signed-off-by: John Crispin <john at phrozen.org>
---
.gitattributes | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitattributes b/.gitattributes
index fa1385d99a..ab4772b9c6 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
* -text
+*.patch whitespace=-indent-with-non-tab,-space-before-tab,-tab-in-indent,-trailing-space
More information about the lede-commits
mailing list