Skip to content

Commit 727c371

Browse files
committed
whitespace: we cannot "catch all errors known to git" anymore
Traditionally, "*.txt whitespace" in .gitattributes file has been an instruction to catch _all_ classes of whitespace errors known to git. This has to change, however, in order to introduce "tab-in-indent" which is inherently incompatible with "indent-with-non-tab". As we do not want to break configuration of existing users, add a mechanism to allow marking selected rules to be excluded from "all rules known to git". Signed-off-by: Chris Webb <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87b3c01 commit 727c371

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ws.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
static struct whitespace_rule {
1111
const char *rule_name;
1212
unsigned rule_bits;
13-
unsigned loosens_error;
13+
unsigned loosens_error:1,
14+
exclude_default:1;
1415
} whitespace_rule_names[] = {
1516
{ "trailing-space", WS_TRAILING_SPACE, 0 },
1617
{ "space-before-tab", WS_SPACE_BEFORE_TAB, 0 },
@@ -82,7 +83,8 @@ unsigned whitespace_rule(const char *pathname)
8283
unsigned all_rule = 0;
8384
int i;
8485
for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++)
85-
if (!whitespace_rule_names[i].loosens_error)
86+
if (!whitespace_rule_names[i].loosens_error &&
87+
!whitespace_rule_names[i].exclude_default)
8688
all_rule |= whitespace_rule_names[i].rule_bits;
8789
return all_rule;
8890
} else if (ATTR_FALSE(value)) {

0 commit comments

Comments
 (0)