Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-07-06 16:05:59 +0400
committerJunio C Hamano <gitster@pobox.com>2007-07-07 09:39:15 +0400
commitb4372ef136b0a5a2c1dbd88a11dd72b478d0e0a5 (patch)
tree904accc21f5d15f6d6f49ba2dbe004072764c16a /builtin-rerere.c
parentb2493649fe41f8a0db48ff4e809ea53c8a304a61 (diff)
Enable "git rerere" by the config variable rerere.enabled
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. [jc: with minimum tweaks] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-rerere.c')
-rw-r--r--builtin-rerere.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 29fb075d29..3196151cc4 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -12,6 +12,9 @@ static const char git_rerere_usage[] =
static int cutoff_noresolve = 15;
static int cutoff_resolve = 60;
+/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */
+static int rerere_enabled = -1;
+
static char *merge_rr_path;
static const char *rr_path(const char *name, const char *file)
@@ -387,21 +390,41 @@ static int git_rerere_config(const char *var, const char *value)
cutoff_resolve = git_config_int(var, value);
else if (!strcmp(var, "gc.rerereunresolved"))
cutoff_noresolve = git_config_int(var, value);
+ else if (!strcmp(var, "rerere.enabled"))
+ rerere_enabled = git_config_bool(var, value);
else
return git_default_config(var, value);
return 0;
}
-int cmd_rerere(int argc, const char **argv, const char *prefix)
+static int is_rerere_enabled(void)
{
- struct path_list merge_rr = { NULL, 0, 0, 1 };
- int i, fd = -1;
struct stat st;
+ const char *rr_cache;
+ int rr_cache_exists;
- if (stat(git_path("rr-cache"), &st) || !S_ISDIR(st.st_mode))
+ if (!rerere_enabled)
return 0;
+ rr_cache = git_path("rr-cache");
+ 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;
+}
+
+int cmd_rerere(int argc, const char **argv, const char *prefix)
+{
+ struct path_list merge_rr = { NULL, 0, 0, 1 };
+ int i, fd = -1;
+
git_config(git_rerere_config);
+ if (!is_rerere_enabled())
+ return 0;
merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR"));
fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
@@ -411,6 +434,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
return do_plain_rerere(&merge_rr, fd);
else if (!strcmp(argv[1], "clear")) {
for (i = 0; i < merge_rr.nr; i++) {
+ struct stat st;
const char *name = (const char *)merge_rr.items[i].util;
if (!stat(git_path("rr-cache/%s", name), &st) &&
S_ISDIR(st.st_mode) &&