commit 882ef1b90ea13c3e6642cdd8af148fb08bbeda02 from: Stefan Sperling date: Fri Dec 13 11:19:26 2019 UTC fix fstatat() and openat() error checking in get_file_status() commit - 3d35a492f8fdcff7a6389058d0fcb635ea34a355 commit + 882ef1b90ea13c3e6642cdd8af148fb08bbeda02 blob - f58f283d5b4a7296a4bc31daa1735068b298bb47 blob + 626e3c574541edf235f43bb2ba2538ca27cf9f53 --- lib/worktree.c +++ lib/worktree.c @@ -1128,6 +1128,13 @@ get_file_status(unsigned char *status, struct stat *sb */ if (dirfd != -1) { if (fstatat(dirfd, de_name, sb, AT_SYMLINK_NOFOLLOW) == -1) { + if (errno == ENOENT) { + if (got_fileindex_entry_has_file_on_disk(ie)) + *status = GOT_STATUS_MISSING; + else + *status = GOT_STATUS_DELETE; + goto done; + } err = got_error_from_errno2("fstatat", abspath); goto done; } @@ -1177,7 +1184,7 @@ get_file_status(unsigned char *status, struct stat *sb if (dirfd != -1) { fd = openat(dirfd, de_name, O_RDONLY | O_NOFOLLOW); - if (fd == -1 && errno != ENOENT) + if (fd == -1) return got_error_from_errno2("openat", abspath); }