From 3697caf4b962f65430fdcd6f0d41b7fe1f579e18 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 20 May 2020 19:15:33 -0700 Subject: [PATCH] config: let feature.experimental imply protocol.version=2 Git 2.26 used protocol v2 as its default protocol, but soon after release, users noticed that the protocol v2 negotiation code was prone to fail when fetching from some remotes that are far ahead of others (such as linux-next.git versus Linus's linux.git). That has been fixed by 0b07eecf6ed (Merge branch 'jt/v2-fetch-nego-fix', 2020-05-01), but to be cautious, we are using protocol v0 as the default in 2.27 to buy some time for any other unanticipated issues to surface. To that end, let's ensure that users requesting the bleeding edge using the feature.experimental flag *do* get protocol v2. This way, we can gain experience with a wider audience for the new protocol version and be more confident when it is time to enable it by default for all users in some future Git version. Implementation note: this isn't with the rest of the feature.experimental options in repo-settings.c because those are tied to a repository object, whereas this code path is used for operations like "git ls-remote" that do not require a repository. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Documentation/config/feature.txt | 4 ++++ Documentation/config/protocol.txt | 3 ++- protocol.c | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/config/feature.txt b/Documentation/config/feature.txt index 4e3a5c0cebc90d..28c33602d527fa 100644 --- a/Documentation/config/feature.txt +++ b/Documentation/config/feature.txt @@ -22,6 +22,10 @@ existing commit-graph file(s). Occasionally, these files will merge and the write may take longer. Having an updated commit-graph file helps performance of many Git commands, including `git merge-base`, `git push -f`, and `git log --graph`. ++ +* `protocol.version=2` speeds up fetches from repositories with many refs by +allowing the client to specify which refs to list before the server lists +them. feature.manyFiles:: Enable config options that optimize for repos with many files in the diff --git a/Documentation/config/protocol.txt b/Documentation/config/protocol.txt index 0b40141613e3d3..c46e9b3d00a97e 100644 --- a/Documentation/config/protocol.txt +++ b/Documentation/config/protocol.txt @@ -48,7 +48,8 @@ protocol.version:: If set, clients will attempt to communicate with a server using the specified protocol version. If the server does not support it, communication falls back to version 0. - If unset, the default is `0`. + If unset, the default is `0`, unless `feature.experimental` + is enabled, in which case the default is `2`. Supported versions: + -- diff --git a/protocol.c b/protocol.c index d390391ebac80a..d1dd3424bbaa56 100644 --- a/protocol.c +++ b/protocol.c @@ -17,6 +17,7 @@ static enum protocol_version parse_protocol_version(const char *value) enum protocol_version get_protocol_version_config(void) { const char *value; + int val; const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION"; const char *git_test_v; @@ -30,6 +31,9 @@ enum protocol_version get_protocol_version_config(void) return version; } + if (!git_config_get_bool("feature.experimental", &val) && val) + return protocol_v2; + git_test_v = getenv(git_test_k); if (git_test_v && *git_test_v) { enum protocol_version env = parse_protocol_version(git_test_v);