summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-01-18 22:48:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-01-21 21:46:32 (GMT)
commitecb2c282c0d6cdd9938ba9cf228316ebc91b397e (patch)
tree4483f19a2e45868e62fcbaf2ccfd19513baf8889 /dir.c
parente5c223e98b985d9faa274039aefa4391d2da25a6 (diff)
downloadgit-ecb2c282c0d6cdd9938ba9cf228316ebc91b397e.zip
git-ecb2c282c0d6cdd9938ba9cf228316ebc91b397e.tar.gz
git-ecb2c282c0d6cdd9938ba9cf228316ebc91b397e.tar.bz2
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>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index 23b6de4..11e1520 100644
--- a/dir.c
+++ b/dir.c
@@ -1476,8 +1476,11 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
flag &= ~REMOVE_DIR_KEEP_TOPLEVEL;
dir = opendir(path->buf);
if (!dir) {
- /* an empty dir could be removed even if it is unreadble */
- if (!keep_toplevel)
+ if (errno == EACCES && !keep_toplevel)
+ /*
+ * An empty dir could be removable even if it
+ * is unreadable:
+ */
return rmdir(path->buf);
else
return -1;