make 'got status' ignore inaccessible directories (reported by semarie)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/lib/fileindex.c b/lib/fileindex.c
index 696ab23..05c0896 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -926,6 +926,10 @@ walk_dir(struct got_pathlist_entry **next, struct got_fileindex *fileindex,
subdir = opendir(subdirpath);
if (subdir == NULL) {
+ if (errno == EACCES) {
+ *next = TAILQ_NEXT(dle, entry);
+ return NULL;
+ }
err = got_error_from_errno2("opendir", subdirpath);
free(subpath);
free(subdirpath);
diff --git a/lib/worktree.c b/lib/worktree.c
index b6130cb..1c38979 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2451,7 +2451,7 @@ add_ignores(struct got_pathlist_head *ignores, const char *root_path,
ignoresfile = fopen(ignorespath, "r");
if (ignoresfile == NULL) {
- if (errno != ENOENT)
+ if (errno != ENOENT && errno != EACCES)
err = got_error_from_errno2("fopen",
ignorespath);
} else
@@ -2541,7 +2541,7 @@ worktree_status(struct got_worktree *worktree, const char *path,
workdir = opendir(ondisk_path);
if (workdir == NULL) {
- if (errno != ENOTDIR && errno != ENOENT)
+ if (errno != ENOTDIR && errno != ENOENT && errno != EACCES)
err = got_error_from_errno2("opendir", ondisk_path);
else
err = report_single_file_status(path, ondisk_path,
diff --git a/regress/cmdline/status.sh b/regress/cmdline/status.sh
index 99766ac..5fde224 100755
--- a/regress/cmdline/status.sh
+++ b/regress/cmdline/status.sh
@@ -33,6 +33,7 @@ function test_status_basic {
touch $testroot/wt/beta
echo "new file" > $testroot/wt/new
(cd $testroot/wt && got add new >/dev/null)
+ mkdir -m 0000 $testroot/wt/bar
echo 'M alpha' > $testroot/stdout.expected
echo 'D beta' >> $testroot/stdout.expected
@@ -47,6 +48,8 @@ function test_status_basic {
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
fi
+ chmod 700 $testroot/wt/bar
+ rmdir $testroot/wt/bar
test_done "$testroot" "$ret"
}