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

Re: [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively()

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jun 30, 2009, 06:48 UTC
Message-ID
<4A49B529.7030900@viscovery.net>
In-Reply-To
<1246327845-22718-2-git-send-email-jason.k.holden@gmail.com>
Jason Holden schrieb:
Show 12 quoted lines
> @@ -812,6 +812,19 @@ int remove_dir_recursively(struct strbuf *path, int only_empty)
>  		strbuf_addch(path, '/');
>  
>  	len = path->len;
> +
> +	if (keep_dot_git) {
> +		char end_of_path[6]; /* enough space for ".git/"*/
> +		memset(end_of_path, '\0', 6);
> +		if (len >= 5) {
> +			strncpy(end_of_path, path->buf + len - 5, 5);
> +			if (strcmp(end_of_path, ".git/") == 0) {
> +				printf("********Found .git!!!!  Skipping delete\n");
I see no reason to ***shout!!!*** here. IOW:
				warning("not removing %s", dir);
is enough. This also sends the text to stderr.
Show 8 quoted lines
> +				return 0;
> +			}
> +		}
> +	}
> +
>  	while ((e = readdir(dir)) != NULL) {
>  		struct stat st;
>  		if (is_dot_or_dotdot(e->d_name))

I think it is even better to move the check for ".git" below this 'if'. It should not make a difference in practice.

-- Hannes
Previous: Junio C Hamano
Message 10 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.