summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-02-10 13:59:02 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-02-10 13:59:02 -0800
commit184a7aa7bf8e42ce9aba12b92d9cf8014d04a947 (patch)
tree625805572842c984cc7600e4880fdff4549e6558
parentMerge branch 'jl/submodule-re-add' into maint (diff)
parentgrep: fix -l/-L interaction with decoration lines (diff)
downloadtgif-184a7aa7bf8e42ce9aba12b92d9cf8014d04a947.tar.xz
Merge branch 'tr/grep-l-with-decoration' into maint
* tr/grep-l-with-decoration: grep: fix -l/-L interaction with decoration lines
-rw-r--r--builtin/grep.c5
-rwxr-xr-xt/t7810-grep.sh22
2 files changed, 25 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);
}
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
@@ -246,6 +246,28 @@ do
done
cat >expected <<EOF
+file
+EOF
+test_expect_success 'grep -l -C' '
+ git grep -l -C1 foo >actual &&
+ test_cmp expected actual
+'
+
+cat >expected <<EOF
+file:5
+EOF
+test_expect_success 'grep -l -C' '
+ git grep -c -C1 foo >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 <<EOF
file:foo mmap bar_mmap
EOF