summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-07-14 15:35:55 +0700
committerJunio C Hamano <gitster@pobox.com>2013-07-15 10:56:08 -0700
commit7327d3d1b70bfde70840aa8970fe70de6ef1be16 (patch)
tree5740ac2d065dfc60e17f042959497dcf53af1e20 /dir.c
parent9b2d61499b4ff9ded3e1f3d535912ce04c21d72e (diff)
downloadgit-7327d3d1b70bfde70840aa8970fe70de6ef1be16.tar.gz
convert {read,fill}_directory to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/dir.c b/dir.c
index 19978d3d59..290c7a33cb 100644
--- a/dir.c
+++ b/dir.c
@@ -142,7 +142,7 @@ char *common_prefix(const char **pathspec)
return len ? xmemdupz(*pathspec, len) : NULL;
}
-int fill_directory(struct dir_struct *dir, const char **pathspec)
+int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
{
size_t len;
@@ -150,10 +150,10 @@ int fill_directory(struct dir_struct *dir, const char **pathspec)
* Calculate common prefix for the pathspec, and
* use that to optimize the directory walk
*/
- len = common_prefix_len(pathspec);
+ len = common_prefix_len(pathspec->raw);
/* Read the directory and prune it */
- read_directory(dir, pathspec ? *pathspec : "", len, pathspec);
+ read_directory(dir, pathspec->nr ? pathspec->raw[0] : "", len, pathspec);
return len;
}
@@ -1388,14 +1388,20 @@ static int treat_leading_path(struct dir_struct *dir,
return rc;
}
-int read_directory(struct dir_struct *dir, const char *path, int len, const char **pathspec)
+int read_directory(struct dir_struct *dir, const char *path, int len, const struct pathspec *pathspec)
{
struct path_simplify *simplify;
+ /*
+ * Check out create_simplify()
+ */
+ if (pathspec)
+ GUARD_PATHSPEC(pathspec, PATHSPEC_FROMTOP | PATHSPEC_MAXDEPTH);
+
if (has_symlink_leading_path(path, len))
return dir->nr;
- simplify = create_simplify(pathspec);
+ simplify = create_simplify(pathspec ? pathspec->raw : NULL);
if (!len || treat_leading_path(dir, path, len, simplify))
read_directory_recursive(dir, path, len, 0, simplify);
free_simplify(simplify);