summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-10 04:34:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-10 19:11:01 (GMT)
commit7c5f3cc4a5680e23b8aa378ed9b655a1779ee881 (patch)
treeb377208b26e47dbca5a74171b45684f3cdaf0e2c /builtin
parentb060ce7de42b357af013909039da3f08a68f3c0b (diff)
downloadgit-7c5f3cc4a5680e23b8aa378ed9b655a1779ee881.zip
git-7c5f3cc4a5680e23b8aa378ed9b655a1779ee881.tar.gz
git-7c5f3cc4a5680e23b8aa378ed9b655a1779ee881.tar.bz2
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/grep.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 0bf8c01..222dd6d 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -956,13 +956,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
verify_filename(prefix, argv[j]);
}
- if (i < argc)
- paths = get_pathspec(prefix, argv + i);
- else if (prefix) {
- paths = xcalloc(2, sizeof(const char *));
- paths[0] = prefix;
- paths[1] = NULL;
- }
+ paths = get_pathspec(prefix, argv + i);
init_pathspec(&pathspec, paths);
pathspec.max_depth = opt.max_depth;
pathspec.recursive = 1;