Browse files

Always auto-gc after calling a fast-import transport

After importing anything with fast-import, we should always let the
garbage collector do its job, since the objects are written to disk

This brings down an initial import of from about
230 megabytes to about 14.

In the future, we may want to make this configurable on a per-remote
basis, or maybe teach fast-import about it in the first place.

Signed-off-by: Johannes Schindelin <>
  • Loading branch information...
1 parent 64a8a03 commit 6a78c1cc84215c9f6c1cfa22dc3e8b44cc328a5b @dscho dscho committed Apr 9, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 transport-helper.c
@@ -12,6 +12,8 @@
#include "sigchain.h"
static int debug;
+/* TODO: put somewhere sensible, e.g. git_transport_options? */
+static int auto_gc = 1;
struct helper_data {
const char *name;
@@ -476,6 +478,12 @@ static int fetch_with_import(struct transport *transport,
+ if (auto_gc) {
+ const char *argv_gc_auto[] = {
+ "gc", "--auto", "--quiet", NULL,
+ };
+ run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+ }
return 0;

2 comments on commit 6a78c1c

This is probably a good idea, nice.


It's a bit hacky since the global variable auto_gc is not really used, but hey, there are 7 billion people on this planet. That's 6,999,999,999 who can improve my patch.

Please sign in to comment.