From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
jugg@hotmail.com, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 2/2] gc: config option for running --auto in background
Date: Sat, 8 Feb 2014 14:08:52 +0700 [thread overview]
Message-ID: <1391843332-20583-2-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1391843332-20583-1-git-send-email-pclouds@gmail.com>
`gc --auto` takes time and can block the user temporarily (but not any
less annoyingly). Make it run in background on systems that support
it. The only thing lost with running in background is printouts. But
gc output is not really interesting. You can keep it in foreground by
changing gc.autodetach.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/config.txt | 4 ++++
builtin/gc.c | 23 ++++++++++++++++++-----
t/t5400-send-pack.sh | 1 +
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5f4d793..4781773 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1167,6 +1167,10 @@ gc.autopacklimit::
--auto` consolidates them into one larger pack. The
default value is 50. Setting this to 0 disables it.
+gc.autodetach::
+ Make `git gc --auto` return immediately andrun in background
+ if the system supports it. Default is true.
+
gc.packrefs::
Running `git pack-refs` in a repository renders it
unclonable by Git versions prior to 1.5.1.2 over dumb
diff --git a/builtin/gc.c b/builtin/gc.c
index c19545d..ed5cc3c 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");
@@ -301,11 +306,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();
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 129fc88..0736bcb 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -164,6 +164,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' '
# Set the child to auto-pack if more than one pack exists
cd child &&
git config gc.autopacklimit 1 &&
+ git config gc.autodetach false &&
git branch test_auto_gc &&
# And create a file that follows the temporary object naming
# convention for the auto-gc to remove
--
1.8.5.2.240.g8478abd
next prev parent reply other threads:[~2014-02-08 7:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-04 2:20 bug? git push triggers auto pack when gc.auto = 0 chris
2014-02-04 2:41 ` Duy Nguyen
2014-02-04 5:13 ` chris
2014-02-04 6:02 ` Duy Nguyen
2014-02-04 6:52 ` [PATCH 1/2] receive-pack: update $GIT_DIR/info before auto garbage collection Nguyễn Thái Ngọc Duy
2014-02-04 6:52 ` [PATCH/RFC 2/2] receive-pack: hint that the user can stop "git push" at auto gc time Nguyễn Thái Ngọc Duy
2014-02-04 18:25 ` Junio C Hamano
2014-02-04 18:32 ` Junio C Hamano
2014-02-07 12:36 ` [PATCH/RFC 2/2] receive-pack: hint that the user can stop chris
2014-02-07 13:05 ` Duy Nguyen
2014-02-07 16:47 ` chris
2014-02-08 7:08 ` [PATCH v2 1/2] daemon: move daemonize() to libgit.a Nguyễn Thái Ngọc Duy
2014-02-08 7:08 ` Nguyễn Thái Ngọc Duy [this message]
2014-02-10 11:03 ` [PATCH v2 2/2] gc: config option for running --auto in background Erik Faye-Lund
2014-02-10 13:17 ` Duy Nguyen
2014-02-10 13:33 ` Erik Faye-Lund
2014-02-10 18:43 ` Junio C Hamano
2014-02-10 19:11 ` Junio C Hamano
2014-02-12 1:53 ` Duy Nguyen
2014-02-12 17:36 ` Junio C Hamano
2014-02-10 11:04 ` [PATCH v2 1/2] daemon: move daemonize() to libgit.a Erik Faye-Lund
2014-02-10 18:46 ` Junio C Hamano
2014-02-10 23:25 ` Duy Nguyen
2014-02-11 18:08 ` Junio C Hamano
2014-02-04 8:16 ` bug? git push triggers auto pack when gc.auto = 0 chris
2014-02-04 8:22 ` David Kastrup
2014-02-04 8:59 ` chris
2014-02-04 9:31 ` David Kastrup
2014-02-04 10:35 ` chris
2014-02-04 11:11 ` David Kastrup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1391843332-20583-2-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jugg@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).