Auto-enable git wire protocol v2 in jgit

By JGit's default, git wire protocol version 2 is disabled. The attempt
to activate it per default in JGit wasn't approved yet: [1],[2]. Given,
that git wire protocol version 2 on server side is considered to be now
very stable, activate it per default in init site program.

Update JGit module to include the following change:

23389a632 Add constants for parsing git wire protocol version

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=563145
[2] https://git.eclipse.org/r/c/jgit/jgit/+/163216

Change-Id: I15da7c5e889bc222da08d473a4c41e349a2ee6a6
This commit is contained in:
David Ostrovsky
2020-11-29 16:49:18 +01:00
committed by David Ostrovsky
parent 99c83aaaeb
commit 4f43759cdf
2 changed files with 32 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.transport.TransferConfig;
import org.eclipse.jgit.util.FS;
/** Initialize the JGit configuration. */
@@ -62,6 +63,36 @@ class InitJGitConfig implements InitStep {
+ "Disable this behavior to avoid the additional load it creates: "
+ "gc should be configured in gc config section or run as a separate process.");
}
if (!jgitConfig
.getNames(ConfigConstants.CONFIG_PROTOCOL_SECTION)
.contains(ConfigConstants.CONFIG_KEY_VERSION)) {
jgitConfig.setString(
ConfigConstants.CONFIG_PROTOCOL_SECTION,
null,
ConfigConstants.CONFIG_KEY_VERSION,
TransferConfig.ProtocolVersion.V2.version());
jgitConfig.save();
ui.error(
String.format(
"Auto-configured \"%s.%s = %s\" to activate git wire protocol version 2.",
ConfigConstants.CONFIG_PROTOCOL_SECTION,
ConfigConstants.CONFIG_KEY_VERSION,
TransferConfig.ProtocolVersion.V2.version()));
} else {
String version =
jgitConfig.getString(
ConfigConstants.CONFIG_PROTOCOL_SECTION, null, ConfigConstants.CONFIG_KEY_VERSION);
if (!TransferConfig.ProtocolVersion.V2.version().equals(version)) {
ui.error(
String.format(
"HINT: JGit option \"%s.%s = %s\". It's recommended to activate git\n"
+ "wire protocol version 2 to improve git fetch performance.",
ConfigConstants.CONFIG_PROTOCOL_SECTION,
ConfigConstants.CONFIG_KEY_VERSION,
version));
}
}
} catch (IOException e) {
throw die(String.format("Handling JGit configuration %s failed", sitePaths.jgit_config), e);
} catch (ConfigInvalidException e) {