git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean

From
JHJason Holden <jason.k.holden@gmail.com>
Date
Jul 1, 2009, 01:44 UTC
Message-ID
<4A4ABF61.7040009@gmail.com>
In-Reply-To
<7vws6t490z.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
Show 23 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 10 in “Don't delete untracked submodule's .git dirs by default”
  1. 0/2 Don't delete untracked submodule's .git dirs by defaultJason Holden, Jun 30, 2009
  2. 1/2 Add option to not delete a .git directory in remove_dir_recursively()Jason Holden, Jun 30, 2009
  3. 2/2 Don't clean any untracked submodule's .git dir by default in git-cleanJason Holden, Jun 30, 2009
  4. Paolo BonziniJun 30, 2009
  5. Johannes SixtJun 30, 2009
  6. Junio C HamanoJun 30, 2009
  7. Junio C HamanoJun 30, 2009
  8. Jason HoldenJul 1, 2009
  9. Junio C HamanoJul 1, 2009
  10. Johannes SixtJun 30, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.