commit - 519c75832f7df1033ba72fb957277e10005566e2
commit + 1f480907e29bc783454427371277ef33a25658e4
blob - 7959ea4623c135554ed6dc50fbd349286a77e50a
blob + 0f6acd7183de5d276439102cc646435ef0addc3a
--- lib/fileindex.c
+++ lib/fileindex.c
struct dirent *de = dle->data;
DIR *subdir = NULL;
int subdirfd = -1;
- int type;
*next = NULL;
-
- if (de->d_type == DT_UNKNOWN) {
- /* Occurs on NFS mounts without "readdir plus" RPC. */
- char *dir_path;
- if (asprintf(&dir_path, "%s/%s", rootpath, path) == -1)
- return got_error_from_errno("asprintf");
- err = got_path_dirent_type(&type, dir_path, de);
- free(dir_path);
- if (err)
- return err;
- } else
- type = de->d_type;
/* Must traverse ignored directories if they contain tracked files. */
- if (type == DT_DIR && ignore &&
+ if (de->d_type == DT_DIR && ignore &&
have_tracked_file_in_dir(fileindex, path))
ignore = 0;
- if (type == DT_DIR && !ignore) {
+ if (de->d_type == DT_DIR && !ignore) {
char *subpath;
char *subdirpath;
struct got_pathlist_head subdirlist;
}
static const struct got_error *
+dirent_type_fixup(struct dirent *de, const char *rootpath, const char *path)
+{
+ const struct got_error *err;
+ char *dir_path;
+ int type;
+
+ if (de->d_type != DT_UNKNOWN)
+ return NULL;
+
+ /* DT_UNKNOWN occurs on NFS mounts without "readdir plus" RPC. */
+ if (asprintf(&dir_path, "%s/%s", rootpath, path) == -1)
+ return got_error_from_errno("asprintf");
+ err = got_path_dirent_type(&type, dir_path, de);
+ free(dir_path);
+ if (err)
+ return err;
+
+ de->d_type = type;
+ return NULL;
+}
+
+static const struct got_error *
diff_fileindex_dir(struct got_fileindex *fileindex,
struct got_fileindex_entry **ie, struct got_pathlist_head *dirlist,
int dirfd, const char *rootpath, const char *path,
char *de_path;
int cmp;
de = dle->data;
+ err = dirent_type_fixup(de, rootpath, path);
+ if (err)
+ break;
if (asprintf(&de_path, "%s/%s", path,
de->d_name) == -1) {
err = got_error_from_errno("asprintf");
*ie = walk_fileindex(fileindex, *ie);
} else if (dle) {
de = dle->data;
+ err = dirent_type_fixup(de, rootpath, path);
+ if (err)
+ break;
err = cb->diff_new(&ignore, cb_arg, de, path, dirfd);
if (err)
break;