@matheusbsbs / matheus-bagliano / commits / 4d9697c787
Fork 0

whitespace: fix off-by-one error in non-space-in-indent checking

If there were no tabs, and the last space was at position 7, then positions 0..7 had spaces, so there were 8 spaces. Update test to check exactly this case. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

J. Bruce Fields committed Dec 16, 2007 at 11:31 UTC 4d9697c7871e513712eb9cfd30611049b10e5132
2 files changed +3 -3
t/t4015-diff-whitespace.sh
+2 -2
@@ -298,7 +298,7 @@ test_expect_success 'check space before tab in indent (space-before-tab: on)' '
298 test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
299
300 git config core.whitespace "-indent-with-non-tab"
301 - echo " foo ();" > x &&
301 + echo " foo ();" > x &&
302 git diff --check
303
304 '
@@ -306,7 +306,7 @@ test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
306 test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
307
308 git config core.whitespace "indent-with-non-tab" &&
309 - echo " foo ();" > x &&
309 + echo " foo ();" > x &&
310 ! git diff --check
311
312 '
ws.c
+1 -1
@@ -159,7 +159,7 @@ unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
159 }
160
161 /* Check for indent using non-tab. */
162 - if ((ws_rule & WS_INDENT_WITH_NON_TAB) && leading_space >= 8)
162 + if ((ws_rule & WS_INDENT_WITH_NON_TAB) && leading_space >= 7)
163 result |= WS_INDENT_WITH_NON_TAB;
164
165 if (stream) {