Subject: Re: [PATCH v3 14/21] read-cache: touch shared index files when used

From: Junio C Hamano <[email-masked]>
Date: Tue, 27 Dec 2016 11:10:30 -0800

Christian Couder <[email-masked]> writes:

> +/*
> + * Signal that the shared index is used by updating its mtime.
> + *
> + * This way, shared index can be removed if they have not been used
> + * for some time. It's ok to fail to update the mtime if we are on a
> + * read only file system.
> + */
> +void freshen_shared_index(char *base_sha1_hex)
> +{
> +	const char *shared_index = git_path("sharedindex.%s", base_sha1_hex);
> +	check_and_freshen_file(shared_index, 1);

What happens when this call fails?  The function returns 0 if the
file did not even exist.  It also returns 0 if you cannot update its
timestamp.

Shouldn't the series be exposing freshen_file() instead _and_ taking
its error return value seriously?

> +}
> +
>  int read_index_from(struct index_state *istate, const char *path)
>  {
>  	struct split_index *split_index;
> @@ -2273,6 +2286,8 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
>  		int ret = write_shared_index(istate, lock, flags);
>  		if (ret)
>  			return ret;
> +	} else {
> +		freshen_shared_index(sha1_to_hex(si->base_sha1));
>  	}
>  
>  	return write_split_index(istate, lock, flags);