提交 0235017e 编写于 作者: A Alex Riesen 提交者: Junio C Hamano

clean: unreadable directory may still be rmdir-able if it is empty

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: NAlex Riesen <raa.lkml@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 2352570b
......@@ -1088,7 +1088,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, '/');
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册