git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "Shawn O. Pearce" <spearce@spearce.org>
Subject: Re: [PATCH] Enable "git rerere" by the config variable rerere.enabled
Date: Sat, 7 Jul 2007 13:41:14 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707071333520.4093@racer.site> (raw)
In-Reply-To: <7vejjkdaqe.fsf@assigned-by-dhcp.cox.net>

Hi,

On Fri, 6 Jul 2007, Junio C Hamano wrote:

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

> > -int cmd_rerere(int argc, const char **argv, const char *prefix)
> > +int is_rerere_enabled(void)
> >  {
> 
> This will be "static".

But of course!

> > +	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.

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

  reply	other threads:[~2007-07-07 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-06 12:05 [PATCH] Enable "git rerere" by the config variable rerere.enabled Johannes Schindelin
2007-07-07  5:49 ` Junio C Hamano
2007-07-07 12:41   ` Johannes Schindelin [this message]
2007-07-08 22:00   ` Shawn O. Pearce
2007-07-08 21:36 ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0707071333520.4093@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).