During a call to 'git fetch', we expect new commits and updated refs. Use these updated refs to add the new commits to the commit-graph file, automatically providing performance benefits in other calls.
Use 'fetch.commitGraph' config setting to enable or disable this behavior. Defaults to false while the commit-graph feature matures. Specifically, we do not want this on by default until the commit-graph feature integrates with history-modifying features such as shallow clones. Signed-off-by: Derrick Stolee <dsto...@microsoft.com> --- Documentation/config.txt | 4 ++++ builtin/fetch.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index 9a3abd87e7..3d8225600a 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1409,6 +1409,10 @@ fetch.output:: `full` and `compact`. Default value is `full`. See section OUTPUT in linkgit:git-fetch[1] for detail. +fetch.commitGraph:: + If true, fetch will automatically update the commit-graph file. + See linkgit:git-commit-graph[1]. + format.attach:: Enable multipart/mixed attachments as the default for 'format-patch'. The value can also be a double quoted string diff --git a/builtin/fetch.c b/builtin/fetch.c index 8ee998ea2e..254f6ecfb6 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -38,6 +38,7 @@ enum { static int fetch_prune_config = -1; /* unspecified */ static int prune = -1; /* unspecified */ #define PRUNE_BY_DEFAULT 0 /* do we prune by default? */ +static int fetch_commit_graph = 0; static int all, append, dry_run, force, keep, multiple, update_head_ok, verbosity, deepen_relative; static int progress = -1; @@ -66,6 +67,11 @@ static int git_fetch_config(const char *k, const char *v, void *cb) return 0; } + if (!strcmp(k, "fetch.commitGraph")) { + fetch_commit_graph = git_config_bool(k, v); + return 0; + } + if (!strcmp(k, "submodule.recurse")) { int r = git_config_bool(k, v) ? RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF; @@ -1462,6 +1468,13 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) result = fetch_multiple(&list); } + if (!result && fetch_commit_graph) { + struct argv_array commit_graph = ARGV_ARRAY_INIT; + argv_array_pushl(&commit_graph, "commit-graph", "write", "--reachable", NULL); + if (run_command_v_opt(commit_graph.argv, RUN_GIT_CMD)) + result = 1; + } + if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) { struct argv_array options = ARGV_ARRAY_INIT; -- 2.16.2.329.gfb62395de6