Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diff.c13
-rwxr-xr-xt/t4015-diff-whitespace.sh9
2 files changed, 19 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index d97ebc501a..9c79ee2891 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')
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 79fdff3f3a..6adf9d11d0 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -117,4 +117,13 @@ EOF
git diff -b > out
test_expect_success 'another test, with -b' 'git diff expect out'
+
+test_expect_success 'check mixed spaces and tabs in indent' '
+
+ # This is indented with SP HT SP.
+ echo " foo();" > x &&
+ git diff --check | grep "space before tab"
+
+'
+
test_done