commit - 8264d9ee0f0935e0f351d70a93e489ef02b1531e
commit + a47330a24a002793ebfd33553aeb80a98f940755
blob - 71a058b11b7499d2dd17a72a9d69aafdb49f8874
blob + 6ea3deaf8e0753eaf31a2c0f81af1a25b313be30
--- 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;