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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Holden schrieb:
> @@ -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.

> +				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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]