From 046802d015b3be2e055ae68f29f76741023bc32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 2 Jul 2009 00:03:44 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- grep.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'grep.c') diff --git a/grep.c b/grep.c index 6ee80f7fd9..4bca759b67 100644 --- a/grep.c +++ b/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; -- cgit v1.2.3