1
2
3
4
5
6
7
8
9
10
11
12 package org.eclipse.jgit.pgm;
13
14 import java.io.File;
15 import java.io.IOException;
16 import java.text.MessageFormat;
17
18 import org.eclipse.jgit.errors.RepositoryNotFoundException;
19 import org.eclipse.jgit.lib.RepositoryCache.FileKey;
20 import org.eclipse.jgit.pgm.internal.CLIText;
21 import org.eclipse.jgit.util.FS;
22 import org.kohsuke.args4j.Argument;
23 import org.kohsuke.args4j.Option;
24
25 @Command(common = false, usage = "usage_ServerSideBackendForJgitFetch")
26 class UploadPack extends TextBuiltin {
27 @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity")
28 int timeout = -1;
29
30 @Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReadFrom")
31 File srcGitdir;
32
33
34 @Override
35 protected final boolean requiresRepository() {
36 return false;
37 }
38
39
40 @Override
41 protected void run() {
42 try {
43 FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
44 db = key.open(true );
45 org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack(
46 db);
47 if (0 <= timeout) {
48 up.setTimeout(timeout);
49 }
50 up.upload(ins, outs, errs);
51 } catch (RepositoryNotFoundException notFound) {
52 throw die(MessageFormat.format(CLIText.get().notAGitRepository,
53 srcGitdir.getPath()), notFound);
54 } catch (IOException e) {
55 throw die(e.getMessage(), e);
56 }
57 }
58 }