Skip to content

Commit 8740773

Browse files
pcloudsgitster
authored andcommitted
t7002: test for not using external grep on skip-worktree paths
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd83ac4 commit 8740773

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

builtin-grep.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ static int exec_grep(int argc, const char **argv)
232232
int status;
233233

234234
argv[argc] = NULL;
235+
trace_argv_printf(argv, "trace: grep:");
235236
pid = fork();
236237
if (pid < 0)
237238
return pid;

t/t7002-grep.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,16 @@ test_expect_success 'grep -p -B5' '
340340
test_cmp expected actual
341341
'
342342

343+
test_expect_success EXTGREP 'external grep is called' '
344+
GIT_TRACE=2 git grep foo >/dev/null 2>actual &&
345+
grep "trace: grep:.*foo" actual >/dev/null
346+
'
347+
348+
test_expect_success EXTGREP 'no external grep when skip-worktree entries exist' '
349+
git update-index --skip-worktree file &&
350+
GIT_TRACE=2 git grep foo >/dev/null 2>actual &&
351+
! grep "trace: grep:" actual >/dev/null &&
352+
git update-index --no-skip-worktree file
353+
'
354+
343355
test_done

0 commit comments

Comments
 (0)