class TransportLocal extends Transport implements PackTransport
This transport is suitable for use on the local system, where the caller has direct read or write access to the "remote" repository.
By default this transport works by spawning a helper thread within the same JVM, and processes the data transfer using a shared memory buffer between the calling thread and the helper thread. This is a pure-Java implementation which does not require forking an external process.
However, during openFetch()
, if the Transport has configured
Transport.getOptionUploadPack()
to be anything other than
"git-upload-pack"
or "git upload-pack"
, this
implementation will fork and execute the external process, using an operating
system pipe to transfer data.
Similarly, during openPush()
, if the Transport has configured
Transport.getOptionReceivePack()
to be anything other than
"git-receive-pack"
or "git receive-pack"
, this
implementation will fork and execute the external process, using an operating
system pipe to transfer data.
Modifier and Type | Class and Description |
---|---|
(package private) class |
TransportLocal.ForkLocalFetchConnection |
(package private) class |
TransportLocal.ForkLocalPushConnection |
Transport.Operation
Modifier and Type | Field and Description |
---|---|
(package private) static TransportProtocol |
PROTO_LOCAL |
private java.io.File |
remoteGitDir |
DEFAULT_FETCH_THIN, DEFAULT_PUSH_THIN, local, REFSPEC_PUSH_ALL, REFSPEC_TAGS, uri
Constructor and Description |
---|
TransportLocal(Repository local,
URIish uri,
java.io.File gitDir) |
TransportLocal(URIish uri,
java.io.File gitDir) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
(package private) ReceivePack |
createReceivePack(Repository dst) |
(package private) UploadPack |
createUploadPack(Repository dst) |
FetchConnection |
openFetch()
Begins a new connection for fetching from the remote repository.
|
PushConnection |
openPush()
Begins a new connection for pushing into the remote repository.
|
private Repository |
openRepo() |
protected java.lang.Process |
spawn(java.lang.String cmd)
Spawn process
|
applyConfig, fetch, findRemoteRefUpdatesFor, findRemoteRefUpdatesFor, findRemoteRefUpdatesFor, findRemoteRefUpdatesFor, getCredentialsProvider, getFilterBlobLimit, getFilterSpec, getObjectChecker, getOptionReceivePack, getOptionUploadPack, getPackConfig, getPushOptions, getTagOpt, getTimeout, getTransportProtocols, getURI, isCheckFetchedObjects, isDryRun, isFetchThin, isPushAtomic, isPushThin, isRemoveDeletedRefs, open, open, open, open, open, open, open, openAll, openAll, openAll, openAll, push, push, register, setCheckFetchedObjects, setCredentialsProvider, setDryRun, setFetchThin, setFilterBlobLimit, setFilterSpec, setObjectChecker, setOptionReceivePack, setOptionUploadPack, setPackConfig, setPushAtomic, setPushOptions, setPushThin, setRemoveDeletedRefs, setTagOpt, setTimeout, unregister
static final TransportProtocol PROTO_LOCAL
private final java.io.File remoteGitDir
TransportLocal(Repository local, URIish uri, java.io.File gitDir)
TransportLocal(URIish uri, java.io.File gitDir)
UploadPack createUploadPack(Repository dst)
ReceivePack createReceivePack(Repository dst)
private Repository openRepo() throws TransportException
TransportException
public FetchConnection openFetch() throws TransportException
If the transport has no local repository, the fetch connection can only be used for reading remote refs.
openFetch
in class Transport
TransportException
- the remote connection could not be established.public PushConnection openPush() throws TransportException
openPush
in class Transport
TransportException
- the remote connection could not be establishedpublic void close()
Close any resources used by this transport.
If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.
AutoClosable.close()
declares that it throws Exception
.
Implementers shouldn't throw checked exceptions. This override narrows
the signature to prevent them from doing so.
protected java.lang.Process spawn(java.lang.String cmd) throws TransportException
cmd
- commandProcess
object.TransportException
- if any.