summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-01-04 10:03:58 -0800
committerJunio C Hamano <gitster@pobox.com>2017-01-08 18:04:17 -0800
commit966de3028b190993329d2ed3af4d3d50059f6483 (patch)
tree77b500703624f44160ca2a0f131d0db55dcc1af7 /dir.c
parente1b8c7bdc0ceba64e4d9fa91b951af3d1de18870 (diff)
downloadgit-966de3028b190993329d2ed3af4d3d50059f6483.tar.gz
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>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index 9ae454ddec..bc5ff72167 100644
--- a/dir.c
+++ b/dir.c
@@ -174,17 +174,21 @@ char *common_prefix(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
* 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_directory(dir, pathspec->nr ? pathspec->_raw[0] : "", len, pathspec);
- return len;
+ read_directory(dir, prefix, prefix_len, pathspec);
+
+ free(prefix);
+ return prefix_len;
}
int within_depth(const char *name, int namelen,