rm: convert to use parse_pathspec
[gitweb.git] / builtin / grep.c
index 159e65d47a41b56634bc3fb480f9c051d40e692c..4bc075422e3c17e7666ed90e4a35be020586be49 100644 (file)
@@ -17,6 +17,7 @@
 #include "grep.h"
 #include "quote.h"
 #include "dir.h"
+#include "pathspec.h"
 
 static char const * const grep_usage[] = {
        N_("git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]"),
@@ -630,7 +631,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        const char *show_in_pager = NULL, *default_pager = "dummy";
        struct grep_opt opt;
        struct object_array list = OBJECT_ARRAY_INIT;
-       const char **paths = NULL;
        struct pathspec pathspec;
        struct string_list path_list = STRING_LIST_INIT_NODUP;
        int i;
@@ -857,8 +857,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                        verify_filename(prefix, argv[j], j == i);
        }
 
-       paths = get_pathspec(prefix, argv + i);
-       init_pathspec(&pathspec, paths);
+       parse_pathspec(&pathspec, 0,
+                      PATHSPEC_PREFER_CWD |
+                      (opt.max_depth != -1 ? PATHSPEC_MAXDEPTH_VALID : 0),
+                      prefix, argv + i);
        pathspec.max_depth = opt.max_depth;
        pathspec.recursive = 1;