summaryrefslogtreecommitdiff
path: root/builtin/gc.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-05 15:06:38 -0800
committerJunio C Hamano <gitster@pobox.com>2014-03-05 15:06:39 -0800
commit4c4ac4db2c933fbae1c6e6bcf90d9bee5f823fc7 (patch)
treeb5dd07dcd50a387d8d3c0c8b8305a0f6d3e1f1e7 /builtin/gc.c
parent6376463c37e0371a411013b90b2e8fc0f7d27dfa (diff)
parent9f673f9477c63433aa0774c11b9e42979721f4d6 (diff)
downloadgit-4c4ac4db2c933fbae1c6e6bcf90d9bee5f823fc7.tar.gz
Merge branch 'nd/daemonize-gc'
Allow running "gc --auto" in the background. * nd/daemonize-gc: gc: config option for running --auto in background daemon: move daemonize() to libgit.a
Diffstat (limited to 'builtin/gc.c')
-rw-r--r--builtin/gc.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 5bbb5e3cc6..63d400bcb2 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -29,6 +29,7 @@ static int pack_refs = 1;
static int aggressive_window = 250;
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 struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT;
@@ -73,6 +74,10 @@ static int gc_config(const char *var, const char *value, void *cb)
gc_auto_pack_limit = git_config_int(var, value);
return 0;
}
+ if (!strcmp(var, "gc.autodetach")) {
+ detach_auto = git_config_bool(var, value);
+ return 0;
+ }
if (!strcmp(var, "gc.pruneexpire")) {
if (value && strcmp(value, "now")) {
unsigned long now = approxidate("now");
@@ -302,11 +307,19 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
*/
if (!need_to_gc())
return 0;
- if (!quiet)
- fprintf(stderr,
- _("Auto packing the repository for optimum performance. You may also\n"
- "run \"git gc\" manually. See "
- "\"git help gc\" for more information.\n"));
+ if (!quiet) {
+ if (detach_auto)
+ fprintf(stderr, _("Auto packing the repository in background for optimum performance.\n"));
+ else
+ fprintf(stderr, _("Auto packing the repository for optimum performance.\n"));
+ fprintf(stderr, _("See \"git help gc\" for manual housekeeping.\n"));
+ }
+ if (detach_auto)
+ /*
+ * failure to daemonize is ok, we'll continue
+ * in foreground
+ */
+ daemonize();
} else
add_repack_all_option();