int check_only, const struct path_simplify *simplify);
static int get_dtype(struct dirent *de, const char *path);
-int common_prefix(const char **pathspec)
+static int common_prefix(const char **pathspec)
{
const char *path, *slash, *next;
int prefix;
return prefix;
}
+int fill_directory(struct dir_struct *dir, const char **pathspec)
+{
+ const char *path, *base;
+ int baselen;
+
+ /*
+ * Calculate common prefix for the pathspec, and
+ * use that to optimize the directory walk
+ */
+ baselen = common_prefix(pathspec);
+ path = "";
+ base = "";
+
+ if (baselen)
+ path = base = xmemdupz(*pathspec, baselen);
+
+ /* Read the directory and prune it */
+ read_directory(dir, path, base, baselen, pathspec);
+ return baselen;
+}
+
/*
* Does 'match' match the given name?
* A match is found if
static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
{
- if (cache_name_pos(pathname, len) >= 0)
+ if (!cache_name_is_other(pathname, len))
return NULL;
ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc);
if (!dir)
return NULL;
if (!getcwd(buffer, size))
- die("can't find the current directory: %s", strerror(errno));
+ die_errno("can't find the current directory");
if (!is_absolute_path(dir))
dir = make_absolute_path(dir);