2 * Copyright (C) 2008 Robin Rosenberg
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License, version 2, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org
.spearce
.jgit
.fetch
;
20 import java
.io
.IOException
;
21 import java
.io
.InputStream
;
22 import java
.io
.OutputStream
;
24 import org
.spearce
.jgit
.lib
.Repository
;
28 * A {@link FetchClient} for local cloning using git protocol.
30 * The main use of this class is for testing the git protocol. Exception
31 * for the initialization, i.e. an optional command to send at the very
32 * beginning, the protocol is the same regardless of whether it is over
33 * pipes, plain TCP sockets or an SSH connection.
35 * <quote>Local</quote> can include network drives.
37 public class LocalGitProtocolFetchClient
extends FullFetchClient
{
39 private LocalGitProtocolFetchClient(final Repository repository
,
40 final String remoteName
, final String initialCommand
,
41 final OutputStream toServer
, final InputStream fromServer
)
43 super(repository
, remoteName
, initialCommand
, toServer
, fromServer
);
47 * Create a FetchClient for local cloning using local git protocol
52 * @return a {@link FetchClient} set up for cloning
55 public static FetchClient
create(final Repository repository
,
56 final String remoteName
, final File remoteGitDir
)
58 final Process process
= Runtime
.getRuntime().exec(
59 new String
[] { "git-upload-pack", "." }, null, remoteGitDir
);
60 final InputStream inputStream
= process
.getInputStream();
61 final OutputStream outpuStream
= process
.getOutputStream();
62 return new LocalGitProtocolFetchClient(repository
, remoteName
, null, outpuStream
, inputStream
);