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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 7, 2007, 05:49 UTC
Message-ID
<7vejjkdaqe.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0707061303450.4093@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 18 quoted lines
> 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@gmx.de>
> ---
>
> 	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".
Show 9 quoted lines
> -	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.

Show 10 quoted lines
>  
> +	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.

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 5 in “Enable "git rerere" by the config variable rerere.enabled”
  1. Enable "git rerere" by the config variable rerere.enabledJohannes Schindelin, Jul 6, 2007
  2. Junio C HamanoJul 7, 2007
  3. Johannes SchindelinJul 7, 2007
  4. Shawn O. PearceJul 8, 2007
  5. Shawn O. PearceJul 8, 2007

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.