Skip to content

Commit a437900

Browse files
committed
attribute: whitespace set to true detects all errors known to git
That is what the documentation says, but the code pretends as if all the known whitespace error tokens were given. Among the whitespace error tokens, there is one kind that loosens the rule when set: cr-at-eol. Which means that whitespace error token that is set to true ignores a newly introduced CR at the end, which is inconsistent with the documentation. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e2f6331 commit a437900

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

ws.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
static struct whitespace_rule {
1111
const char *rule_name;
1212
unsigned rule_bits;
13+
unsigned loosens_error;
1314
} whitespace_rule_names[] = {
14-
{ "trailing-space", WS_TRAILING_SPACE },
15-
{ "space-before-tab", WS_SPACE_BEFORE_TAB },
16-
{ "indent-with-non-tab", WS_INDENT_WITH_NON_TAB },
17-
{ "cr-at-eol", WS_CR_AT_EOL },
15+
{ "trailing-space", WS_TRAILING_SPACE, 0 },
16+
{ "space-before-tab", WS_SPACE_BEFORE_TAB, 0 },
17+
{ "indent-with-non-tab", WS_INDENT_WITH_NON_TAB, 0 },
18+
{ "cr-at-eol", WS_CR_AT_EOL, 1 },
1819
};
1920

2021
unsigned parse_whitespace_rule(const char *string)
@@ -79,7 +80,8 @@ unsigned whitespace_rule(const char *pathname)
7980
unsigned all_rule = 0;
8081
int i;
8182
for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++)
82-
all_rule |= whitespace_rule_names[i].rule_bits;
83+
if (!whitespace_rule_names[i].loosens_error)
84+
all_rule |= whitespace_rule_names[i].rule_bits;
8385
return all_rule;
8486
} else if (ATTR_FALSE(value)) {
8587
/* false (-whitespace) */

0 commit comments

Comments
 (0)