upload-pack and receive-pack take a git repository as an argument, but its a lenient path format. Locate the repository and open it. Change-Id: I4b377e57b28ba3b1717c13d9ab51a602de1ad257 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>tags/v0.9.1
@@ -47,9 +47,10 @@ package org.eclipse.jgit.pgm; | |||
import java.io.File; | |||
import java.text.MessageFormat; | |||
import org.eclipse.jgit.errors.RepositoryNotFoundException; | |||
import org.eclipse.jgit.lib.RepositoryCache.FileKey; | |||
import org.eclipse.jgit.util.FS; | |||
import org.kohsuke.args4j.Argument; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.lib.Repository; | |||
@Command(common = false, usage = "usage_ServerSideBackendForJgitPush") | |||
class ReceivePack extends TextBuiltin { | |||
@@ -65,11 +66,14 @@ class ReceivePack extends TextBuiltin { | |||
protected void run() throws Exception { | |||
final org.eclipse.jgit.transport.ReceivePack rp; | |||
if (new File(dstGitdir, Constants.DOT_GIT).isDirectory()) | |||
dstGitdir = new File(dstGitdir, Constants.DOT_GIT); | |||
db = new Repository(dstGitdir); | |||
if (!db.getObjectsDirectory().isDirectory()) | |||
throw die(MessageFormat.format(CLIText.get().notAGitRepository, dstGitdir.getPath())); | |||
try { | |||
FileKey key = FileKey.lenient(dstGitdir, FS.DETECTED); | |||
db = key.open(true /* must exist */); | |||
} catch (RepositoryNotFoundException notFound) { | |||
throw die(MessageFormat.format(CLIText.get().notAGitRepository, | |||
dstGitdir.getPath())); | |||
} | |||
rp = new org.eclipse.jgit.transport.ReceivePack(db); | |||
rp.receive(System.in, System.out, System.err); | |||
} |
@@ -47,10 +47,11 @@ package org.eclipse.jgit.pgm; | |||
import java.io.File; | |||
import java.text.MessageFormat; | |||
import org.eclipse.jgit.errors.RepositoryNotFoundException; | |||
import org.eclipse.jgit.lib.RepositoryCache.FileKey; | |||
import org.eclipse.jgit.util.FS; | |||
import org.kohsuke.args4j.Argument; | |||
import org.kohsuke.args4j.Option; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.lib.Repository; | |||
@Command(common = false, usage = "usage_ServerSideBackendForJgitFetch") | |||
class UploadPack extends TextBuiltin { | |||
@@ -67,16 +68,19 @@ class UploadPack extends TextBuiltin { | |||
@Override | |||
protected void run() throws Exception { | |||
final org.eclipse.jgit.transport.UploadPack rp; | |||
final org.eclipse.jgit.transport.UploadPack up; | |||
if (new File(srcGitdir, Constants.DOT_GIT).isDirectory()) | |||
srcGitdir = new File(srcGitdir, Constants.DOT_GIT); | |||
db = new Repository(srcGitdir); | |||
if (!db.getObjectsDirectory().isDirectory()) | |||
throw die(MessageFormat.format(CLIText.get().notAGitRepository, srcGitdir.getPath())); | |||
rp = new org.eclipse.jgit.transport.UploadPack(db); | |||
try { | |||
FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED); | |||
db = key.open(true /* must exist */); | |||
} catch (RepositoryNotFoundException notFound) { | |||
throw die(MessageFormat.format(CLIText.get().notAGitRepository, | |||
srcGitdir.getPath())); | |||
} | |||
up = new org.eclipse.jgit.transport.UploadPack(db); | |||
if (0 <= timeout) | |||
rp.setTimeout(timeout); | |||
rp.upload(System.in, System.out, System.err); | |||
up.setTimeout(timeout); | |||
up.upload(System.in, System.out, System.err); | |||
} | |||
} |