summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-07-13 11:51:05 +0700
committerJunio C Hamano <gitster@pobox.com>2014-07-17 11:05:42 -0700
commitf54a89c11054b97da34363e899c4baa3bcb2e0e3 (patch)
treee8f6c2432cc25da246bda79f3abad94fbf35534e
parentb29b44bf67fd91ec024da240914b6465fae21cac (diff)
downloadgit-f54a89c11054b97da34363e899c4baa3bcb2e0e3.tar.gz
gc: support prune --repos
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Documentation/config.txt7
-rw-r--r--builtin/gc.c11
2 files changed, 18 insertions, 0 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 286e539be2..57999fa4f9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1211,6 +1211,13 @@ gc.pruneexpire::
"now" may be used to disable this grace period and always prune
unreachable objects immediately.
+gc.prunereposexpire::
+ When 'git gc' is run, it will call
+ 'prune --repos --expire 3.months.ago'.
+ Override the grace period with this config variable. The value
+ "now" may be used to disable the grace period and prune
+ $GIT_DIR/repos immediately.
+
gc.reflogexpire::
gc.<pattern>.reflogexpire::
'git reflog expire' removes reflog entries older than
diff --git a/builtin/gc.c b/builtin/gc.c
index e38c9021c2..0c65808dca 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -33,11 +33,13 @@ static int gc_auto_threshold = 6700;
static int gc_auto_pack_limit = 50;
static int detach_auto = 1;
static const char *prune_expire = "2.weeks.ago";
+static const char *prune_repos_expire = "3.months.ago";
static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT;
static struct argv_array reflog = ARGV_ARRAY_INIT;
static struct argv_array repack = ARGV_ARRAY_INIT;
static struct argv_array prune = ARGV_ARRAY_INIT;
+static struct argv_array prune_repos = ARGV_ARRAY_INIT;
static struct argv_array rerere = ARGV_ARRAY_INIT;
static char *pidfile;
@@ -97,6 +99,8 @@ static int gc_config(const char *var, const char *value, void *cb)
}
if (!strcmp(var, "gc.pruneexpire"))
return git_config_date_string(&prune_expire, var, value);
+ if (!strcmp(var, "gc.prunereposexpire"))
+ return git_config_date_string(&prune_repos_expire, var, value);
return git_default_config(var, value, cb);
}
@@ -304,6 +308,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
argv_array_pushl(&reflog, "reflog", "expire", "--all", NULL);
argv_array_pushl(&repack, "repack", "-d", "-l", NULL);
argv_array_pushl(&prune, "prune", "--expire", NULL);
+ argv_array_pushl(&prune_repos, "prune", "--repos", "--expire", NULL);
argv_array_pushl(&rerere, "rerere", "gc", NULL);
git_config(gc_config, NULL);
@@ -373,6 +378,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
return error(FAILED_RUN, prune.argv[0]);
}
+ if (prune_repos_expire) {
+ argv_array_push(&prune_repos, prune_repos_expire);
+ if (run_command_v_opt(prune_repos.argv, RUN_GIT_CMD))
+ return error(FAILED_RUN, prune_repos.argv[0]);
+ }
+
if (run_command_v_opt(rerere.argv, RUN_GIT_CMD))
return error(FAILED_RUN, rerere.argv[0]);