summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-07-09 15:25:42 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-07-09 15:25:42 -0700
commit892d3fb71e75849811c038b9fcaf17188a9ccf5d (patch)
tree2e50aa84b3e7e4ce2c34b9da85c2d056c816ebd1 /builtin/fetch.c
parentMerge branch 'es/rev-list-no-object-names' (diff)
parentfetch: only run 'gc' once when fetching multiple remotes (diff)
downloadtgif-892d3fb71e75849811c038b9fcaf17188a9ccf5d.tar.xz
Merge branch 'nd/fetch-multi-gc-once'
"git fetch" that grabs from a group of remotes learned to run the auto-gc only once at the very end. * nd/fetch-multi-gc-once: fetch: only run 'gc' once when fetching multiple remotes
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index c9b92b1e52..667f2cec7b 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -48,6 +48,7 @@ static int prune_tags = -1; /* unspecified */
static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity, deepen_relative;
static int progress = -1;
+static int enable_auto_gc = 1;
static int tags = TAGS_DEFAULT, unshallow, update_shallow, deepen;
static int max_children = 1;
static enum transport_family family;
@@ -169,6 +170,8 @@ static struct option builtin_fetch_options[] = {
OPT_STRING_LIST(0, "negotiation-tip", &negotiation_tip, N_("revision"),
N_("report that we have only objects reachable from this object")),
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
+ OPT_BOOL(0, "auto-gc", &enable_auto_gc,
+ N_("run 'gc --auto' after fetching")),
OPT_END()
};
@@ -1432,7 +1435,7 @@ static int fetch_multiple(struct string_list *list)
return errcode;
}
- argv_array_pushl(&argv, "fetch", "--append", NULL);
+ argv_array_pushl(&argv, "fetch", "--append", "--no-auto-gc", NULL);
add_options_to_argv(&argv);
for (i = 0; i < list->nr; i++) {
@@ -1682,11 +1685,13 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
close_object_store(the_repository->objects);
- argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
- if (verbosity < 0)
- argv_array_push(&argv_gc_auto, "--quiet");
- run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
- argv_array_clear(&argv_gc_auto);
+ if (enable_auto_gc) {
+ argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+ if (verbosity < 0)
+ argv_array_push(&argv_gc_auto, "--quiet");
+ run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
+ argv_array_clear(&argv_gc_auto);
+ }
return result;
}