Skip to content

Commit

Permalink
Merge branch 'tr/grep-l-with-decoration'
Browse files Browse the repository at this point in the history
* tr/grep-l-with-decoration:
  grep: fix -l/-L interaction with decoration lines
  • Loading branch information
gitster committed Feb 1, 2012
2 parents fc75ad7 + 50dd0f2 commit 3e9e416
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
22 changes: 22 additions & 0 deletions t/t7810-grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,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
Expand Down

0 comments on commit 3e9e416

Please sign in to comment.