summaryrefslogtreecommitdiff
path: root/builtin-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 /builtin-grep.c
parent5dd06d38795b2f6d05f851b25c814732238f8df1 (diff)
downloadgit-046802d015b3be2e055ae68f29f76741023bc32d.tar.gz
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 'builtin-grep.c')
-rw-r--r--builtin-grep.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index 73fc922c49..48998af911 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -278,6 +278,17 @@ static int flush_grep(struct grep_opt *opt,
argc -= 2;
}
+ if (opt->pre_context || opt->post_context) {
+ /*
+ * grep handles hunk marks between files, but we need to
+ * do that ourselves between multiple calls.
+ */
+ if (opt->show_hunk_mark)
+ write_or_die(1, "--\n", 3);
+ else
+ opt->show_hunk_mark = 1;
+ }
+
status = exec_grep(argc, argv);
if (kept_0) {