Skip to content

Commit 6a78c1c

Browse files
committed
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 inefficiently. This brings down an initial import of http://selenic.com/hg 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 <[email protected]>
1 parent 64a8a03 commit 6a78c1c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

transport-helper.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "sigchain.h"
1313

1414
static int debug;
15+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
16+
static int auto_gc = 1;
1517

1618
struct helper_data {
1719
const char *name;
@@ -476,6 +478,12 @@ static int fetch_with_import(struct transport *transport,
476478
}
477479
}
478480
strbuf_release(&buf);
481+
if (auto_gc) {
482+
const char *argv_gc_auto[] = {
483+
"gc", "--auto", "--quiet", NULL,
484+
};
485+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
486+
}
479487
return 0;
480488
}
481489

0 commit comments

Comments
 (0)