summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a9cc857)
raw | patch | inline | side by side (parent: a9cc857)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 3 Oct 2007 01:00:27 +0000 (18:00 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 3 Nov 2007 00:58:09 +0000 (17:58 -0700) |
This introduces a new whitespace error type, "indent-with-non-tab".
The error is about starting a line with 8 or more SP, instead of
indenting it with a HT.
This is not enabled by default, as some projects employ an
indenting policy to use only SPs and no HTs.
The kernel folks and git contributors may want to enable this
detection with:
[core]
whitespace = indent-with-non-tab
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The error is about starting a line with 8 or more SP, instead of
indenting it with a HT.
This is not enabled by default, as some projects employ an
indenting policy to use only SPs and no HTs.
The kernel folks and git contributors may want to enable this
detection with:
[core]
whitespace = indent-with-non-tab
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
config.c | patch | blob | history | |
diff.c | patch | blob | history |
index a6e5988f0778803f11de7b7b440e15f75372d6de..3f4282795e4bffd9e9c07a692155995435a14044 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -608,6 +608,7 @@ void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, i
*/
#define WS_TRAILING_SPACE 01
#define WS_SPACE_BEFORE_TAB 02
+#define WS_INDENT_WITH_NON_TAB 04
#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB)
extern unsigned whitespace_rule;
diff --git a/config.c b/config.c
index ffb418ccffc751ef87d8534264fa56b1ca8a6683..d5b976696c31e6287f43c44c974e0fe0e9c73149 100644 (file)
--- a/config.c
+++ b/config.c
} whitespace_rule_names[] = {
{ "trailing-space", WS_TRAILING_SPACE },
{ "space-before-tab", WS_SPACE_BEFORE_TAB },
+ { "indent-with-non-tab", WS_INDENT_WITH_NON_TAB },
};
static unsigned parse_whitespace_rule(const char *string)
index 211235376de2166593945a646dcfa97405dc74d0..6bb902f4af75d37647a434d4b1efb2a1d33d144f 100644 (file)
--- a/diff.c
+++ b/diff.c
int i;
int tail = len;
int need_highlight_leading_space = 0;
- /* The line is a newly added line. Does it have funny leading
- * whitespaces? In indent, SP should never precede a TAB.
+ /*
+ * The line is a newly added line. Does it have funny leading
+ * whitespaces? In indent, SP should never precede a TAB. In
+ * addition, under "indent with non tab" rule, there should not
+ * be more than 8 consecutive spaces.
*/
for (i = col0; i < len; i++) {
if (line[i] == '\t') {
else
break;
}
+ if ((whitespace_rule & WS_INDENT_WITH_NON_TAB) &&
+ 0 <= last_space_in_indent &&
+ last_tab_in_indent < 0 &&
+ 8 <= (i - col0)) {
+ last_tab_in_indent = i;
+ need_highlight_leading_space = 1;
+ }
fputs(set, stdout);
fwrite(line, col0, 1, stdout);
fputs(reset, stdout);