]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-grep.c
grep: fix worktree setup
[git.git] / builtin-grep.c
index 647535061c350b68f1583fc12b049a37eb17481c..3ded1ba9da9166c09fb1b65d315499e24036466d 100644 (file)
@@ -498,7 +498,7 @@ static int grep_object(struct grep_opt *opt, const char **paths,
 }
 
 static const char builtin_grep_usage[] =
-"git-grep <option>* <rev>* [-e] <pattern> [<path>...]";
+"git grep <option>* [-e] <pattern> <rev>* [[--] <path>...]";
 
 static const char emsg_invalid_context_len[] =
 "%s: invalid context length argument";
@@ -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.");