git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>,
	Marek Zawirski <marek.zawirski@gmail.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 1/1] Use 'git upload-pack' for local transport and not 'git-upload-pack'
Date: Wed,  2 Jul 2008 23:58:09 -0400	[thread overview]
Message-ID: <1215057489-10415-1-git-send-email-spearce@spearce.org> (raw)

Since Git 1.6.0 and later is heading towards moving the dash form
of commands out of the user's $PATH and into the libexec directory
we may not have 'git-upload-pack' or 'git-receive-pack' in $PATH
when the JRE tries to startup C Git for a local transport.  Instead
we should use the git wrapper, as it can select the right libexec
directory and start the correct helper program, or perform the task
internally if it is a builtin command.

In the future we should eliminate this reliance on C Git for any
sort of local transport operation.  We have direct filesystem IO
available to read from the source repository, so there is little
execuse for us to be invoking C Git for this special case.  Until
we fix it, we should at least try to ensure it works for any user.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/transport/TransportLocal.java |   25 ++++++++++++++++---
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
index b112267..b41d4af 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
@@ -59,13 +59,15 @@ import org.spearce.jgit.util.FS;
  * process.
  */
 class TransportLocal extends PackTransport {
+	private static final String PWD = ".";
+
 	static boolean canHandle(final URIish uri) {
 		if (uri.getHost() != null || uri.getPort() > 0 || uri.getUser() != null
 				|| uri.getPass() != null || uri.getPath() == null)
 			return false;
 
 		if ("file".equals(uri.getScheme()) || uri.getScheme() == null)
-			return FS.resolve(new File("."), uri.getPath()).isDirectory();
+			return FS.resolve(new File(PWD), uri.getPath()).isDirectory();
 		return false;
 	}
 
@@ -74,7 +76,7 @@ class TransportLocal extends PackTransport {
 	TransportLocal(final Repository local, final URIish uri) {
 		super(local, uri);
 
-		File d = FS.resolve(new File("."), uri.getPath()).getAbsoluteFile();
+		File d = FS.resolve(new File(PWD), uri.getPath()).getAbsoluteFile();
 		if (new File(d, ".git").isDirectory())
 			d = new File(d, ".git");
 		remoteGitDir = d;
@@ -94,8 +96,23 @@ class TransportLocal extends PackTransport {
 	protected Process startProcessWithErrStream(final String cmd)
 			throws TransportException {
 		try {
-			final Process proc = Runtime.getRuntime().exec(
-					new String[] { cmd, "." }, null, remoteGitDir);
+			final String[] args;
+			final Process proc;
+
+			if (cmd.startsWith("git-")) {
+				args = new String[] { "git", cmd.substring(4), PWD };
+			} else {
+				final int gitspace = cmd.indexOf("git ");
+				if (gitspace >= 0) {
+					final String git = cmd.substring(0, gitspace + 3);
+					final String subcmd = cmd.substring(gitspace + 4);
+					args = new String[] { git, subcmd, PWD };
+				} else {
+					args = new String[] { cmd, PWD };
+				}
+			}
+
+			proc = Runtime.getRuntime().exec(args, null, remoteGitDir);
 			new StreamRewritingThread(cmd, proc.getErrorStream()).start();
 			return proc;
 		} catch (IOException err) {
-- 
1.5.6.74.g8a5e

                 reply	other threads:[~2008-07-03  7:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1215057489-10415-1-git-send-email-spearce@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=marek.zawirski@gmail.com \
    --cc=robin.rosenberg@dewire.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).