Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit ecb2c28

Browse files
mhaggergitster
authored andcommitted
remove_dir_recurse(): tighten condition for removing unreadable dir
If opendir() fails on the top-level directory, it makes sense to try to delete it anyway--but only if the failure was due to EACCES. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5c223e commit ecb2c28

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

dir.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,8 +1476,11 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
14761476
flag &= ~REMOVE_DIR_KEEP_TOPLEVEL;
14771477
dir = opendir(path->buf);
14781478
if (!dir) {
1479-
/* an empty dir could be removed even if it is unreadble */
1480-
if (!keep_toplevel)
1479+
if (errno == EACCES && !keep_toplevel)
1480+
/*
1481+
* An empty dir could be removable even if it
1482+
* is unreadable:
1483+
*/
14811484
return rmdir(path->buf);
14821485
else
14831486
return -1;

0 commit comments

Comments
 (0)