diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-09-03 23:39:43 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-09-04 11:50:27 -0700 |
commit | 467babf8d059caee9587567452fc8b46505b4e67 (patch) | |
tree | 9038af337fc9d8ea487e0e1420c3080604dbe200 /t | |
parent | diff --whitespace=warn/error: obey blank-at-eof (diff) | |
download | tgif-467babf8d059caee9587567452fc8b46505b4e67.tar.xz |
diff --whitespace=warn/error: fix blank-at-eof check
The "diff --check" logic used to share the same issue as the one fixed for
"git apply" earlier in this series, in that a patch that adds new blank
lines at end could appear as
@@ -l,5 +m,7 @@$
_context$
_context$
-deleted$
+$
+$
+$
_$
_$
where _ stands for SP and $ shows a end-of-line. Instead of looking at
each line in the patch in the callback, simply count the blank lines from
the end in two versions, and notice the presence of new ones.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t4015-diff-whitespace.sh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index a5d4461574..e0b481d42b 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -341,6 +341,13 @@ test_expect_success 'checkdiff detects new trailing blank lines (1)' ' git diff --check | grep "new blank line" ' +test_expect_success 'checkdiff detects new trailing blank lines (2)' ' + { echo a; echo b; echo; echo; } >x && + git add x && + { echo a; echo; echo; echo; echo; } >x && + git diff --check | grep "new blank line" +' + test_expect_success 'checkdiff allows new blank lines' ' git checkout x && mv x y && |