Re: [PATCH] Enable "git rerere" by the config variable rerere.enabled

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

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:

> Earlier, "git rerere" was enabled by creating the directory
> .git/rr-cache.  That is definitely not in line with most other
> features, which are enabled by a config variable.
>
> So, check the config variable "rerere.enabled". If it is set
> to "false" explicitely, do not activate rerere, even if
> .git/rr-cache exists. This should help when you want to disable
> rerere temporarily.
>
> If "rerere.enabled" is not set at all, fall back to detection
> of the directory .git/rr-cache.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
> ---
>
> 	Touches quite some parts, doesn't it?
>
> 	And yeah, the git-gui part should be factored out, I guess. Shawn?

I'll exclude git-gui part and commit with a minor tweaks; having
extra "does the directory exist" check in git-gui would not hurt
people who are used to how rerere works in the short term, and I
think I read somewhere that I should expect git-gui updates over
the weekend anyway.

> -int cmd_rerere(int argc, const char **argv, const char *prefix)
> +int is_rerere_enabled(void)
>  {

This will be "static".

> -	struct path_list merge_rr = { NULL, 0, 0, 1 };
> -	int i, fd = -1;
>  	struct stat st;
> +	const char *rr_cache = git_path("rr-cache");
> +	int rr_cache_exists;
>  
> -	if (stat(git_path("rr-cache"), &st) || !S_ISDIR(st.st_mode))
> +	if (!rerere_enabled)
>  		return 0;

As git_path() is not zero-cost, assignment to rr_cache will be
moved here.
>  
> +	rr_cache_exists = !stat(rr_cache, &st) && S_ISDIR(st.st_mode);
> +	if (rerere_enabled < 0)
> +		return rr_cache_exists;
> +
> +	if (!rr_cache_exists && (mkdir(rr_cache, 0777) ||
> +			adjust_shared_perm(rr_cache)))
> +		die("Could not create directory %s", rr_cache);
> +	return 1;
> +}

If rr-cache is a regular file, we will hit "Could not create
directory" which is exactly what we want anyway.  Even if it is
a dangling symlink, it would fail with "File exists", so that
should be Ok.


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

  Powered by Linux