summaryrefslogtreecommitdiff
path: root/ws.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-11-17 15:01:47 -0800
committerJunio C Hamano <gitster@pobox.com>2010-11-17 15:01:47 -0800
commit44e4155f8356a33e04a23b37a111bb4af0a8b060 (patch)
tree73afd89c86acefa95587e3f1cd6e0ad40d0b284e /ws.c
parent016c4b8919a0a58a430f3483aeac35de9dfdc579 (diff)
parentcfd1a9849cdb4b9c7fcd0cb71a28cbdbc3494329 (diff)
downloadgit-44e4155f8356a33e04a23b37a111bb4af0a8b060.tar.gz
Merge branch 'kb/maint-diff-ws-check'
* 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) {