Skip to content

Commit 866109b

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 458f952 commit 866109b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

transport-helper.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "protocol.h"
2222

2323
static int debug;
24+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
25+
static int auto_gc = 1;
2426

2527
struct helper_data {
2628
const char *name;
@@ -572,6 +574,13 @@ static int fetch_with_import(struct transport *transport,
572574
}
573575
}
574576
strbuf_release(&buf);
577+
if (auto_gc) {
578+
struct child_process cmd = CHILD_PROCESS_INIT;
579+
580+
cmd.git_cmd = 1;
581+
strvec_pushl(&cmd.args, "gc", "--auto", "--quiet", NULL);
582+
run_command(&cmd);
583+
}
575584
return 0;
576585
}
577586

0 commit comments

Comments
 (0)