]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t4015: improve coverage of function context test
authorRené Scharfe <l.s.r@web.de>
Thu, 19 Dec 2019 17:35:43 +0000 (18:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Dec 2019 18:35:21 +0000 (10:35 -0800)
Add a test that includes an actual function line in the test file to
check if context is expanded to include the whole function, and add an
ignored change before function context to check if that one stays hidden
while the originally ignored change within function context is shown.

This differs from the existing test, which is concerned with the case
where there is no function line at all in the file (and we might look
past the beginning of the file).

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4015-diff-whitespace.sh

index 4a7254ec5f2e822cf643ab3cfa6434e95cbebd04..a723c28d0e52c74edc1a5c588a147fe211f45ac9 100755 (executable)
@@ -2026,4 +2026,27 @@ test_expect_success 'combine --ignore-blank-lines with --function-context' '
        test_cmp expect actual
 '
 
+test_expect_success 'combine --ignore-blank-lines with --function-context 2' '
+       test_write_lines    a b c "" function 1 2 3 4 5 "" 6 7 8 9 >a &&
+       test_write_lines "" a b c "" function 1 2 3 4 5    6 7 8   >b &&
+       test_must_fail git diff --no-index \
+               --ignore-blank-lines --function-context a b >actual.raw &&
+       sed -n "/@@/,\$p" <actual.raw >actual &&
+       cat <<-\EOF >expect &&
+       @@ -5,11 +6,9 @@ c
+        function
+        1
+        2
+        3
+        4
+        5
+       -
+        6
+        7
+        8
+       -9
+       EOF
+       test_cmp expect actual
+'
+
 test_done