aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
index 52d2488f70..d4e2bcec76 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
@@ -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);
}
}