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

Johannes Schindelin <Johannes.Schindelin@gmx.de> 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@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".

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

  reply	other threads:[~2007-07-07  5:49 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 [this message]
2007-07-07 12:41   ` Johannes Schindelin
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=7vejjkdaqe.fsf@assigned-by-dhcp.cox.net \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --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).