aboutsummaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2009-07-02 00:03:44 +0200
committerJunio C Hamano <gitster@pobox.com>2009-07-01 19:16:46 -0700
commit046802d015b3be2e055ae68f29f76741023bc32d (patch)
treed65f59ba86ab3ba0932b02d2ab835575c08a8f09 /grep.c
parent5dd06d38795b2f6d05f851b25c814732238f8df1 (diff)
downloadgit-046802d015b3be2e055ae68f29f76741023bc32d.tar.gz
git-046802d015b3be2e055ae68f29f76741023bc32d.tar.xz
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>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/grep.c b/grep.c
index 6ee80f7fd..4bca759b6 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;