Skip to content

Commit

Permalink
grep: use get_pathspec() correctly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed May 10, 2011
1 parent b060ce7 commit 7c5f3cc
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7c5f3cc

Please sign in to comment.