summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2352570)
raw | patch | inline | side by side (parent: 2352570)
author | Alex Riesen <raa.lkml@gmail.com> | |
Fri, 1 Apr 2011 08:29:16 +0000 (10:29 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 1 Apr 2011 18:16:21 +0000 (11:16 -0700) |
As a last ditch effort, try rmdir(2) when we cannot read the directory
to be removed. It may be an empty directory that we can remove without
any permission, as long as we can modify its parent directory.
Noticed by Linus.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to be removed. It may be an empty directory that we can remove without
any permission, as long as we can modify its parent directory.
Noticed by Linus.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c | patch | blob | history | |
t/t7300-clean.sh | patch | blob | history |
index 570b651a17520cbb0273b9247ab0fcffc0129477..aa1a7181f69c2b8e45df2cc0b95686cb0c3a73fe 100644 (file)
--- a/dir.c
+++ b/dir.c
dir = opendir(path->buf);
if (!dir)
- return -1;
+ return rmdir(path->buf);
if (path->buf[original_len - 1] != '/')
strbuf_addch(path, '/');
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 02f67b73b762850f3c7f0faf0886bf4011f57308..9b12681f971f39fe30fc113fecf37bd219d9b65f 100755 (executable)
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
)
'
+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