summaryrefslogtreecommitdiff
path: root/ws.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2010-11-24 12:47:27 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-11-24 12:47:27 -0800
commit4713fd9b5d472f94fc6f821ae8581d27da4e8094 (patch)
treee26fcc988f6d9bf9aa19e988e134a4adc67d6c28 /ws.c
parentMerge branch 'jm/mailmap' into maint (diff)
parentdiff: handle lines containing only whitespace and tabs better (diff)
downloadtgif-4713fd9b5d472f94fc6f821ae8581d27da4e8094.tar.xz
Merge branch 'kb/maint-diff-ws-check' into maint
* kb/maint-diff-ws-check: diff: handle lines containing only whitespace and tabs better test-lib: extend test_decode_color to handle more color codes
Diffstat (limited to 'ws.c')
-rw-r--r--ws.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ws.c b/ws.c
index d7b8c33f14..7302f8f5a2 100644
--- a/ws.c
+++ b/ws.c
@@ -174,8 +174,11 @@ static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,
}
}
+ if (trailing_whitespace == -1)
+ trailing_whitespace = len;
+
/* Check indentation */
- for (i = 0; i < len; i++) {
+ for (i = 0; i < trailing_whitespace; i++) {
if (line[i] == ' ')
continue;
if (line[i] != '\t')
@@ -218,8 +221,6 @@ static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,
* Now the rest of the line starts at "written".
* The non-highlighted part ends at "trailing_whitespace".
*/
- if (trailing_whitespace == -1)
- trailing_whitespace = len;
/* Emit non-highlighted (middle) segment. */
if (trailing_whitespace - written > 0) {