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
24 @Command(common = false, usage = "usage_ServerSideBackendForJgitPush")
25 class ReceivePack extends TextBuiltin {
26 @Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReceiveInto")
27 File dstGitdir;
28
29
30 @Override
31 protected final boolean requiresRepository() {
32 return false;
33 }
34
35
36 @Override
37 protected void run() {
38 final org.eclipse.jgit.transport.ReceivePack rp;
39
40 try {
41 FileKey key = FileKey.lenient(dstGitdir, FS.DETECTED);
42 db = key.open(true );
43 } catch (RepositoryNotFoundException notFound) {
44 throw die(MessageFormat.format(CLIText.get().notAGitRepository,
45 dstGitdir.getPath()), notFound);
46 } catch (IOException e) {
47 throw die(e.getMessage(), e);
48 }
49
50 rp = new org.eclipse.jgit.transport.ReceivePack(db);
51 try {
52 rp.receive(ins, outs, errs);
53 } catch (IOException e) {
54 throw die(e.getMessage(), e);
55 }
56 }
57 }