Commit Diff


commit - 605229825077e78948f4223e88244a9b6e1797e4
commit + 32d2fb48346b752db5098ea03c9c1800863bc71b
blob - 26a2616570274af7c7fa7136499c336965d3176c
blob + b463e74467b24e30f3a5d0f011b14cc4af7a69ff
--- lib/worktree.c
+++ lib/worktree.c
@@ -2651,10 +2651,12 @@ status_new(void *arg, struct dirent *de, const char *p
 	}
 
 	if (de->d_type == DT_DIR) {
-		int subdirfd;
-		subdirfd = openat(dirfd, de->d_name,
+		int subdirfd = openat(dirfd, de->d_name,
 		    O_RDONLY | O_NOFOLLOW | O_DIRECTORY);
-		if (subdirfd != -1) {
+		if (subdirfd == -1) {
+			if (errno != ENOENT && errno != EACCES)
+				err = got_error_from_errno2("openat", path);
+		} else {
 			err = add_ignores(&a->ignores, a->worktree->root_path,
 			    path, subdirfd, ".cvsignore");
 			if (err == NULL)