grep: print context hunk marks between files
Print a hunk mark before matches from a new file are shown, in addition to the current behaviour of printing them if lines have been skipped. The result is easier to read, as (presumably unrelated) matches from different files are separated by a hunk mark. GNU grep does the same. 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
5dd06d3879
commit
046802d015
7
grep.c
7
grep.c
@ -491,7 +491,12 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
|
||||
int rest = eol - bol;
|
||||
|
||||
if (opt->pre_context || opt->post_context) {
|
||||
if (opt->last_shown && lno > opt->last_shown + 1)
|
||||
if (opt->last_shown == 0) {
|
||||
if (opt->show_hunk_mark)
|
||||
fputs("--\n", stdout);
|
||||
else
|
||||
opt->show_hunk_mark = 1;
|
||||
} else if (lno > opt->last_shown + 1)
|
||||
fputs("--\n", stdout);
|
||||
}
|
||||
opt->last_shown = lno;
|
||||
|
||||
Reference in New Issue
Block a user