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.