diff options
| author | René Scharfe <l.s.r@web.de> | 2024-07-30 16:18:54 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-07-30 09:59:04 -0700 |
| commit | 8e5dd94e68e37d2d4b67e34db00b9e9790a2325b (patch) | |
| tree | 94a6961f8769c7c4a9d968be2b31cdaecc98811d | |
| parent | Yet another batch of post 2.45.2 updates from the 'master' front (diff) | |
| download | git-8e5dd94e68e37d2d4b67e34db00b9e9790a2325b.tar.gz git-8e5dd94e68e37d2d4b67e34db00b9e9790a2325b.zip | |
grep: -W: skip trailing empty lines at EOF, too
4aa2c4753d (grep: -W: don't extend context to trailing empty lines,
2016-05-28) stopped showing empty lines at the end of function context
when using -W. Do the same for trailing empty lines at the end of
files, for consistency -- it doesn't matter whether a function section
is ended by the next function or the end of the file.
Test it by adding a trailing empty line to the file used by the test
"grep -W" and leave its expected output the same.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | grep.c | 3 | ||||
| -rwxr-xr-x | t/t7810-grep.sh | 1 |
2 files changed, 3 insertions, 1 deletions
@@ -1735,7 +1735,8 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle peek_eol = end_of_line(peek_bol, &peek_left); } - if (match_funcname(opt, gs, peek_bol, peek_eol)) + if (peek_bol >= gs->buf + gs->size || + match_funcname(opt, gs, peek_bol, peek_eol)) show_function = 0; } if (show_function || diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 875dcfd98f..af2cf2f78a 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -31,6 +31,7 @@ int main(int argc, const char **argv) return 0; /* char ?? */ } + EOF test_expect_success setup ' |
