grep: print context hunk marks between files
[gitweb.git] / grep.c
diff --git a/grep.c b/grep.c
index 6ee80f7fd9b014a0855f9eadb24cb71b9b97836f..4bca759b67e2d386ae87975780b0272209cc2942 100644 (file)
--- 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;