convert some get_pathspec() calls to parse_pathspec()
These call sites follow the pattern: paths = get_pathspec(prefix, argv); init_pathspec(&pathspec, paths); which can be converted into a single parse_pathspec() call. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jul 14, 2013 at 15:35 UTC
0fdc2ae5125b61e5cfe0cd49b064d8367994e61b
4 files changed
+17
-8
builtin/grep.c
+3
-3
@@ -631,7 +631,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
631
const char *show_in_pager = NULL, *default_pager = "dummy";
632
struct grep_opt opt;
633
struct object_array list = OBJECT_ARRAY_INIT;
634
- const char **paths = NULL;
634
struct pathspec pathspec;
635
struct string_list path_list = STRING_LIST_INIT_NODUP;
636
int i;
@@ -858,8 +857,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
857
verify_filename(prefix, argv[j], j == i);
858
}
859
861
- paths = get_pathspec(prefix, argv + i);
862
- init_pathspec(&pathspec, paths);
860
+ parse_pathspec(&pathspec, 0,
861
+ PATHSPEC_PREFER_CWD,
862
+ prefix, argv + i);
863
pathspec.max_depth = opt.max_depth;
864
pathspec.recursive = 1;
865
builtin/ls-tree.c
+9
-1
@@ -167,7 +167,15 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
167
if (get_sha1(argv[0], sha1))
168
die("Not a valid object name %s", argv[0]);
169
170
- init_pathspec(&pathspec, get_pathspec(prefix, argv + 1));
170
+ /*
171
+ * show_recursive() rolls its own matching code and is
172
+ * generally ignorant of 'struct pathspec'. The magic mask
173
+ * cannot be lifted until it is converted to use
174
+ * match_pathspec_depth() or tree_entry_interesting()
175
+ */
176
+ parse_pathspec(&pathspec, 0,
177
+ PATHSPEC_PREFER_CWD,
178
+ prefix, argv + 1);
179
for (i = 0; i < pathspec.nr; i++)
180
pathspec.items[i].nowildcard_len = pathspec.items[i].len;
181
pathspec.has_wildcard = 0;
builtin/update-index.c
+3
-2
@@ -547,10 +547,11 @@ static int do_reupdate(int ac, const char **av,
547
*/
548
int pos;
549
int has_head = 1;
550
- const char **paths = get_pathspec(prefix, av + 1);
550
struct pathspec pathspec;
551
553
- init_pathspec(&pathspec, paths);
552
+ parse_pathspec(&pathspec, 0,
553
+ PATHSPEC_PREFER_CWD,
554
+ prefix, av + 1);
555
556
if (read_ref("HEAD", head_sha1))
557
/* If there is no HEAD, that means it is an initial
revision.c
+2
-2
@@ -2120,8 +2120,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2120
*/
2121
ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc);
2122
prune_data.path[prune_data.nr++] = NULL;
2123
- init_pathspec(&revs->prune_data,
2124
- get_pathspec(revs->prefix, prune_data.path));
2123
+ parse_pathspec(&revs->prune_data, 0, 0,
2124
+ revs->prefix, prune_data.path);
2125
}
2126
2127
if (revs->def == NULL)