git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Michael J Gruber <git@drmicha.warpmail.net>
Subject: [PATCH] Try to remove the given path even if it can't be opened
Date: Sat, 2 Apr 2011 22:09:20 +0200	[thread overview]
Message-ID: <20110402200920.GA18171@blimp.dmz> (raw)
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

  reply	other threads:[~2011-04-02 20:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-01  8:29 [PATCH] Try to remove the given path even if it can't be opened Alex Riesen
2011-04-01 13:37 ` Michael J Gruber
2011-04-01 14:01   ` Alex Riesen
2011-04-01 18:08 ` Junio C Hamano
2011-04-02 20:09   ` Alex Riesen [this message]
2011-04-02 20:33     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110402200920.GA18171@blimp.dmz \
    --to=raa.lkml@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).