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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e5c223e98b
commit
ecb2c282c0
7
dir.c
7
dir.c
@ -1476,8 +1476,11 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
|
|||||||
flag &= ~REMOVE_DIR_KEEP_TOPLEVEL;
|
flag &= ~REMOVE_DIR_KEEP_TOPLEVEL;
|
||||||
dir = opendir(path->buf);
|
dir = opendir(path->buf);
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
/* an empty dir could be removed even if it is unreadble */
|
if (errno == EACCES && !keep_toplevel)
|
||||||
if (!keep_toplevel)
|
/*
|
||||||
|
* An empty dir could be removable even if it
|
||||||
|
* is unreadable:
|
||||||
|
*/
|
||||||
return rmdir(path->buf);
|
return rmdir(path->buf);
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user