summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorWincent Colaiuta <win@wincent.com>2007-12-12 16:22:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-12-12 19:24:33 (GMT)
commit86f8c2368523db5ee56c8856748b26c31ebeb0aa (patch)
tree67b964850ce5906c98893530f59ccff249843a22 /diff.c
parentf604652e05073aaef6d83e83b5d6499b55bb6dfd (diff)
downloadgit-86f8c2368523db5ee56c8856748b26c31ebeb0aa.zip
git-86f8c2368523db5ee56c8856748b26c31ebeb0aa.tar.gz
git-86f8c2368523db5ee56c8856748b26c31ebeb0aa.tar.bz2
Fix "diff --check" whitespace detection
"diff --check" would only detect spaces before tabs if a tab was the last character in the leading indent. Fix that and add a test case to make sure the bug doesn't regress in the future. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index d97ebc5..9c79ee2 100644
--- a/diff.c
+++ b/diff.c
@@ -1044,11 +1044,18 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
int i, spaces = 0, space_before_tab = 0, white_space_at_end = 0;
/* check space before tab */
- for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++)
+ for (i = 1; i < len; i++) {
if (line[i] == ' ')
spaces++;
- if (line[i - 1] == '\t' && spaces)
- space_before_tab = 1;
+ else if (line[i] == '\t') {
+ if (spaces) {
+ space_before_tab = 1;
+ break;
+ }
+ }
+ else
+ break;
+ }
/* check whitespace at line end */
if (line[len - 1] == '\n')