public abstract class Transport
extends java.lang.Object
implements java.lang.AutoCloseable
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.
Modifier and Type | Class and Description |
---|---|
static class |
Transport.Operation
Type of operation a Transport is being opened for.
|
Modifier and Type | Field and Description |
---|---|
private CredentialsProvider |
credentialsProvider
Assists with authentication the connection.
|
static boolean |
DEFAULT_FETCH_THIN
Default setting for
fetchThin option. |
static boolean |
DEFAULT_PUSH_THIN
Default setting for
pushThin option. |
private boolean |
dryRun
Should push just check for operation result, not really push.
|
private java.util.List<RefSpec> |
fetch
Specifications to apply during fetch.
|
private boolean |
fetchThin
Should fetch request thin-pack if remote repository can produce it.
|
private FilterSpec |
filterSpec |
private java.io.PrintStream |
hookOutRedirect |
protected Repository |
local
The repository this transport fetches into, or pushes out of.
|
private ObjectChecker |
objectChecker
Should an incoming (fetch) transfer validate objects?
|
private java.lang.String |
optionReceivePack
Name of the receive pack program, if it must be executed.
|
private java.lang.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.
|
private PrePushHook |
prePush |
private static java.util.List<java.lang.ref.WeakReference<TransportProtocol>> |
protocols |
private java.util.List<RefSpec> |
push
Specifications to apply during push.
|
private boolean |
pushAtomic
Should push be all-or-nothing atomic behavior?
|
private java.util.List<java.lang.String> |
pushOptions
The option strings associated with the push operation.
|
private boolean |
pushThin
Should push produce thin-pack when sending objects to remote repository.
|
static RefSpec |
REFSPEC_PUSH_ALL
Specification for push operation, to push all refs under refs/heads.
|
static RefSpec |
REFSPEC_TAGS
Specification for fetch or push operations, to fetch or push all tags.
|
private boolean |
removeDeletedRefs
Should refs no longer on the source be pruned from the destination?
|
private TagOpt |
tagopt
How
fetch(ProgressMonitor, Collection) should handle tags. |
private int |
timeout
Timeout in seconds to wait before aborting an IO read or write.
|
protected URIish |
uri
The URI used to create this transport.
|
Modifier | Constructor and Description |
---|---|
protected |
Transport(Repository local,
URIish uri)
Create a new transport instance.
|
protected |
Transport(URIish uri)
Create a minimal transport instance not tied to a single repository.
|
Modifier and Type | Method and Description |
---|---|
void |
applyConfig(RemoteConfig cfg)
Apply provided remote configuration on this transport.
|
private static java.util.Enumeration<java.net.URL> |
catalogs(java.lang.ClassLoader ldr) |
abstract void |
close() |
private static boolean |
doesNotExist(RemoteConfig cfg) |
private static java.util.Collection<RefSpec> |
expandPushWildcardsFor(Repository db,
java.util.Collection<RefSpec> specs) |
FetchResult |
fetch(ProgressMonitor monitor,
java.util.Collection<RefSpec> toFetch)
Fetch objects and refs from the remote repository to the local one.
|
java.util.Collection<RemoteRefUpdate> |
findRemoteRefUpdatesFor(java.util.Collection<RefSpec> specs)
Convert push remote refs update specification from
RefSpec form to
RemoteRefUpdate . |
java.util.Collection<RemoteRefUpdate> |
findRemoteRefUpdatesFor(java.util.Collection<RefSpec> specs,
java.util.Map<java.lang.String,RefLeaseSpec> leases)
Convert push remote refs update specification from
RefSpec form to
RemoteRefUpdate . |
static java.util.Collection<RemoteRefUpdate> |
findRemoteRefUpdatesFor(Repository db,
java.util.Collection<RefSpec> specs,
java.util.Collection<RefSpec> fetchSpecs)
Convert push remote refs update specification from
RefSpec form to
RemoteRefUpdate . |
static java.util.Collection<RemoteRefUpdate> |
findRemoteRefUpdatesFor(Repository db,
java.util.Collection<RefSpec> specs,
java.util.Map<java.lang.String,RefLeaseSpec> leases,
java.util.Collection<RefSpec> fetchSpecs)
Convert push remote refs update specification from
RefSpec form to
RemoteRefUpdate . |
private static java.lang.String |
findTrackingRefName(java.lang.String remoteName,
java.util.Collection<RefSpec> fetchSpecs) |
CredentialsProvider |
getCredentialsProvider()
The configured credentials provider.
|
long |
getFilterBlobLimit()
Deprecated.
Use
getFilterSpec() instead |
FilterSpec |
getFilterSpec() |
ObjectChecker |
getObjectChecker()
Get configured object checker for received objects
|
java.lang.String |
getOptionReceivePack()
Default setting is:
RemoteConfig.DEFAULT_RECEIVE_PACK |
java.lang.String |
getOptionUploadPack()
Get the name of the remote executable providing upload-pack service.
|
PackConfig |
getPackConfig()
Get the configuration used by the pack generator to make packs.
|
java.util.List<java.lang.String> |
getPushOptions()
Get the option strings associated with the push operation
|
TagOpt |
getTagOpt()
Get the description of how annotated tags should be treated during fetch.
|
int |
getTimeout()
Get timeout (in seconds) before aborting an IO operation.
|
static java.util.List<TransportProtocol> |
getTransportProtocols()
Obtain a copy of the registered protocols.
|
URIish |
getURI()
Get the URI this transport connects to.
|
private static java.util.List<URIish> |
getURIs(RemoteConfig cfg,
Transport.Operation op) |
boolean |
isCheckFetchedObjects()
Whether fetch will verify if received objects are formatted correctly.
|
boolean |
isDryRun()
Whether push operation should just check for possible result and not
really update remote refs
|
boolean |
isFetchThin()
Default setting is:
DEFAULT_FETCH_THIN |
boolean |
isPushAtomic()
Default setting is false.
|
boolean |
isPushThin()
Default setting is: false
|
boolean |
isRemoveDeletedRefs()
Whether destination refs should be removed if they no longer exist at the
source repository.
|
private static void |
load(java.lang.ClassLoader ldr,
java.lang.String cn) |
static Transport |
open(Repository local,
RemoteConfig cfg)
Open a new transport instance to connect two repositories.
|
static Transport |
open(Repository local,
RemoteConfig cfg,
Transport.Operation op)
Open a new transport instance to connect two repositories.
|
static Transport |
open(Repository local,
java.lang.String remote)
Open a new transport instance to connect two repositories.
|
static Transport |
open(Repository local,
java.lang.String remote,
Transport.Operation op)
Open a new transport instance to connect two repositories.
|
static Transport |
open(Repository local,
URIish uri)
Open a new transport instance to connect two repositories.
|
static Transport |
open(Repository local,
URIish uri,
java.lang.String remoteName)
Open a new transport instance to connect two repositories.
|
static Transport |
open(URIish uri)
Open a new transport with no local repository.
|
static java.util.List<Transport> |
openAll(Repository local,
RemoteConfig cfg)
Open new transport instances to connect two repositories.
|
static java.util.List<Transport> |
openAll(Repository local,
RemoteConfig cfg,
Transport.Operation op)
Open new transport instances to connect two repositories.
|
static java.util.List<Transport> |
openAll(Repository local,
java.lang.String remote)
Open new transport instances to connect two repositories.
|
static java.util.List<Transport> |
openAll(Repository local,
java.lang.String remote,
Transport.Operation op)
Open new transport instances to connect two repositories.
|
abstract FetchConnection |
openFetch()
Begins a new connection for fetching from the remote repository.
|
abstract PushConnection |
openPush()
Begins a new connection for pushing into the remote repository.
|
PushResult |
push(ProgressMonitor monitor,
java.util.Collection<RemoteRefUpdate> toPush)
Push objects and refs from the local repository to the remote one.
|
PushResult |
push(ProgressMonitor monitor,
java.util.Collection<RemoteRefUpdate> toPush,
java.io.OutputStream out)
Push objects and refs from the local repository to the remote one.
|
static void |
register(TransportProtocol proto)
Register a TransportProtocol instance for use during open.
|
private static void |
registerByService() |
private static void |
scan(java.lang.ClassLoader ldr,
java.net.URL url) |
void |
setCheckFetchedObjects(boolean check)
Configure if checking received objects is enabled
|
void |
setCredentialsProvider(CredentialsProvider credentialsProvider)
A credentials provider to assist with authentication connections..
|
void |
setDryRun(boolean dryRun)
Set dry run option for push operation.
|
void |
setFetchThin(boolean fetchThin)
Set the thin-pack preference for fetch operation.
|
void |
setFilterBlobLimit(long bytes)
Deprecated.
Use
setFilterSpec(FilterSpec) instead |
void |
setFilterSpec(FilterSpec filter) |
void |
setObjectChecker(ObjectChecker impl)
Set the object checker to verify each received object with
|
void |
setOptionReceivePack(java.lang.String optionReceivePack)
Set remote executable providing receive-pack service for pack transports.
|
void |
setOptionUploadPack(java.lang.String where)
Set the name of the remote executable providing upload-pack services.
|
void |
setPackConfig(PackConfig pc)
Set the configuration used by the pack generator.
|
void |
setPushAtomic(boolean atomic)
Request atomic push (all references succeed, or none do).
|
void |
setPushOptions(java.util.List<java.lang.String> pushOptions)
Sets the option strings associated with the push operation.
|
void |
setPushThin(boolean pushThin)
Set thin-pack preference for push operation.
|
void |
setRemoveDeletedRefs(boolean remove)
Set whether or not to remove refs which no longer exist in the source.
|
void |
setTagOpt(TagOpt option)
Set the description of how annotated tags should be treated on fetch.
|
void |
setTimeout(int seconds)
Set the timeout before willing to abort an IO call.
|
static void |
unregister(TransportProtocol proto)
Unregister a TransportProtocol instance.
|
private static final java.util.List<java.lang.ref.WeakReference<TransportProtocol>> protocols
public static final boolean DEFAULT_FETCH_THIN
fetchThin
option.public static final boolean DEFAULT_PUSH_THIN
pushThin
option.public static final RefSpec REFSPEC_TAGS
public static final RefSpec REFSPEC_PUSH_ALL
protected final Repository local
protected final URIish uri
private java.lang.String optionUploadPack
private java.util.List<RefSpec> fetch
private TagOpt tagopt
fetch(ProgressMonitor, Collection)
should handle tags.
We default to TagOpt.NO_TAGS
so as to avoid fetching annotated
tags during one-shot fetches used for later merges. This prevents
dragging down tags from repositories that we do not have established
tracking branches for. If we do not track the source repository, we most
likely do not care about any tags it publishes.
private boolean fetchThin
private java.lang.String optionReceivePack
private java.util.List<RefSpec> push
private boolean pushThin
private boolean pushAtomic
private boolean dryRun
private ObjectChecker objectChecker
private boolean removeDeletedRefs
private FilterSpec filterSpec
private int timeout
private PackConfig packConfig
private CredentialsProvider credentialsProvider
private java.util.List<java.lang.String> pushOptions
private java.io.PrintStream hookOutRedirect
private PrePushHook prePush
protected Transport(Repository local, URIish uri)
local
- the repository this instance will fetch into, or push out of.
This must be the repository passed to
open(Repository, URIish)
.uri
- the URI used to access the remote repository. This must be the
URI passed to open(Repository, URIish)
.private static void registerByService()
private static java.util.Enumeration<java.net.URL> catalogs(java.lang.ClassLoader ldr)
private static void scan(java.lang.ClassLoader ldr, java.net.URL url)
private static void load(java.lang.ClassLoader ldr, java.lang.String cn)
public static void register(TransportProtocol proto)
Protocol definitions are held by WeakReference, allowing them to be
garbage collected when the calling application drops all strongly held
references to the TransportProtocol. Therefore applications should use a
singleton pattern as described in
TransportProtocol
's class
documentation to ensure their protocol does not get disabled by garbage
collection earlier than expected.
The new protocol is registered in front of all earlier protocols, giving it higher priority than the built-in protocol definitions.
proto
- the protocol definition. Must not be null.public static void unregister(TransportProtocol proto)
Unregistering a protocol usually isn't necessary, as protocols are held
by weak references and will automatically clear when they are garbage
collected by the JVM. Matching is handled by reference equality, so the
exact reference given to register(TransportProtocol)
must be
used.
proto
- the exact object previously given to register.public static java.util.List<TransportProtocol> getTransportProtocols()
public static Transport open(Repository local, java.lang.String remote) throws NotSupportedException, java.net.URISyntaxException, TransportException
This method assumes
Transport.Operation.FETCH
.
local
- existing local repository.remote
- location of the remote repository - may be URI or remote
configuration name.java.net.URISyntaxException
- the location is not a remote defined in the configuration
file and is not a well-formed URL.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.public static Transport open(Repository local, java.lang.String remote, Transport.Operation op) throws NotSupportedException, java.net.URISyntaxException, TransportException
local
- existing local repository.remote
- location of the remote repository - may be URI or remote
configuration name.op
- planned use of the returned Transport; the URI may differ
based on the type of connection desired.java.net.URISyntaxException
- the location is not a remote defined in the configuration
file and is not a well-formed URL.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.public static java.util.List<Transport> openAll(Repository local, java.lang.String remote) throws NotSupportedException, java.net.URISyntaxException, TransportException
This method assumes
Transport.Operation.FETCH
.
local
- existing local repository.remote
- location of the remote repository - may be URI or remote
configuration name.java.net.URISyntaxException
- the location is not a remote defined in the configuration
file and is not a well-formed URL.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.public static java.util.List<Transport> openAll(Repository local, java.lang.String remote, Transport.Operation op) throws NotSupportedException, java.net.URISyntaxException, TransportException
local
- existing local repository.remote
- location of the remote repository - may be URI or remote
configuration name.op
- planned use of the returned Transport; the URI may differ
based on the type of connection desired.java.net.URISyntaxException
- the location is not a remote defined in the configuration
file and is not a well-formed URL.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.public static Transport open(Repository local, RemoteConfig cfg) throws NotSupportedException, TransportException
This method assumes
Transport.Operation.FETCH
.
local
- existing local repository.cfg
- configuration describing how to connect to the remote
repository.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.java.lang.IllegalArgumentException
- if provided remote configuration doesn't have any URI
associated.public static Transport open(Repository local, RemoteConfig cfg, Transport.Operation op) throws NotSupportedException, TransportException
local
- existing local repository.cfg
- configuration describing how to connect to the remote
repository.op
- planned use of the returned Transport; the URI may differ
based on the type of connection desired.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.java.lang.IllegalArgumentException
- if provided remote configuration doesn't have any URI
associated.public static java.util.List<Transport> openAll(Repository local, RemoteConfig cfg) throws NotSupportedException, TransportException
This method assumes
Transport.Operation.FETCH
.
local
- existing local repository.cfg
- configuration describing how to connect to the remote
repository.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.public static java.util.List<Transport> openAll(Repository local, RemoteConfig cfg, Transport.Operation op) throws NotSupportedException, TransportException
local
- existing local repository.cfg
- configuration describing how to connect to the remote
repository.op
- planned use of the returned Transport; the URI may differ
based on the type of connection desired.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.private static java.util.List<URIish> getURIs(RemoteConfig cfg, Transport.Operation op)
private static boolean doesNotExist(RemoteConfig cfg)
public static Transport open(Repository local, URIish uri) throws NotSupportedException, TransportException
local
- existing local repository.uri
- location of the remote repository.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.public static Transport open(Repository local, URIish uri, java.lang.String remoteName) throws NotSupportedException, TransportException
local
- existing local repository.uri
- location of the remote repository.remoteName
- name of the remote, if the remote as configured in
local
; otherwise null.NotSupportedException
- the protocol specified is not supported.TransportException
- the transport cannot open this URI.public static Transport open(URIish uri) throws NotSupportedException, TransportException
Note that the resulting transport instance can not be used for fetching or pushing, but only for reading remote refs.
uri
- a URIish
object.NotSupportedException
TransportException
public static java.util.Collection<RemoteRefUpdate> findRemoteRefUpdatesFor(Repository db, java.util.Collection<RefSpec> specs, java.util.Map<java.lang.String,RefLeaseSpec> leases, java.util.Collection<RefSpec> fetchSpecs) throws java.io.IOException
RefSpec
form to
RemoteRefUpdate
. Conversion expands
wildcards by matching source part to local refs. expectedOldObjectId in
RemoteRefUpdate is set when specified in leases. Tracking branch is
configured if RefSpec destination matches source of any fetch ref spec
for this transport remote configuration.db
- local database.specs
- collection of RefSpec to convert.leases
- map from ref to lease (containing expected old object id)fetchSpecs
- fetch specifications used for finding localtracking refs. May
be null or empty collection.RemoteRefUpdate
.java.io.IOException
- when problem occurred during conversion or specification set
up: most probably, missing objects or refs.public static java.util.Collection<RemoteRefUpdate> findRemoteRefUpdatesFor(Repository db, java.util.Collection<RefSpec> specs, java.util.Collection<RefSpec> fetchSpecs) throws java.io.IOException
RefSpec
form to
RemoteRefUpdate
. Conversion expands
wildcards by matching source part to local refs. expectedOldObjectId in
RemoteRefUpdate is always set as null. Tracking branch is configured if
RefSpec destination matches source of any fetch ref spec for this
transport remote configuration.db
- local database.specs
- collection of RefSpec to convert.fetchSpecs
- fetch specifications used for finding localtracking refs. May
be null or empty collection.RemoteRefUpdate
.java.io.IOException
- when problem occurred during conversion or specification set
up: most probably, missing objects or refs.private static java.util.Collection<RefSpec> expandPushWildcardsFor(Repository db, java.util.Collection<RefSpec> specs) throws java.io.IOException
java.io.IOException
private static java.lang.String findTrackingRefName(java.lang.String remoteName, java.util.Collection<RefSpec> fetchSpecs)
public URIish getURI()
Each transport instance connects to at most one URI at any point in time.
public java.lang.String getOptionUploadPack()
public void setOptionUploadPack(java.lang.String where)
where
- name of the executable.public TagOpt getTagOpt()
public void setTagOpt(TagOpt option)
option
- method to use when handling annotated tags.public boolean isFetchThin()
DEFAULT_FETCH_THIN
PackTransport
public void setFetchThin(boolean fetchThin)
DEFAULT_FETCH_THIN
fetchThin
- true when fetch should request thin-pack when possible; false
when it shouldn'tPackTransport
public boolean isCheckFetchedObjects()
public void setCheckFetchedObjects(boolean check)
check
- true to enable checking received objects; false to assume all
received objects are valid.setObjectChecker(ObjectChecker)
public ObjectChecker getObjectChecker()
public void setObjectChecker(ObjectChecker impl)
impl
- if non-null the object checking instance to verify each
received object with; null to disable object checking.public java.lang.String getOptionReceivePack()
RemoteConfig.DEFAULT_RECEIVE_PACK
PackTransport
public void setOptionReceivePack(java.lang.String optionReceivePack)
RemoteConfig.DEFAULT_RECEIVE_PACK
optionReceivePack
- remote executable, if null or empty default one is set;public boolean isPushThin()
PackTransport
public void setPushThin(boolean pushThin)
pushThin
- true when push should produce thin-pack in pack transports;
false when it shouldn'tPackTransport
public boolean isPushAtomic()
public void setPushAtomic(boolean atomic)
Server must also support atomic push. If the server does not support the feature the push will abort without making changes.
atomic
- true when push should be an all-or-nothing operation.PackTransport
public boolean isRemoveDeletedRefs()
public void setRemoveDeletedRefs(boolean remove)
If true, refs at the destination repository (local for fetch, remote for push) are deleted if they no longer exist on the source side (remote for fetch, local for push).
False by default, as this may cause data to become unreachable, and eventually be deleted on the next GC.
remove
- true to remove refs that no longer exist.@Deprecated public final long getFilterBlobLimit()
getFilterSpec()
insteadsetFilterBlobLimit(long)
or
setFilterSpec(FilterSpec)
, or -1 if no blob limit value
was set@Deprecated public final void setFilterBlobLimit(long bytes)
setFilterSpec(FilterSpec)
insteadbytes
- exclude blobs of size greater than thispublic final FilterSpec getFilterSpec()
setFilterSpec(FilterSpec)
,
or FilterSpec.NO_FILTER
if it was never invoked.public final void setFilterSpec(@NonNull FilterSpec filter)
filter
- a new filter to use for this transportpublic void applyConfig(RemoteConfig cfg)
cfg
- configuration to apply on this transport.public boolean isDryRun()
public void setDryRun(boolean dryRun)
dryRun
- true if push operation should just check for possible result
and not really update remote refs, false otherwise - when push
should act normally.public int getTimeout()
public void setTimeout(int seconds)
seconds
- number of seconds to wait (with no data transfer occurring)
before aborting an IO read or write operation with this
remote.public PackConfig getPackConfig()
setPackConfig(PackConfig)
was previously given null a new
PackConfig is created on demand by this method using the source
repository's settings.public void setPackConfig(PackConfig pc)
pc
- configuration controlling packing parameters. If null the
source repository's settings will be used.public void setCredentialsProvider(CredentialsProvider credentialsProvider)
credentialsProvider
- the credentials provider, or null if there is nonepublic CredentialsProvider getCredentialsProvider()
public java.util.List<java.lang.String> getPushOptions()
public void setPushOptions(java.util.List<java.lang.String> pushOptions)
pushOptions
- null if push options are unsupportedpublic FetchResult fetch(ProgressMonitor monitor, java.util.Collection<RefSpec> toFetch) throws NotSupportedException, TransportException
This is a utility function providing standard fetch behavior. Local
tracking refs associated with the remote repository are automatically
updated if this transport was created from a
RemoteConfig
with fetch RefSpecs
defined.
monitor
- progress monitor to inform the user about our processing
activity. Must not be null. Use
NullProgressMonitor
if progress
updates are not interesting or necessary.toFetch
- specification of refs to fetch locally. May be null or the
empty collection to use the specifications from the
RemoteConfig. Source for each RefSpec can't be null.NotSupportedException
- this transport implementation does not support fetching
objects.TransportException
- the remote connection could not be established or object
copying (if necessary) failed or update specification was
incorrect.public PushResult push(ProgressMonitor monitor, java.util.Collection<RemoteRefUpdate> toPush, java.io.OutputStream out) throws NotSupportedException, TransportException
This is a utility function providing standard push behavior. It updates remote refs and send there necessary objects according to remote ref update specification. After successful remote ref update, associated locally stored tracking branch is updated if set up accordingly. Detailed operation result is provided after execution.
For setting up remote ref update specification from ref spec, see helper
method findRemoteRefUpdatesFor(Collection)
, predefined refspecs
(REFSPEC_TAGS
, REFSPEC_PUSH_ALL
) or consider using
directly RemoteRefUpdate
for more
possibilities.
When isDryRun()
is true, result of this operation is just
estimation of real operation result, no real action is performed.
monitor
- progress monitor to inform the user about our processing
activity. Must not be null. Use
NullProgressMonitor
if progress
updates are not interesting or necessary.toPush
- 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.out
- output stream to write messages toNotSupportedException
- this transport implementation does not support pushing
objects.TransportException
- the remote connection could not be established or object
copying (if necessary) failed at I/O or protocol level or
update specification was incorrect.RemoteRefUpdate
public PushResult push(ProgressMonitor monitor, java.util.Collection<RemoteRefUpdate> toPush) throws NotSupportedException, TransportException
This is a utility function providing standard push behavior. It updates remote refs and sends necessary objects according to remote ref update specification. After successful remote ref update, associated locally stored tracking branch is updated if set up accordingly. Detailed operation result is provided after execution.
For setting up remote ref update specification from ref spec, see helper
method findRemoteRefUpdatesFor(Collection)
, predefined refspecs
(REFSPEC_TAGS
, REFSPEC_PUSH_ALL
) or consider using
directly RemoteRefUpdate
for more
possibilities.
When isDryRun()
is true, result of this operation is just
estimation of real operation result, no real action is performed.
monitor
- progress monitor to inform the user about our processing
activity. Must not be null. Use
NullProgressMonitor
if progress
updates are not interesting or necessary.toPush
- 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.NotSupportedException
- this transport implementation does not support pushing
objects.TransportException
- the remote connection could not be established or object
copying (if necessary) failed at I/O or protocol level or
update specification was incorrect.RemoteRefUpdate
public java.util.Collection<RemoteRefUpdate> findRemoteRefUpdatesFor(java.util.Collection<RefSpec> specs) throws java.io.IOException
RefSpec
form to
RemoteRefUpdate
. Conversion expands
wildcards by matching source part to local refs. expectedOldObjectId in
RemoteRefUpdate is always set as null. Tracking branch is configured if
RefSpec destination matches source of any fetch ref spec for this
transport remote configuration.
Conversion is performed for context of this transport (database, fetch specifications).
specs
- collection of RefSpec to convert.RemoteRefUpdate
.java.io.IOException
- when problem occurred during conversion or specification set
up: most probably, missing objects or refs.public java.util.Collection<RemoteRefUpdate> findRemoteRefUpdatesFor(java.util.Collection<RefSpec> specs, java.util.Map<java.lang.String,RefLeaseSpec> leases) throws java.io.IOException
RefSpec
form to
RemoteRefUpdate
. Conversion expands
wildcards by matching source part to local refs. expectedOldObjectId in
RemoteRefUpdate is set according to leases. Tracking branch is configured
if RefSpec destination matches source of any fetch ref spec for this
transport remote configuration.
Conversion is performed for context of this transport (database, fetch specifications).
specs
- collection of RefSpec to convert.leases
- map from ref to lease (containing expected old object id)RemoteRefUpdate
.java.io.IOException
- when problem occurred during conversion or specification set
up: most probably, missing objects or refs.public abstract FetchConnection openFetch() throws NotSupportedException, TransportException
If the transport has no local repository, the fetch connection can only be used for reading remote refs.
NotSupportedException
- the implementation does not support fetching.TransportException
- the remote connection could not be established.public abstract PushConnection openPush() throws NotSupportedException, TransportException
NotSupportedException
- the implementation does not support pushing.TransportException
- the remote connection could not be establishedpublic abstract 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.
close
in interface java.lang.AutoCloseable