Revert "Allow to enable git protocol version 2 for upload pack"

The JGit implementation of protocol V2 does not invoke the
advertiseRefsHook on fetch and ls-refs, which results in all
refs being sent.

This reverts commit 437d7ef616.

Change-Id: Ia9f0c6140649db2c638ab0483fd14aad99152ff9
This commit is contained in:
David Pursehouse 2018-12-19 08:43:24 +09:00
parent 8caa465b2e
commit f51a97d523
5 changed files with 1 additions and 45 deletions

View File

@ -3822,25 +3822,6 @@ link:https://www.gnupg.org/documentation/manuals/gnupg/OpenPGP-Key-Management.ht
If no keys are specified, web-of-trust checks are disabled. This is the
default behavior.
[[receive.enableProtocolV2]]receive.enableProtocolV2::
+
[NOTE]
Support for Git protocol version 2 is still experimental. Do not use it in
production!
+
Enable support for git protocol version 2.
+
When this option is enabled, clients may send upload pack using git
protocol version 2.
+
The repository must also be configured on the server side to use protocol
version 2 by setting `protocol.version = 2` either in the gerrit user's
`~/.gitconfig` file (which will enable it for all repositories) or on
a per repository basis by setting the option in the `.git/config` file
of the repository.
+
Defaults to false, git protocol version 2 is not enabled.
[[repository]]
=== Section repository

View File

@ -49,7 +49,6 @@ import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
import java.io.IOException;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@ -259,13 +258,6 @@ public class GitOverHttpServlet extends GitServlet {
up.setTimeout(config.getTimeout());
up.setPreUploadHook(PreUploadHookChain.newChain(Lists.newArrayList(preUploadHooks)));
up.setPostUploadHook(PostUploadHookChain.newChain(Lists.newArrayList(postUploadHooks)));
if (config.enableProtocolV2()) {
String header = req.getHeader("Git-Protocol");
if (header != null) {
String[] params = header.split(":");
up.setExtraParameters(Arrays.asList(params));
}
}
ProjectState state = (ProjectState) req.getAttribute(ATT_STATE);
for (UploadPackInitializer initializer : uploadPackInitializers) {
initializer.init(state.getNameKey(), up);

View File

@ -29,7 +29,6 @@ public class TransferConfig {
private final long maxObjectSizeLimit;
private final String maxObjectSizeLimitFormatted;
private final boolean inheritProjectMaxObjectSizeLimit;
private final boolean enableProtocolV2;
@Inject
TransferConfig(@GerritServerConfig Config cfg) {
@ -46,7 +45,6 @@ public class TransferConfig {
maxObjectSizeLimitFormatted = cfg.getString("receive", null, "maxObjectSizeLimit");
inheritProjectMaxObjectSizeLimit =
cfg.getBoolean("receive", "inheritProjectMaxObjectSizeLimit", false);
enableProtocolV2 = cfg.getBoolean("receive", "enableProtocolV2", false);
packConfig = new PackConfig();
packConfig.setDeltaCompress(false);
@ -74,8 +72,4 @@ public class TransferConfig {
public boolean inheritProjectMaxObjectSizeLimit() {
return inheritProjectMaxObjectSizeLimit;
}
public boolean enableProtocolV2() {
return enableProtocolV2;
}
}

View File

@ -29,8 +29,6 @@ import org.eclipse.jgit.lib.Repository;
import org.kohsuke.args4j.Argument;
public abstract class AbstractGitCommand extends BaseCommand {
private static final String GIT_PROTOCOL = "GIT_PROTOCOL";
@Argument(index = 0, metaVar = "PROJECT.git", required = true, usage = "project name")
protected ProjectState projectState;
@ -47,15 +45,9 @@ public abstract class AbstractGitCommand extends BaseCommand {
protected Repository repo;
protected Project.NameKey projectName;
protected Project project;
protected String[] extraParameters;
@Override
public void start(Environment env) {
String gitProtocol = env.getEnv().get(GIT_PROTOCOL);
if (gitProtocol != null) {
extraParameters = gitProtocol.split(":");
}
Context ctx = context.subContext(newSession(), context.getCommandLine());
final Context old = sshScope.set(ctx);
try {

View File

@ -14,7 +14,6 @@
package com.google.gerrit.sshd.commands;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.restapi.AuthException;
@ -53,6 +52,7 @@ final class Upload extends AbstractGitCommand {
PermissionBackend.ForProject perm =
permissionBackend.user(user).project(projectState.getNameKey());
try {
perm.check(ProjectPermission.RUN_UPLOAD_PACK);
} catch (AuthException e) {
throw new Failure(1, "fatal: upload-pack not permitted on this server");
@ -65,9 +65,6 @@ final class Upload extends AbstractGitCommand {
up.setPackConfig(config.getPackConfig());
up.setTimeout(config.getTimeout());
up.setPostUploadHook(PostUploadHookChain.newChain(Lists.newArrayList(postUploadHooks)));
if (config.enableProtocolV2() && extraParameters != null) {
up.setExtraParameters(ImmutableList.copyOf(extraParameters));
}
List<PreUploadHook> allPreUploadHooks = Lists.newArrayList(preUploadHooks);
allPreUploadHooks.add(