t7002: test for not using external grep on skip-worktree paths
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Mon, 4 Jan 2010 12:34:15 +0000 (19:34 +0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Jan 2010 02:29:23 +0000 (18:29 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-grep.c
t/t7002-grep.sh

index 25ee75d989d80382e370b5460f3d8f64ae086f6e..04ac60a29a55189d2c757a0a205b4cc0e7ece9da 100644 (file)
@@ -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;
index 23eeb767f97d9640c44e48d396d1b76afb0fa5b9..99142fd6bda0e9c241bad1c18a18583b30fda700 100755 (executable)
@@ -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