Skip to content

Commit 3c52385

Browse files
committed
fetch: add fetch.writeCommitGraph config setting
Signed-off-by: Derrick Stolee <[email protected]>
1 parent 7c5bc06 commit 3c52385

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

builtin/fetch.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "packfile.h"
2424
#include "list-objects-filter-options.h"
2525
#include "commit-reach.h"
26+
#include "commit-graph.h"
2627

2728
static const char * const builtin_fetch_usage[] = {
2829
N_("git fetch [<options>] [<repository> [<refspec>...]]"),
@@ -62,6 +63,7 @@ static const char *submodule_prefix = "";
6263
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
6364
static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND;
6465
static int shown_url = 0;
66+
static int fetch_write_commit_graph = 0;
6567
static struct refspec refmap = REFSPEC_INIT_FETCH;
6668
static struct list_objects_filter_options filter_options;
6769
static struct string_list server_options = STRING_LIST_INIT_DUP;
@@ -79,6 +81,11 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
7981
return 0;
8082
}
8183

84+
if (!strcmp(k, "fetch.writecommitgraph")) {
85+
fetch_write_commit_graph = 1;
86+
return 0;
87+
}
88+
8289
if (!strcmp(k, "submodule.recurse")) {
8390
int r = git_config_bool(k, v) ?
8491
RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
@@ -1670,6 +1677,16 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
16701677

16711678
string_list_clear(&list, 0);
16721679

1680+
if (fetch_write_commit_graph) {
1681+
int commit_graph_flags = COMMIT_GRAPH_SPLIT;
1682+
1683+
if (progress)
1684+
commit_graph_flags |= COMMIT_GRAPH_PROGRESS;
1685+
1686+
write_commit_graph_reachable(get_object_directory(),
1687+
commit_graph_flags);
1688+
}
1689+
16731690
close_all_packs(the_repository->objects);
16741691

16751692
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);

0 commit comments

Comments
 (0)