Code

t9124: clean up chdir usage
[git.git] / builtin-grep.c
index f59f95f1758f891f8068f1d12222d415c6595957..3a51662a35878ae6b5965c90abb747b5b27c5493 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.");