author | Junio C Hamano <gitster@pobox.com> | |
Wed, 1 Feb 2012 06:01:15 +0000 (22:01 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 1 Feb 2012 06:01:15 +0000 (22:01 -0800) |
* tr/grep-l-with-decoration:
grep: fix -l/-L interaction with decoration lines
grep: fix -l/-L interaction with decoration lines
builtin/grep.c | patch | blob | history | |
t/t7810-grep.sh | patch | blob | history |
diff --git a/builtin/grep.c b/builtin/grep.c
index 9ce064ac1131e9a93383f568bb6f567791740b77..5c2ae94e5576f2e8af1f8509b789a67851db2598 100644 (file)
--- a/builtin/grep.c
+++ b/builtin/grep.c
#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 7ba5b16f99443c0dc5aaff8fbb4ce4ad8874a27c..75f4716d8cbca0c295668e181a557b186cb37432 100755 (executable)
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
'
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