Skip to content

Commit

Permalink
t7002: test for not using external grep on skip-worktree paths
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Jan 7, 2010
1 parent cd83ac4 commit 8740773
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions builtin-grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ static int exec_grep(int argc, const char **argv)
int status;

argv[argc] = NULL;
trace_argv_printf(argv, "trace: grep:");
pid = fork();
if (pid < 0)
return pid;
Expand Down
12 changes: 12 additions & 0 deletions t/t7002-grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,16 @@ test_expect_success 'grep -p -B5' '
test_cmp expected actual
'

test_expect_success EXTGREP 'external grep is called' '
GIT_TRACE=2 git grep foo >/dev/null 2>actual &&
grep "trace: grep:.*foo" actual >/dev/null
'

test_expect_success EXTGREP 'no external grep when skip-worktree entries exist' '
git update-index --skip-worktree file &&
GIT_TRACE=2 git grep foo >/dev/null 2>actual &&
! grep "trace: grep:" actual >/dev/null &&
git update-index --no-skip-worktree file
'

test_done

0 comments on commit 8740773

Please sign in to comment.