diff options
author | Albert Yale <surfingalbert@gmail.com> | 2012-01-23 18:52:44 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-01-23 10:49:34 -0800 |
commit | 50dd0f2fd910d9973760db052897ee8e73ed2f1f (patch) | |
tree | 0a8ed13e4ccf7220759728cb4436644bdfc515c0 /builtin | |
parent | Merge branch 'tr/grep-threading' (diff) | |
download | tgif-50dd0f2fd910d9973760db052897ee8e73ed2f1f.tar.xz |
grep: fix -l/-L interaction with decoration lines
In threaded mode, git-grep emits file breaks (enabled with context, -W
and --break) into the accumulation buffers even if they are not
required. The output collection thread then uses skip_first_line to
skip the first such line in the output, which would otherwise be at
the very top.
This is wrong when the user also specified -l/-L/-c, in which case
every line is relevant. While arguably giving these options together
doesn't make any sense, git-grep has always quietly accepted it. So
do not skip anything in these cases.
Signed-off-by: Albert Yale <surfingalbert@gmail.com>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 9ce064ac11..5c2ae94e55 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -1034,8 +1034,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix) #ifndef NO_PTHREADS if (use_threads) { - if (opt.pre_context || opt.post_context || opt.file_break || - opt.funcbody) + if (!(opt.name_only || opt.unmatch_name_only || opt.count) + && (opt.pre_context || opt.post_context || + opt.file_break || opt.funcbody)) skip_first_line = 1; start_threads(&opt); } |