Code

everyday: use the dashless form of git-init
[git.git] / builtin-grep.c
index 631129ddfd0ffe06f919882d22cfc494d9553f50..d3cc75e3a47bed0d44d1981a6f609f24558a9e1b 100644 (file)
@@ -289,6 +289,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
                push_arg("-E");
        if (opt->regflags & REG_ICASE)
                push_arg("-i");
+       if (opt->binary == GREP_BINARY_NOMATCH)
+               push_arg("-I");
        if (opt->word_regexp)
                push_arg("-w");
        if (opt->name_only)
@@ -774,7 +776,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                        /* Make sure we do not get outside of paths */
                        for (i = 0; paths[i]; i++)
                                if (strncmp(prefix, paths[i], opt.prefix_length))
-                                       die("git-grep: cannot generate relative filenames containing '..'");
+                                       die("git grep: cannot generate relative filenames containing '..'");
                }
        }
        else if (prefix) {
@@ -783,8 +785,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.");