]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remove_dir_recurse(): tighten condition for removing unreadable dir
authorMichael Haggerty <mhagger@alum.mit.edu>
Sat, 18 Jan 2014 22:48:56 +0000 (23:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Jan 2014 21:46:32 +0000 (13:46 -0800)
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>
dir.c

diff --git a/dir.c b/dir.c
index 23b6de47036839ca4297a9b93d1a9794547ccff1..11e152026211b4031f9d9b10412449c4421c0ebb 100644 (file)
--- 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;