Code

Merge branch 'ar/clean-rmdir-empty'
authorJunio C Hamano <gitster@pobox.com>
Wed, 27 Apr 2011 18:36:41 +0000 (11:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Apr 2011 18:36:41 +0000 (11:36 -0700)
* ar/clean-rmdir-empty:
  clean: unreadable directory may still be rmdir-able if it is empty

dir.c
t/t7300-clean.sh

diff --git a/dir.c b/dir.c
index 325fb56ad395c9b47dcbdea47b2833a4287198bc..532bcb65b523223b66efd3f4e458f62fcbe0d6a5 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1192,7 +1192,7 @@ int remove_dir_recursively(struct strbuf *path, int flag)
 
        dir = opendir(path->buf);
        if (!dir)
-               return -1;
+               return rmdir(path->buf);
        if (path->buf[original_len - 1] != '/')
                strbuf_addch(path, '/');
 
index 7e1be444027621e1ea94b0b9ed0e129fce922b02..800b5368a5248835bb9817c0e0c8409131306b3c 100755 (executable)
@@ -453,4 +453,11 @@ test_expect_success 'git clean -e' '
        )
 '
 
+test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
+       mkdir foo &&
+       chmod a= foo &&
+       git clean -dfx foo &&
+       ! test -d foo
+'
+
 test_done