grep: add --break
With --break, an empty line is printed between matches from different files, increasing readability. This option is taken from ack (http://betterthangrep.com/). Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
08303c3636
commit
a8f0e7649e
7
grep.c
7
grep.c
@ -721,7 +721,10 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
|
||||
int rest = eol - bol;
|
||||
char *line_color = NULL;
|
||||
|
||||
if (opt->pre_context || opt->post_context) {
|
||||
if (opt->file_break && opt->last_shown == 0) {
|
||||
if (opt->show_hunk_mark)
|
||||
opt->output(opt, "\n", 1);
|
||||
} else if (opt->pre_context || opt->post_context) {
|
||||
if (opt->last_shown == 0) {
|
||||
if (opt->show_hunk_mark) {
|
||||
output_color(opt, "--", 2, opt->color_sep);
|
||||
@ -941,7 +944,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
|
||||
if (!opt->output)
|
||||
opt->output = std_output;
|
||||
|
||||
if (opt->pre_context || opt->post_context) {
|
||||
if (opt->pre_context || opt->post_context || opt->file_break) {
|
||||
/* Show hunk marks, except for the first file. */
|
||||
if (opt->last_shown)
|
||||
opt->show_hunk_mark = 1;
|
||||
|
||||
Reference in New Issue
Block a user