Skip to content

Commit bcb06e2

Browse files
committed
Merge branch 'js/fetch-multi-lockfix'
Fetching from multiple remotes into the same repository in parallel had a bad interaction with the recent change to (optionally) update the commit-graph after a fetch job finishes, as these parallel fetches compete with each other. Which has been corrected. * js/fetch-multi-lockfix: fetch: avoid locking issues between fetch.jobs/fetch.writeCommitGraph fetch: add the command-line option `--write-commit-graph`
2 parents d08daec + 7d8e72b commit bcb06e2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Documentation/fetch-options.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ ifndef::git-pull[]
9292
Run `git gc --auto` at the end to perform garbage collection
9393
if needed. This is enabled by default.
9494

95+
--[no-]write-commit-graph::
96+
Write a commit-graph after fetching. This overrides the config
97+
setting `fetch.writeCommitGraph`.
98+
9599
-p::
96100
--prune::
97101
Before fetching, remove any remote-tracking references that no

builtin/fetch.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static struct refspec refmap = REFSPEC_INIT_FETCH;
7777
static struct list_objects_filter_options filter_options;
7878
static struct string_list server_options = STRING_LIST_INIT_DUP;
7979
static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
80+
static int fetch_write_commit_graph = -1;
8081

8182
static int git_fetch_config(const char *k, const char *v, void *cb)
8283
{
@@ -198,6 +199,8 @@ static struct option builtin_fetch_options[] = {
198199
N_("run 'gc --auto' after fetching")),
199200
OPT_BOOL(0, "show-forced-updates", &fetch_show_forced_updates,
200201
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")),
201204
OPT_END()
202205
};
203206

@@ -1599,7 +1602,8 @@ static int fetch_multiple(struct string_list *list, int max_children)
15991602
return errcode;
16001603
}
16011604

1602-
argv_array_pushl(&argv, "fetch", "--append", "--no-auto-gc", NULL);
1605+
argv_array_pushl(&argv, "fetch", "--append", "--no-auto-gc",
1606+
"--no-write-commit-graph", NULL);
16031607
add_options_to_argv(&argv);
16041608

16051609
if (max_children != 1 && list->nr != 1) {
@@ -1865,7 +1869,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
18651869
string_list_clear(&list, 0);
18661870

18671871
prepare_repo_settings(the_repository);
1868-
if (the_repository->settings.fetch_write_commit_graph) {
1872+
if (fetch_write_commit_graph > 0 ||
1873+
(fetch_write_commit_graph < 0 &&
1874+
the_repository->settings.fetch_write_commit_graph)) {
18691875
int commit_graph_flags = COMMIT_GRAPH_WRITE_SPLIT;
18701876
struct split_commit_graph_opts split_opts;
18711877
memset(&split_opts, 0, sizeof(struct split_commit_graph_opts));

0 commit comments

Comments
 (0)