git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Holden <jason.k.holden@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Sixt <j.sixt@viscovery.net>, git@vger.kernel.org
Subject: Re: [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean
Date: Tue, 30 Jun 2009 21:44:01 -0400	[thread overview]
Message-ID: <4A4ABF61.7040009@gmail.com> (raw)
In-Reply-To: <7vws6t490z.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> diff --git a/dir.c b/dir.c
> index bbfcb56..d0cfe74 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -800,12 +800,20 @@ int is_empty_dir(const char *path)
>  	return ret;
>  }
>  
> -int remove_dir_recursively(struct strbuf *path, int only_empty)
> +int remove_dir_recursively(struct strbuf *path, int flag)
>  {
> -	DIR *dir = opendir(path->buf);
> +	DIR *dir;
>  	struct dirent *e;
>  	int ret = 0, original_len = path->len, len;
> +	int only_empty = (flag & REMOVE_DIR_EMPTY_ONLY);
> +	unsigned char submodule_head[20];
>  
> +	if ((flag & REMOVE_DIR_KEEP_NESTED_GIT) &&
> +	    !resolve_gitlink_ref(path->buf, "HEAD", submodule_head))
> +		/* Do not descend and nuke a nested git work tree. */

Add a printout here to indicate that we didn't end up removing the
directory.  Otherwise when you run git clean -f -d you just end up
with something like:
"Removing attachement_fu/"
even when we didn't actually end up removing it.  Paolo noticed this
same issue in my original patch.

> +		return 0;
> +
> +	dir = opendir(path->buf);
>  	if (!dir)

I was able to test this patch and everything seems to behave as
expected.

If this becomes the final fix, don't forget to update
Documentation/git-clean.txt

I'm leaving for vacation tomorrow, so you won't hear any more from
me until ~July 8th.  Thanks for the quick responses.

-- 
Regards,
Jason Holden
Get my PGP Key at
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x6B7FBC8D

  reply	other threads:[~2009-07-01  1:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-30  2:10 [PATCH 0/2] Don't delete untracked submodule's .git dirs by default Jason Holden
2009-06-30  2:10 ` [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Jason Holden
2009-06-30  2:10   ` [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean Jason Holden
2009-06-30  6:07     ` Paolo Bonzini
2009-06-30  6:40     ` Johannes Sixt
2009-06-30  7:34       ` Junio C Hamano
2009-06-30 23:05         ` Junio C Hamano
2009-07-01  1:44           ` Jason Holden [this message]
2009-07-01  2:13             ` Junio C Hamano
2009-06-30  6:48   ` [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Johannes Sixt

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=4A4ABF61.7040009@gmail.com \
    --to=jason.k.holden@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    /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).