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
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 7, 2007, 12:41 UTC
Message-ID
<Pine.LNX.4.64.0707071333520.4093@racer.site>
In-Reply-To
<7vejjkdaqe.fsf@assigned-by-dhcp.cox.net>
Hi,
On Fri, 6 Jul 2007, Junio C Hamano wrote:
Show 5 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > 	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;

Thank you. I planned to redo the patch when consensus is reached that this is actually a good patch. But as usual, you're faster.

Show 5 quoted lines
> > -int cmd_rerere(int argc, const char **argv, const char *prefix)
> > +int is_rerere_enabled(void)
> >  {
> 
> This will be "static".
But of course!
Show 9 quoted lines
> > +	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.

Yes, fully agree. It probably does not matter much right now, as git-rerere is mostly called from scripts, and thus does a fork() && exec() anyway, but I am smilingly awaiting the first full-fledged builtin implementation of "git commit", in which case this very function should move somewhere else, and there it does matter a bit more.

Show 14 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.

That was the intended error path, yes. It does not safeguard against old behaviour, where you could ": > .git/rr-cache", and be wondering why it is not activating rr-cache ;-)

Ciao, Dscho

Previous: Junio C HamanoNext: Shawn O. Pearce
Message 3 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.