Merge branch 'rs/grep-omit-blank-lines-after-function-at-eof'

"git grep -W" omits blank lines that follow the found function at
the end of the file, just like it omits blank lines before the next
function.

* rs/grep-omit-blank-lines-after-function-at-eof:
  grep: -W: skip trailing empty lines at EOF, too
This commit is contained in:
Junio C Hamano 2024-08-08 10:41:19 -07:00
commit 984ab11337
2 changed files with 3 additions and 1 deletions

3
grep.c
View file

@ -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 ||

View file

@ -31,6 +31,7 @@ int main(int argc, const char **argv)
return 0;
/* char ?? */
}
EOF
test_expect_success setup '