path: root/builtin/fetch.c
diff options
authorDerrick Stolee <>2019-09-03 02:22:02 (GMT)
committerJunio C Hamano <>2019-09-03 19:06:14 (GMT)
commit50f26bd035816c2bb79582b834d59b49292502a9 (patch)
tree48d8a75a581c0acb513b5351f472d0a6aa97fe93 /builtin/fetch.c
parentaaf633c2ad10b47af7623c130ddfe7231658c7e4 (diff)
fetch: add fetch.writeCommitGraph config setting
The commit-graph feature is now on by default, and is being written during 'git gc' by default. Typically, Git only writes a commit-graph when a 'git gc --auto' command passes the setting to actualy do work. This means that a commit-graph will typically fall behind the commits that are being used every day. To stay updated with the latest commits, add a step to 'git fetch' to write a commit-graph after fetching new objects. The fetch.writeCommitGraph config setting enables writing a split commit-graph, so on average the cost of writing this file is very small. Occasionally, the commit-graph chain will collapse to a single level, and this could be slow for very large repos. For additional use, adjust the default to be true when feature.experimental is enabled. Signed-off-by: Derrick Stolee <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/fetch.c')
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 53ce99d..d36a403 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -23,6 +23,7 @@
#include "packfile.h"
#include "list-objects-filter-options.h"
#include "commit-reach.h"
+#include "commit-graph.h"
@@ -1715,6 +1716,20 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
string_list_clear(&list, 0);
+ prepare_repo_settings(the_repository);
+ if (the_repository->settings.fetch_write_commit_graph) {
+ int commit_graph_flags = COMMIT_GRAPH_SPLIT;
+ struct split_commit_graph_opts split_opts;
+ memset(&split_opts, 0, sizeof(struct split_commit_graph_opts));
+ if (progress)
+ commit_graph_flags |= COMMIT_GRAPH_PROGRESS;
+ write_commit_graph_reachable(get_object_directory(),
+ commit_graph_flags,
+ &split_opts);
+ }
if (enable_auto_gc) {