Re: [PATCH v2 16/21] read-cache: unlink old sharedindex files

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

 



On Sat, Dec 17, 2016 at 03:55:42PM +0100, Christian Couder wrote:
> +static int clean_shared_index_files(const char *current_hex)
> +{
> +	struct dirent *de;
> +	DIR *dir = opendir(get_git_dir());
> +
> +	if (!dir)
> +		return error_errno(_("unable to open git dir: %s"), get_git_dir());
> +
> +	while ((de = readdir(dir)) != NULL) {
> +		const char *sha1_hex;
> +		if (!skip_prefix(de->d_name, "sharedindex.", &sha1_hex))
> +			continue;
> +		if (!strcmp(sha1_hex, current_hex))

fspathcmp since we're dealing fs paths?

In theory we should be ok using strcmp, even on Windows because case
is preserved, I think. It's only a problem when we write path 'abc'
down and read 'ABC' back.

Oh well.. your call because if you go with fspathcmp, skip_prefix can't
be used either. A lot more changes for a very rare case.

> +			continue;
> +		if (can_delete_shared_index(sha1_hex) > 0 &&

Probably shorter to pass full d->name here so you don't have to do
another git_path() in can_delete_

> +		    unlink(git_path("%s", de->d_name)))
> +			error_errno(_("unable to unlink: %s"), git_path("%s", de->d_name));
> +	}
> +	closedir(dir);
> +
> +	return 0;
> +}



[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]