From ef93a59d707b434a89f140f56b65f84f52936401 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 30 Jun 2008 23:04:03 -0400 Subject: [PATCH] Support 'git upload-pack' and 'git receive-pack' over SSH Within the next 6 months C git clients will begin asking remote servers for 'git $command' rather than 'git-$command' when using the SSH transport. This change is to allow the C git programs to be removed from the user's $PATH, leaving only the git wrapper binary. For the first 6 months after C git 1.6.0 gets released clients will continue to ask for 'git-$command' but users may change that behavior by specifically asking for 'git $command' in remote.$name.uploadpack or remote.$name.receivepack. Later clients (including jgit) will change to ask for 'git $command' by default. If we are asking for 'git $command' we cannot quote this as a single command with a space in the path. We split on the whitespace and quote both sides (if necessary) to protect the strings from the shell. Signed-off-by: Shawn O. Pearce Signed-off-by: Robin Rosenberg --- .../src/org/spearce/jgit/transport/TransportGitSsh.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java index caf531d7..1bbdf044 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportGitSsh.java @@ -182,7 +182,13 @@ class TransportGitSsh extends PackTransport { path = (uri.getPath().substring(1)); final StringBuilder cmd = new StringBuilder(); - sqMinimal(cmd, exe); + final int gitspace = exe.indexOf("git "); + if (gitspace >= 0) { + sqMinimal(cmd, exe.substring(0, gitspace + 3)); + cmd.append(' '); + sqMinimal(cmd, exe.substring(gitspace + 4)); + } else + sqMinimal(cmd, exe); cmd.append(' '); sqAlways(cmd, path); channel.setCommand(cmd.toString()); -- 2.11.4.GIT