t4051: add test for comments preceding function lines
authorRené Scharfe <l.s.r@web.de>
Sat, 18 Nov 2017 18:04:00 +0000 (19:04 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Nov 2017 00:36:06 +0000 (09:36 +0900)
When showing function context it would be helpful to show comments
immediately before declarations, as they are most likely relevant.

Add a test for that, but without specifying the choice of lines too
rigidly in the test---we may want to stop before and not include
"/*" in the future, for example.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4051-diff-function-context.sh
t/t4051/hello.c
index 3e6b485ecba1a59e3d69edc3ac5a6f0f1d327bd3..30fc5bf2b36d815d6a43f2b439f938b81a8816ca 100755 (executable)
@@ -85,6 +85,10 @@ test_expect_success 'setup' '
 
 check_diff changed_hello 'changed function'
 
+test_expect_failure ' context includes comment' '
+       grep "^ .*Hello comment" changed_hello.diff
+'
+
 test_expect_success ' context includes begin' '
        grep "^ .*Begin of hello" changed_hello.diff
 '
index 63b1a1e4efbb4c5dee315ba56a6ad0658da0a9a5..73e767e1783d8ab97d7a45297a173b1bed9f00a2 100644 (file)
@@ -1,4 +1,7 @@
 
+/*
+ * Hello comment.
+ */
 static void hello(void)        // Begin of hello
 {
        /*