Skip to content

Commit befcd58

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 988c460 commit befcd58

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

transport-helper.c

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "protocol.h"
1717

1818
static int debug;
19+
/* TODO: put somewhere sensible, e.g. git_transport_options? */
20+
static int auto_gc = 1;
1921

2022
struct helper_data {
2123
const char *name;
@@ -567,6 +569,13 @@ static int fetch_with_import(struct transport *transport,
567569
}
568570
}
569571
strbuf_release(&buf);
572+
if (auto_gc) {
573+
struct child_process cmd = CHILD_PROCESS_INIT;
574+
575+
cmd.git_cmd = 1;
576+
strvec_pushl(&cmd.args, "gc", "--auto", "--quiet", NULL);
577+
run_command(&cmd);
578+
}
570579
return 0;
571580
}
572581

0 commit comments

Comments
 (0)