23
23
#include "packfile.h"
24
24
#include "list-objects-filter-options.h"
25
25
#include "commit-reach.h"
26
+ #include "commit-graph.h"
26
27
27
28
static const char * const builtin_fetch_usage [] = {
28
29
N_ ("git fetch [<options>] [<repository> [<refspec>...]]" ),
@@ -62,6 +63,7 @@ static const char *submodule_prefix = "";
62
63
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT ;
63
64
static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND ;
64
65
static int shown_url = 0 ;
66
+ static int fetch_write_commit_graph = 0 ;
65
67
static struct refspec refmap = REFSPEC_INIT_FETCH ;
66
68
static struct list_objects_filter_options filter_options ;
67
69
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)
79
81
return 0 ;
80
82
}
81
83
84
+ if (!strcmp (k , "fetch.writecommitgraph" )) {
85
+ fetch_write_commit_graph = 1 ;
86
+ return 0 ;
87
+ }
88
+
82
89
if (!strcmp (k , "submodule.recurse" )) {
83
90
int r = git_config_bool (k , v ) ?
84
91
RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF ;
@@ -1670,6 +1677,16 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1670
1677
1671
1678
string_list_clear (& list , 0 );
1672
1679
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
+
1673
1690
close_all_packs (the_repository -> objects );
1674
1691
1675
1692
argv_array_pushl (& argv_gc_auto , "gc" , "--auto" , NULL );
0 commit comments