Execute Git commands with AccessPath.GIT

Since 53b0e7ffb5 ("Require branch deletion permission for pushes
over HTTP") branch deletion or creation over ssh:// by Git push
failed, because the AccessPath was specified wrong.  We need to
force a temporary change for the current command to AccessPath.GIT,
rather than the default of AccessPath.SSH_COMMAND.

Doing this is a bit ugly, as we have to build up a temporary
SshSession, and also a temporary SshScope.Context to point to that
temporary session.  Installing the temporary context before we call
the startThread method will ensure the background worker properly
inherits our context object, and therefore our identity as a Git
based command.

Change-Id: I6cfc91966fffa2c5054ae6d65f6ac57dc751a4fc
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-02-08 10:09:36 -08:00
parent e938ee873d
commit 3c4a53edf6
3 changed files with 46 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.git.ReceiveCommits;
import com.google.gerrit.server.git.ReceiveCommits.MessageListener;
import com.google.gerrit.sshd.AbstractGitCommand;
import com.google.inject.Inject;
import org.eclipse.jgit.transport.ReceivePack;