зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
fc12261fea
Коммит
0fdc2ae512
|
@ -631,7 +631,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||||
const char *show_in_pager = NULL, *default_pager = "dummy";
|
const char *show_in_pager = NULL, *default_pager = "dummy";
|
||||||
struct grep_opt opt;
|
struct grep_opt opt;
|
||||||
struct object_array list = OBJECT_ARRAY_INIT;
|
struct object_array list = OBJECT_ARRAY_INIT;
|
||||||
const char **paths = NULL;
|
|
||||||
struct pathspec pathspec;
|
struct pathspec pathspec;
|
||||||
struct string_list path_list = STRING_LIST_INIT_NODUP;
|
struct string_list path_list = STRING_LIST_INIT_NODUP;
|
||||||
int i;
|
int i;
|
||||||
|
@ -858,8 +857,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||||
verify_filename(prefix, argv[j], j == i);
|
verify_filename(prefix, argv[j], j == i);
|
||||||
}
|
}
|
||||||
|
|
||||||
paths = get_pathspec(prefix, argv + i);
|
parse_pathspec(&pathspec, 0,
|
||||||
init_pathspec(&pathspec, paths);
|
PATHSPEC_PREFER_CWD,
|
||||||
|
prefix, argv + i);
|
||||||
pathspec.max_depth = opt.max_depth;
|
pathspec.max_depth = opt.max_depth;
|
||||||
pathspec.recursive = 1;
|
pathspec.recursive = 1;
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,15 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
|
||||||
if (get_sha1(argv[0], sha1))
|
if (get_sha1(argv[0], sha1))
|
||||||
die("Not a valid object name %s", argv[0]);
|
die("Not a valid object name %s", argv[0]);
|
||||||
|
|
||||||
init_pathspec(&pathspec, get_pathspec(prefix, argv + 1));
|
/*
|
||||||
|
* show_recursive() rolls its own matching code and is
|
||||||
|
* generally ignorant of 'struct pathspec'. The magic mask
|
||||||
|
* cannot be lifted until it is converted to use
|
||||||
|
* match_pathspec_depth() or tree_entry_interesting()
|
||||||
|
*/
|
||||||
|
parse_pathspec(&pathspec, 0,
|
||||||
|
PATHSPEC_PREFER_CWD,
|
||||||
|
prefix, argv + 1);
|
||||||
for (i = 0; i < pathspec.nr; i++)
|
for (i = 0; i < pathspec.nr; i++)
|
||||||
pathspec.items[i].nowildcard_len = pathspec.items[i].len;
|
pathspec.items[i].nowildcard_len = pathspec.items[i].len;
|
||||||
pathspec.has_wildcard = 0;
|
pathspec.has_wildcard = 0;
|
||||||
|
|
|
@ -547,10 +547,11 @@ static int do_reupdate(int ac, const char **av,
|
||||||
*/
|
*/
|
||||||
int pos;
|
int pos;
|
||||||
int has_head = 1;
|
int has_head = 1;
|
||||||
const char **paths = get_pathspec(prefix, av + 1);
|
|
||||||
struct pathspec pathspec;
|
struct pathspec pathspec;
|
||||||
|
|
||||||
init_pathspec(&pathspec, paths);
|
parse_pathspec(&pathspec, 0,
|
||||||
|
PATHSPEC_PREFER_CWD,
|
||||||
|
prefix, av + 1);
|
||||||
|
|
||||||
if (read_ref("HEAD", head_sha1))
|
if (read_ref("HEAD", head_sha1))
|
||||||
/* If there is no HEAD, that means it is an initial
|
/* If there is no HEAD, that means it is an initial
|
||||||
|
|
|
@ -2120,8 +2120,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
||||||
*/
|
*/
|
||||||
ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc);
|
ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc);
|
||||||
prune_data.path[prune_data.nr++] = NULL;
|
prune_data.path[prune_data.nr++] = NULL;
|
||||||
init_pathspec(&revs->prune_data,
|
parse_pathspec(&revs->prune_data, 0, 0,
|
||||||
get_pathspec(revs->prefix, prune_data.path));
|
revs->prefix, prune_data.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revs->def == NULL)
|
if (revs->def == NULL)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче