Top Description Inners Fields Constructors Methods
org.eclipse.jgit.transport

public abstract Class Transport

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Known Direct Subclasses
org.eclipse.jgit.transport.TransportBundleFile, org.eclipse.jgit.transport.TransportBundleStream, org.eclipse.jgit.transport.TransportLocal, org.eclipse.jgit.transport.HttpTransport, org.eclipse.jgit.transport.TcpTransport, org.eclipse.jgit.transport.TestProtocol.TransportInternal
Static Imports
java.nio.charset.StandardCharsets.UTF_8, java.util.Objects.requireNonNull

Connects two Git repositories together and copies objects between them.

A transport can be used for either fetching (copying objects into the caller's repository from the remote repository) or pushing (copying objects into the remote repository from the caller's repository). Each transport implementation is responsible for the details associated with establishing the network connection(s) necessary for the copy, as well as actually shuffling data back and forth.

Transport instances and the connections they create are not thread-safe. Callers must ensure a transport is accessed by only one thread at a time.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Transport.Operation

Type of operation a Transport is being opened for.

Field Summary

Modifier and TypeField and Description
private CredentialsProvider
credentialsProvider

Assists with authentication the connection.

private List<String>
private Instant
public static final boolean
DEFAULT_FETCH_THIN

Default setting for fetchThin option.

public static final boolean
DEFAULT_PUSH_THIN

Default setting for pushThin option.

public static final boolean
DEFAULT_PUSH_USE_BITMAPS

Default setting for pushUseBitmaps option.

private Integer
private boolean
dryRun

Should push just check for operation result, not really push.

private List<RefSpec>
fetch

Specifications to apply during fetch.

private boolean
fetchThin

Should fetch request thin-pack if remote repository can produce it.

private FilterSpec
private PrintStream
private PrintStream
protected final Repository
local

The repository this transport fetches into, or pushes out of.

private ObjectChecker
objectChecker

Should an incoming (fetch) transfer validate objects?

private String
optionReceivePack

Name of the receive pack program, if it must be executed.

private String
optionUploadPack

Name of the upload pack program, if it must be executed.

private PackConfig
packConfig

Pack configuration used by this transport to make pack file.

pack-priv TransferConfig.ProtocolVersion
private static final List<WeakReference<TransportProtocol>>
private List<RefSpec>
push

Specifications to apply during push.

private boolean
pushAtomic

Should push be all-or-nothing atomic behavior?

private List<String>
pushOptions

The option strings associated with the push operation.

private boolean
pushThin

Should push produce thin-pack when sending objects to remote repository.

private boolean
pushUseBitmaps

Should push use bitmaps?

public static final RefSpec
REFSPEC_PUSH_ALL

Specification for push operation, to push all refs under refs/heads.

public static final RefSpec
REFSPEC_TAGS

Specification for fetch or push operations, to fetch or push all tags.

private String
private boolean
removeDeletedRefs

Should refs no longer on the source be pruned from the destination?

private TagOpt
private int
timeout

Timeout in seconds to wait before aborting an IO read or write.

protected final URIish
uri

The URI used to create this transport.

Constructor Summary

AccessConstructor and Description
protected
Transport(Repository
the repository this instance will fetch into, or push out of. This must be the repository passed to open(Repository, URIish).
local
,
URIish
the URI used to access the remote repository. This must be the URI passed to open(Repository, URIish).
uri
)

Create a new transport instance.

protected
Transport(URIish uri)

Create a minimal transport instance not tied to a single repository.

Method Summary

Modifier and TypeMethod and Description
public void
applyConfig(RemoteConfig
configuration to apply on this transport.
cfg
)

Apply provided remote configuration on this transport.

private static Enumeration<URL>
public abstract void
close()

Redeclares java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

private static boolean
private static Collection<RefSpec>
public FetchResult

Returns:

information describing the tracking refs updated.
fetch
(final ProgressMonitor
progress monitor to inform the user about our processing activity. Must not be null. Use org.eclipse.jgit.lib.NullProgressMonitor if progress updates are not interesting or necessary.
monitor
,
Collection<RefSpec>
specification of refs to fetch locally. May be null or the empty collection to use the specifications from the RemoteConfig. May contains regular and negative RefSpecs. Source for each regular RefSpec can't be null.
toFetch
)

Fetch objects and refs from the remote repository to the local one.

public FetchResult

Returns:

information describing the tracking refs updated.
fetch
(final ProgressMonitor
progress monitor to inform the user about our processing activity. Must not be null. Use org.eclipse.jgit.lib.NullProgressMonitor if progress updates are not interesting or necessary.
monitor
,
Collection<RefSpec>
specification of refs to fetch locally. May be null or the empty collection to use the specifications from the RemoteConfig. May contain regular and negative RefSpecs. Source for each regular RefSpec can't be null.
toFetch
,
String
the initial branch to check out when cloning the repository. Can be specified as ref name (refs/heads/master), branch name (master) or tag name (v1.2.3). The default is to use the branch pointed to by the cloned repository's HEAD and can be requested by passing null or HEAD.
branch
)

Fetch objects and refs from the remote repository to the local one.

public static Collection<RemoteRefUpdate>

Returns:

collection of set up org.eclipse.jgit.transport.RemoteRefUpdate.
findRemoteRefUpdatesFor
(final Repository
local database.
db
,
final Collection<RefSpec>
collection of RefSpec to convert.
specs
,
final Map<String, RefLeaseSpec>
map from ref to lease (containing expected old object id)
leases
,
Collection<RefSpec>
fetch specifications used for finding localtracking refs. May be null or empty collection.
fetchSpecs
)

Convert push remote refs update specification from org.eclipse.jgit.transport.RefSpec form to org.eclipse.jgit.transport.RemoteRefUpdate.

public static Collection<RemoteRefUpdate>

Returns:

collection of set up org.eclipse.jgit.transport.RemoteRefUpdate.
findRemoteRefUpdatesFor
(final Repository
local database.
db
,
final Collection<RefSpec>
collection of RefSpec to convert.
specs
,
Collection<RefSpec>
fetch specifications used for finding localtracking refs. May be null or empty collection.
fetchSpecs
)

Convert push remote refs update specification from org.eclipse.jgit.transport.RefSpec form to org.eclipse.jgit.transport.RemoteRefUpdate.

public Collection<RemoteRefUpdate>

Returns:

collection of set up org.eclipse.jgit.transport.RemoteRefUpdate.
findRemoteRefUpdatesFor
(final Collection<RefSpec>
collection of RefSpec to convert.
specs
)

Convert push remote refs update specification from org.eclipse.jgit.transport.RefSpec form to org.eclipse.jgit.transport.RemoteRefUpdate.

public Collection<RemoteRefUpdate>

Returns:

collection of set up org.eclipse.jgit.transport.RemoteRefUpdate.
findRemoteRefUpdatesFor
(final Collection<RefSpec>
collection of RefSpec to convert.
specs
,
final Map<String, RefLeaseSpec>
map from ref to lease (containing expected old object id)
leases
)

Convert push remote refs update specification from org.eclipse.jgit.transport.RefSpec form to org.eclipse.jgit.transport.RemoteRefUpdate.

pack-priv static String
findTrackingRefName(final String remoteName, final Collection<RefSpec> fetchSpecs)

public CredentialsProvider

Returns:

the credentials provider, or null if no credentials provider is associated with this transport.
getCredentialsProvider
()

The configured credentials provider.

public final List<String>

Returns:

the list of deepen-not for a shallow clone
getDeepenNots
()

Get list of deepen-not

public final Instant

Returns:

the deepen-since for a shallow clone
getDeepenSince
()

Get deepen-since

public final Integer

Returns:

the depth, or null if none set
getDepth
()

Retrieves the depth for a shallow clone.

public final FilterSpec

Returns:

the last filter spec set with setFilterSpec(FilterSpec), or FilterSpec#NO_FILTER if it was never invoked.
getFilterSpec
()

Get filter spec

public ObjectChecker

Returns:

configured object checker for received objects, or null.
getObjectChecker
()

Get configured object checker for received objects

public String

Returns:

remote executable providing receive-pack service for pack transports.
getOptionReceivePack
()

Default setting is: org.eclipse.jgit.transport.RemoteConfig#DEFAULT_RECEIVE_PACK

public String

Returns:

typically "git-upload-pack".
getOptionUploadPack
()

Get the name of the remote executable providing upload-pack service.

public PackConfig

Returns:

the pack configuration. Never null.
getPackConfig
()

Get the configuration used by the pack generator to make packs.

public List<String>

Returns:

the option strings associated with the push operation
getPushOptions
()

Get the option strings associated with the push operation

public TagOpt

Returns:

option indicating the behavior of annotated tags in fetch.
getTagOpt
()

Get the description of how annotated tags should be treated during fetch.

public int

Returns:

timeout (in seconds) before aborting an IO operation.
getTimeout
()

Get timeout (in seconds) before aborting an IO operation.

public static List<TransportProtocol>

Returns:

an immutable copy of the currently registered protocols.
getTransportProtocols
()

Obtain a copy of the registered protocols.

public URIish

Returns:

the URI describing the location of the remote repository.
getURI
()

Get the URI this transport connects to.

private static List<URIish>
getURIs(final RemoteConfig cfg, final Transport.Operation op)

public boolean

Returns:

true if fetch will verify received objects are formatted correctly. Validating objects requires more CPU time on the client side of the connection.
isCheckFetchedObjects
()

Whether fetch will verify if received objects are formatted correctly.

public boolean

Returns:

true if push operation should just check for possible result and not really update remote refs, false otherwise - when push should act normally.
isDryRun
()

Whether push operation should just check for possible result and not really update remote refs

public boolean

Returns:

true if fetch should request thin-pack when possible; false otherwise
isFetchThin
()

Default setting is: DEFAULT_FETCH_THIN

public boolean

Returns:

true if push requires all-or-nothing atomic behavior.
isPushAtomic
()

Default setting is false.

public boolean

Returns:

true if push should produce thin-pack in pack transports
isPushThin
()

Default setting is: false

public boolean

Returns:

true if push use bitmaps.
isPushUseBitmaps
()

Default setting is: true

public boolean

Returns:

true if destination refs should be removed if they no longer exist at the source repository.
isRemoveDeletedRefs
()

Whether destination refs should be removed if they no longer exist at the source repository.

private static void
public static Transport

Returns:

the new transport instance. Never null. In case of multiple URIs in remote configuration, only the first is chosen.
open
(Repository
existing local repository.
local
,
String
location of the remote repository - may be URI or remote configuration name.
remote
)

Open a new transport instance to connect two repositories.

public static Transport

Returns:

the new transport instance. Never null. In case of multiple URIs in remote configuration, only the first is chosen.
open
(final Repository
existing local repository.
local
,
final String
location of the remote repository - may be URI or remote configuration name.
remote
,
final Transport.Operation
planned use of the returned Transport; the URI may differ based on the type of connection desired.
op
)

Open a new transport instance to connect two repositories.

public static Transport

Returns:

the new transport instance. Never null. In case of multiple URIs in remote configuration, only the first is chosen.
open
(Repository
existing local repository.
local
,
RemoteConfig
configuration describing how to connect to the remote repository.
cfg
)

Open a new transport instance to connect two repositories.

public static Transport

Returns:

the new transport instance. Never null. In case of multiple URIs in remote configuration, only the first is chosen.
open
(final Repository
existing local repository.
local
,
final RemoteConfig
configuration describing how to connect to the remote repository.
cfg
,
final Transport.Operation
planned use of the returned Transport; the URI may differ based on the type of connection desired.
op
)

Open a new transport instance to connect two repositories.

public static Transport

Returns:

the new transport instance. Never null.
open
(Repository
existing local repository.
local
,
URIish
location of the remote repository.
uri
)

Open a new transport instance to connect two repositories.

public static Transport

Returns:

the new transport instance. Never null.
open
(Repository
existing local repository.
local
,
URIish
location of the remote repository.
uri
,
String
name of the remote, if the remote as configured in local; otherwise null.
remoteName
)

Open a new transport instance to connect two repositories.

public static Transport

Returns:

new Transport instance
open
(URIish uri)

Open a new transport with no local repository.

public static List<Transport>

Returns:

the list of new transport instances for every URI in remote configuration.
openAll
(final Repository
existing local repository.
local
,
final String
location of the remote repository - may be URI or remote configuration name.
remote
)

Open new transport instances to connect two repositories.

public static List<Transport>

Returns:

the list of new transport instances for every URI in remote configuration.
openAll
(final Repository
existing local repository.
local
,
final String
location of the remote repository - may be URI or remote configuration name.
remote
,
final Transport.Operation
planned use of the returned Transport; the URI may differ based on the type of connection desired.
op
)

Open new transport instances to connect two repositories.

public static List<Transport>

Returns:

the list of new transport instances for every URI in remote configuration.
openAll
(final Repository
existing local repository.
local
,
final RemoteConfig
configuration describing how to connect to the remote repository.
cfg
)

Open new transport instances to connect two repositories.

public static List<Transport>

Returns:

the list of new transport instances for every URI in remote configuration.
openAll
(final Repository
existing local repository.
local
,
final RemoteConfig
configuration describing how to connect to the remote repository.
cfg
,
final Transport.Operation
planned use of the returned Transport; the URI may differ based on the type of connection desired.
op
)

Open new transport instances to connect two repositories.

public abstract FetchConnection

Returns:

a fresh connection to fetch from the remote repository.
openFetch
()

Begins a new connection for fetching from the remote repository.

public FetchConnection

Returns:

a fresh connection to fetch from the remote repository.
openFetch
(Collection<RefSpec> refSpecs, String...
that will be set as ref prefixes if the server supports git protocol V2; null values are ignored
additionalPatterns
)

Begins a new connection for fetching from the remote repository.

public abstract PushConnection

Returns:

a fresh connection to push into the remote repository.
openPush
()

Begins a new connection for pushing into the remote repository.

public PushResult

Returns:

information about results of remote refs updates, tracking refs updates and refs advertised by remote repository.
push
(final ProgressMonitor
progress monitor to inform the user about our processing activity. Must not be null. Use org.eclipse.jgit.lib.NullProgressMonitor if progress updates are not interesting or necessary.
monitor
,
Collection<RemoteRefUpdate>
specification of refs to push. May be null or the empty collection to use the specifications from the RemoteConfig converted by findRemoteRefUpdatesFor(Collection). No more than 1 RemoteRefUpdate with the same remoteName is allowed. These objects are modified during this call.
toPush
,
OutputStream
output stream to write messages to
out
)

Push objects and refs from the local repository to the remote one.

public PushResult

Returns:

information about results of remote refs updates, tracking refs updates and refs advertised by remote repository.
push
(final ProgressMonitor
progress monitor to inform the user about our processing activity. Must not be null. Use org.eclipse.jgit.lib.NullProgressMonitor if progress updates are not interesting or necessary.
monitor
,
Collection<RemoteRefUpdate>
specification of refs to push. May be null or the empty collection to use the specifications from the RemoteConfig converted by findRemoteRefUpdatesFor(Collection). No more than 1 RemoteRefUpdate with the same remoteName is allowed. These objects are modified during this call.
toPush
)

Push objects and refs from the local repository to the remote one.

public static void
register(TransportProtocol
the protocol definition. Must not be null.
proto
)

Register a TransportProtocol instance for use during open.

private static void
private static void
scan(ClassLoader ldr, URL url)

public void
setCheckFetchedObjects(boolean
true to enable checking received objects; false to assume all received objects are valid.
check
)

Configure if checking received objects is enabled

public void
setCredentialsProvider(CredentialsProvider
the credentials provider, or null if there is none
credentialsProvider
)

A credentials provider to assist with authentication connections..

public final void
setDeepenNots(List<String>
the deepen-not. Must not be null
deepenNots
)

Deepen or shorten the history of a shallow repository to exclude commits reachable from a specified remote branch or tag.

public final void
setDeepenSince(Instant
the deepen-since. Must not be null
deepenSince
)

Deepen or shorten the history of a shallow repository to include all reachable commits after a specified time.

public final void
setDepth(int
the depth
depth
)

Limits fetching to the specified number of commits from the tip of each remote branch history.

public final void
setDepth(Integer
the depth, or null to unset the depth
depth
)

Limits fetching to the specified number of commits from the tip of each remote branch history.

public void
setDryRun(boolean
true if push operation should just check for possible result and not really update remote refs, false otherwise - when push should act normally.
dryRun
)

Set dry run option for push operation.

public void
setFetchThin(boolean
true when fetch should request thin-pack when possible; false when it shouldn't
fetchThin
)

Set the thin-pack preference for fetch operation.

public final void
setFilterSpec(FilterSpec
a new filter to use for this transport
filter
)

Set filter spec

public void
setHookErrorStream(PrintStream
PrintStream to use; if null, System#err will be used
redirect
)

Sets a PrintStream a PrePushHook may write its stderr to.

public void
setHookOutputStream(PrintStream
PrintStream to use; if null, System#out will be used
redirect
)

Sets a PrintStream a PrePushHook may write its stdout to.

public void
setObjectChecker(ObjectChecker
if non-null the object checking instance to verify each received object with; null to disable object checking.
impl
)

Set the object checker to verify each received object with

public void
setOptionReceivePack(String
remote executable, if null or empty default one is set;
optionReceivePack
)

Set remote executable providing receive-pack service for pack transports.

public void
setOptionUploadPack(String
name of the executable.
where
)

Set the name of the remote executable providing upload-pack services.

public void
setPackConfig(PackConfig
configuration controlling packing parameters. If null the source repository's settings will be used.
pc
)

Set the configuration used by the pack generator.

public void
setPushAtomic(boolean
true when push should be an all-or-nothing operation.
atomic
)

Request atomic push (all references succeed, or none do).

public void
setPushOptions(List<String>
null if push options are unsupported
pushOptions
)

Sets the option strings associated with the push operation.

public void
setPushThin(boolean
true when push should produce thin-pack in pack transports; false when it shouldn't
pushThin
)

Set thin-pack preference for push operation.

public void
setPushUseBitmaps(boolean
false to disable use of bitmaps for push, true otherwise.
useBitmaps
)

Set whether to use bitmaps for push.

public void
setRemoveDeletedRefs(boolean
true to remove refs that no longer exist.
remove
)

Set whether or not to remove refs which no longer exist in the source.

public void
setTagOpt(TagOpt
method to use when handling annotated tags.
option
)

Set the description of how annotated tags should be treated on fetch.

public void
setTimeout(int
number of seconds to wait (with no data transfer occurring) before aborting an IO read or write operation with this remote.
seconds
)

Set the timeout before willing to abort an IO call.

public static void
unregister(TransportProtocol
the exact object previously given to register.
proto
)

Unregister a TransportProtocol instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait