dir: convert fill_directory to use the pathspec struct interface
Convert 'fill_directory()' to use the pathspec struct interface from using the '_raw' entry in the pathspec struct. Signed-off-by: Brandon Williams <bmwill@google.com> Reviewed-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:

committed by
Junio C Hamano

parent
e1b8c7bdc0
commit
966de3028b
12
dir.c
12
dir.c
@ -174,17 +174,21 @@ char *common_prefix(const struct pathspec *pathspec)
|
|||||||
|
|
||||||
int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
|
int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
|
||||||
{
|
{
|
||||||
size_t len;
|
char *prefix;
|
||||||
|
size_t prefix_len;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate common prefix for the pathspec, and
|
* Calculate common prefix for the pathspec, and
|
||||||
* use that to optimize the directory walk
|
* use that to optimize the directory walk
|
||||||
*/
|
*/
|
||||||
len = common_prefix_len(pathspec);
|
prefix = common_prefix(pathspec);
|
||||||
|
prefix_len = prefix ? strlen(prefix) : 0;
|
||||||
|
|
||||||
/* Read the directory and prune it */
|
/* Read the directory and prune it */
|
||||||
read_directory(dir, pathspec->nr ? pathspec->_raw[0] : "", len, pathspec);
|
read_directory(dir, prefix, prefix_len, pathspec);
|
||||||
return len;
|
|
||||||
|
free(prefix);
|
||||||
|
return prefix_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int within_depth(const char *name, int namelen,
|
int within_depth(const char *name, int namelen,
|
||||||
|
Reference in New Issue
Block a user