@matheusbsbs / matheus-bagliano / commits / c14e6e7903
Fork 0

fetch: add the command-line option `--write-commit-graph`

This option overrides the config setting `fetch.writeCommitGraph`, if both are set. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Nov 3, 2019 at 00:21 UTC c14e6e790392647ed3b540b0be3d51d1b8a711c4
2 files changed +10 -1
Documentation/fetch-options.txt
+4
@@ -92,6 +92,10 @@ ifndef::git-pull[]
92 Run `git gc --auto` at the end to perform garbage collection
93 if needed. This is enabled by default.
94
95 +--[no-]write-commit-graph::
96 + Write a commit-graph after fetching. This overrides the config
97 + setting `fetch.writeCommitGraph`.
98 +
99 -p::
100 --prune::
101 Before fetching, remove any remote-tracking references that no
builtin/fetch.c
+6 -1
@@ -77,6 +77,7 @@ static struct refspec refmap = REFSPEC_INIT_FETCH;
77 static struct list_objects_filter_options filter_options;
78 static struct string_list server_options = STRING_LIST_INIT_DUP;
79 static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
80 +static int fetch_write_commit_graph = -1;
81
82 static int git_fetch_config(const char *k, const char *v, void *cb)
83 {
@@ -198,6 +199,8 @@ static struct option builtin_fetch_options[] = {
199 N_("run 'gc --auto' after fetching")),
200 OPT_BOOL(0, "show-forced-updates", &fetch_show_forced_updates,
201 N_("check for forced-updates on all updated branches")),
202 + OPT_BOOL(0, "write-commit-graph", &fetch_write_commit_graph,
203 + N_("write the commit-graph after fetching")),
204 OPT_END()
205 };
206
@@ -1865,7 +1868,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1868 string_list_clear(&list, 0);
1869
1870 prepare_repo_settings(the_repository);
1868 - if (the_repository->settings.fetch_write_commit_graph) {
1871 + if (fetch_write_commit_graph > 0 ||
1872 + (fetch_write_commit_graph < 0 &&
1873 + the_repository->settings.fetch_write_commit_graph)) {
1874 int commit_graph_flags = COMMIT_GRAPH_WRITE_SPLIT;
1875 struct split_commit_graph_opts split_opts;
1876 memset(&split_opts, 0, sizeof(struct split_commit_graph_opts));