grep: use get_pathspec() correctly
When there is no remaining string in argv, get_pathspec(prefix, argv) will return a two-element array that has prefix as the first element, so there is no need to re-roll that logic in the code that uses get_pathspec(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 9, 2011 at 21:34 UTC
7c5f3cc4a5680e23b8aa378ed9b655a1779ee881
1 file changed
+1
-7
builtin/grep.c
+1
-7
@@ -956,13 +956,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
956
verify_filename(prefix, argv[j]);
957
}
958
959
- if (i < argc)
960
- paths = get_pathspec(prefix, argv + i);
961
- else if (prefix) {
962
- paths = xcalloc(2, sizeof(const char *));
963
- paths[0] = prefix;
964
- paths[1] = NULL;
965
- }
959
+ paths = get_pathspec(prefix, argv + i);
960
init_pathspec(&pathspec, paths);
961
pathspec.max_depth = opt.max_depth;
962
pathspec.recursive = 1;