Skip to content

Commit d4ff987

Browse files
committed
repo-settings: fetch.showForcedUpdates=false
When a repo has many active contributors, the commit history can grow very quickly and there can be many branches. During 'git fetch', after downloading the pack from the remote, the default behavior checks each remote ref for a forced update. This presents a somewhat quadratic performance hit, as the time it takes to walk these commits can be on the order of the number of branches times the "commit velocity" per branch. Set fetch.showForcedUpdates=false when core.size=large to enable the --no-show-forced-updates option by default for fetch and pull commands. Signed-off-by: Derrick Stolee <[email protected]>
1 parent 637aebc commit d4ff987

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

Documentation/config/core.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,8 @@ client machine.
623623
+
624624
* `status.aheadBehind=false` enables `--no-ahead-behind` by default during
625625
linkgit:git-status[1] calls, saving time in a fast-moving commit history.
626+
+
627+
* `fetch.showForcedUpdates=false` enables `--no-show-forced-updates` by
628+
default during linkgit:git-fetch[1] and linkgit:git-pull[1] calls, saving
629+
time in a fast-moving commit history. This has a small side-effect of not
630+
updating the forced-update bit in the reflog.

Documentation/config/fetch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ See also the `--negotiation-tip` option for linkgit:git-fetch[1].
6767
fetch.showForcedUpdates::
6868
Set to false to enable `--no-show-forced-updates` in
6969
linkgit:git-fetch[1] and linkgit:git-pull[1] commands.
70-
Defaults to true.
70+
Defaults to true, unless `core.size=large`.

builtin/fetch.c

Lines changed: 5 additions & 5 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 "repo-settings.h"
2627

2728
#define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000)
2829

@@ -83,11 +84,6 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
8384
return 0;
8485
}
8586

86-
if (!strcmp(k, "fetch.showforcedupdates")) {
87-
fetch_show_forced_updates = git_config_bool(k, v);
88-
return 0;
89-
}
90-
9187
if (!strcmp(k, "submodule.recurse")) {
9288
int r = git_config_bool(k, v) ?
9389
RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
@@ -1618,6 +1614,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
16181614
fetch_config_from_gitmodules(&max_children, &recurse_submodules);
16191615
git_config(git_fetch_config, NULL);
16201616

1617+
prepare_repo_settings(the_repository);
1618+
if (the_repository->settings->fetch_show_forced_updates != -1)
1619+
fetch_show_forced_updates = the_repository->settings->fetch_show_forced_updates;
1620+
16211621
argc = parse_options(argc, argv, prefix,
16221622
builtin_fetch_options, builtin_fetch_usage, 0);
16231623

repo-settings.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static int git_repo_config(const char *key, const char *value, void *cb)
1616
UPDATE_DEFAULT(rs->gc_write_commit_graph, 1);
1717
UPDATE_DEFAULT(rs->pack_use_sparse, 1);
1818
UPDATE_DEFAULT(rs->status_ahead_behind, 1);
19+
UPDATE_DEFAULT(rs->fetch_show_forced_updates, 1);
1920
UPDATE_DEFAULT(rs->index_version, 4);
2021
}
2122
return 0;
@@ -36,6 +37,10 @@ static int git_repo_config(const char *key, const char *value, void *cb)
3637
rs->status_ahead_behind = git_config_bool(key, value);
3738
return 0;
3839
}
40+
if (!strcmp(key, "fetch.showforcedupdates")) {
41+
rs->fetch_show_forced_updates = git_config_bool(key, value);
42+
return 0;
43+
}
3944
if (!strcmp(key, "index.version")) {
4045
rs->index_version = git_config_int(key, value);
4146
return 0;
@@ -56,6 +61,7 @@ void prepare_repo_settings(struct repository *r)
5661
r->settings->gc_write_commit_graph = -1;
5762
r->settings->pack_use_sparse = -1;
5863
r->settings->status_ahead_behind = -1;
64+
r->settings->fetch_show_forced_updates = -1;
5965
r->settings->index_version = -1;
6066

6167
repo_config(r, git_repo_config, r->settings);

repo-settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct repo_settings {
66
char gc_write_commit_graph;
77
char pack_use_sparse;
88
char status_ahead_behind;
9+
char fetch_show_forced_updates;
910
int index_version;
1011
};
1112

0 commit comments

Comments
 (0)