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>

Brandon Williams committed Jan 4, 2017 at 10:03 UTC 966de3028b190993329d2ed3af4d3d50059f6483
1 file changed +8 -4
dir.c
+8 -4
@@ -174,17 +174,21 @@ char *common_prefix(const struct pathspec *pathspec)
174
175 int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
176 {
177 - size_t len;
177 + char *prefix;
178 + size_t prefix_len;
179
180 /*
181 * Calculate common prefix for the pathspec, and
182 * use that to optimize the directory walk
183 */
183 - len = common_prefix_len(pathspec);
184 + prefix = common_prefix(pathspec);
185 + prefix_len = prefix ? strlen(prefix) : 0;
186
187 /* Read the directory and prune it */
186 - read_directory(dir, pathspec->nr ? pathspec->_raw[0] : "", len, pathspec);
187 - return len;
188 + read_directory(dir, prefix, prefix_len, pathspec);
189 +
190 + free(prefix);
191 + return prefix_len;
192 }
193
194 int within_depth(const char *name, int namelen,