summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 13bf1a9)
raw | patch | inline | side by side (parent: 13bf1a9)
author | Junio C Hamano <gitster@pobox.com> | |
Sat, 16 Feb 2008 04:30:05 +0000 (20:30 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 16 Feb 2008 07:06:57 +0000 (23:06 -0800) |
c1795bb (Unify whitespace checking) incorrectly made the
checking function return without incrementing the line numbers
when there is no whitespace problem is found on a '+' line.
This resurrects the earlier behaviour.
Noticed and reported by Jay Soffian. The test script was stolen
from Jay's independent fix.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
checking function return without incrementing the line numbers
when there is no whitespace problem is found on a '+' line.
This resurrects the earlier behaviour.
Noticed and reported by Jay Soffian. The test script was stolen
from Jay's independent fix.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history | |
t/t4015-diff-whitespace.sh | patch | blob | history |
index f082f55bc524dae92c8d57fe0dc9e9c8e3f2d59a..39f6e21aa39db53b3d72cb221156b92267272033 100644 (file)
--- a/diff.c
+++ b/diff.c
char *err;
if (line[0] == '+') {
+ data->lineno++;
data->status = check_and_emit_line(line + 1, len - 1,
data->ws_rule, NULL, NULL, NULL, NULL);
if (!data->status)
emit_line(set, reset, line, 1);
(void)check_and_emit_line(line + 1, len - 1, data->ws_rule,
stdout, set, reset, ws);
- data->lineno++;
} else if (line[0] == ' ')
data->lineno++;
else if (line[0] == '@') {
char *plus = strchr(line, '+');
if (plus)
- data->lineno = strtol(plus, NULL, 10);
+ data->lineno = strtol(plus, NULL, 10) - 1;
else
die("invalid diff");
}
index d30169fbdcafdf51561f024e887f05aa800fc9d4..83c54b747f4efe1f99b67284a7ba72b89df07a6d 100755 (executable)
@@ -326,4 +326,13 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab:
! git diff --check
'
+
+test_expect_success 'line numbers in --check output are correct' '
+
+ echo "" > x &&
+ echo "foo(); " >> x &&
+ git diff --check | grep "x:2:"
+
+'
+
test_done