Re: [PATCH v3 25/25] gc: support prune --repos

2014-02-19 Thread Junio C Hamano
(Only nitpicks during this round of review).

 @@ -274,6 +284,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 );

No SP before closing ).
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 25/25] gc: support prune --repos

2014-02-18 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 Documentation/config.txt |  6 ++
 builtin/gc.c | 17 +
 2 files changed, 23 insertions(+)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index cbf4d97..eec2d05 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1182,6 +1182,12 @@ 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 this  grace period and always 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 c19545d..fbeba86 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -30,11 +30,13 @@ static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
 static int gc_auto_pack_limit = 50;
 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;
@@ -81,6 +83,14 @@ static int gc_config(const char *var, const char *value, 
void *cb)
}
return git_config_string(prune_expire, var, value);
}
+   if (!strcmp(var, gc.prunereposexpire)) {
+   if (value  strcmp(value, now)) {
+   unsigned long now = approxidate(now);
+   if (approxidate(value) = now)
+   return error(_(Invalid %s: '%s'), var, value);
+   }
+   return git_config_string(prune_repos_expire, var, value);
+   }
return git_default_config(var, value, cb);
 }
 
@@ -274,6 +284,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);
@@ -334,6 +345,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]);
 
-- 
1.8.5.2.240.g8478abd

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html