From 50dd0f2fd910d9973760db052897ee8e73ed2f1f Mon Sep 17 00:00:00 2001 From: Albert Yale Date: Mon, 23 Jan 2012 18:52:44 +0100 Subject: 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 Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 7ba5b16f99..75f4716d8c 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -245,6 +245,28 @@ do ' done +cat >expected <actual && + test_cmp expected actual +' + +cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'grep -L -C' ' + git ls-files >expected && + git grep -L -C1 nonexistent_string >actual && + test_cmp expected actual +' + cat >expected <