[PATCH] Try to remove the given path even if it can't be opened
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Apr 2, 2011, 20:09 UTC
- Message-ID
- <20110402200920.GA18171@blimp.dmz>
- In-Reply-To
- <7vy63tg7yz.fsf@alter.siamese.dyndns.org>
Consider unreadable empty directories. rmdir(2) will remove them just fine, assuming the parent directory is modifiable.
Noticed by Linus. Fix suggested by Michael Gruber and Linus.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- Junio C Hamano, Fri, Apr 01, 2011 20:08:36 +0200:
> > Please don't do an attachment that has an inline patch and then attach the > patch itself again in base64. It is extremely annoying.
Sorry. Hard to notice on GMail.
The extended error information is a little bit tricky: there is at least four error cases (opendir, stat, unlink and rmdir) and there is a closedir, which resets errno to output the error in the caller of remove_dir_recursively.
dir.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dir.c b/dir.c index 325fb56..532bcb6 100644 --- 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, '/');
-- 1.7.4