From 4aa2c4753d152aef810eaf3f3f4fa1df7035d9b0 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Sat, 28 May 2016 17:06:19 +0200 Subject: grep: -W: don't extend context to trailing empty lines Empty lines between functions are shown by grep -W, as it considers them to be part of the function preceding them. They are not interesting in most languages. The previous patches stopped showing them for diff -W. Stop showing empty lines trailing a function with grep -W. Grep scans the lines of a buffer from top to bottom and prints matching lines immediately. Thus we need to peek ahead in order to determine if an empty line is part of a function body and worth showing or not. Remember how far ahead we peeked in order to avoid having to do so repeatedly when handling multiple consecutive empty lines. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index c42b82ae52..befbde44f4 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -748,7 +748,7 @@ hello.c-#include hello.c:#include EOF -test_expect_failure 'grep -W shows no trailing empty lines' ' +test_expect_success 'grep -W shows no trailing empty lines' ' git grep -W stdio >actual && test_cmp expected actual ' -- cgit v1.3