]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-grep.c
grep: fix worktree setup
[git.git] / builtin-grep.c
index 631129ddfd0ffe06f919882d22cfc494d9553f50..3ded1ba9da9166c09fb1b65d315499e24036466d 100644 (file)
@@ -783,8 +783,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                paths[1] = NULL;
        }
 
-       if (!list.nr)
+       if (!list.nr) {
+               if (!cached)
+                       setup_work_tree();
                return !grep_cache(&opt, paths, cached);
+       }
 
        if (cached)
                die("both --cached and trees are given.");