Skip to content

Commit df3998b

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 31e1af5 commit df3998b

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
@@ -22,6 +22,8 @@
2222
#include "packfile.h"
2323

2424
static int debug;
25+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
26+
static int auto_gc = 1;
2527

2628
struct helper_data {
2729
char *name;
@@ -588,6 +590,13 @@ static int fetch_with_import(struct transport *transport,
588590
}
589591
}
590592
strbuf_release(&buf);
593+
if (auto_gc) {
594+
struct child_process cmd = CHILD_PROCESS_INIT;
595+
596+
cmd.git_cmd = 1;
597+
strvec_pushl(&cmd.args, "gc", "--auto", "--quiet", NULL);
598+
run_command(&cmd);
599+
}
591600
return 0;
592601
}
593602

0 commit comments

Comments
 (0)