summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2011-06-05 17:24:15 +0200
committerJunio C Hamano <gitster@pobox.com>2011-06-05 18:10:50 -0700
commit08303c3636ef750bfafd1c47f363120cb439b367 (patch)
tree4f6f843c4e7381b2c066d7f837ae3a406ca0fffd /grep.c
parenta6605d76cdad37ed3c55a7be4d2e0af0f4721bb2 (diff)
downloadgit-08303c3636ef750bfafd1c47f363120cb439b367.tar.gz
grep: fix coloring of hunk marks between files
Commit 431d6e7b (grep: enable threading for context line printing) split the printing of the "--\n" mark between results from different files out into two places: show_line() in grep.c for the non-threaded case and work_done() in builtin/grep.c for the threaded case. Commit 55f638bd (grep: Colorize filename, line number, and separator) updated the former, but not the latter, so the separators between files are not colored if threads are used. This patch merges the two. In the threaded case, hunk marks are now printed by show_line() for every file, including the first one, and the very first mark is simply skipped in work_done(). This ensures that the output is properly colored and works just as well. 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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/grep.c b/grep.c
index d03d9e24c2..3f15085d0e 100644
--- a/grep.c
+++ b/grep.c
@@ -941,9 +941,18 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
if (!opt->output)
opt->output = std_output;
- if (opt->last_shown && (opt->pre_context || opt->post_context) &&
- opt->output == std_output)
- opt->show_hunk_mark = 1;
+ if (opt->pre_context || opt->post_context) {
+ /* Show hunk marks, except for the first file. */
+ if (opt->last_shown)
+ opt->show_hunk_mark = 1;
+ /*
+ * If we're using threads then we can't easily identify
+ * the first file. Always put hunk marks in that case
+ * and skip the very first one later in work_done().
+ */
+ if (opt->output != std_output)
+ opt->show_hunk_mark = 1;
+ }
opt->last_shown = 0;
switch (opt->binary) {