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

pack-priv Class WalkPushConnection

extends BaseConnection
implements PushConnection
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.transport.PushConnection, org.eclipse.jgit.transport.Connection, java.lang.AutoCloseable
Static Imports
org.eclipse.jgit.transport.WalkRemoteObjectDatabase.ROOT_DIR

Generic push support for dumb transport protocols.

Since there are no Git-specific smarts on the remote side of the connection the client side must handle everything on its own. The generic push support requires being able to delete, create and overwrite files on the remote side, as well as create any missing directories (if necessary). Typically this can be handled through an FTP style protocol.

Objects not on the remote side are uploaded as pack files, using one pack file per invocation. This simplifies the implementation as only two data files need to be written to the remote repository.

Push support supplied by this class is not multiuser safe. Concurrent pushes to the same repository may yield an inconsistent reference database which may confuse fetch clients.

A single push is concurrently safe with multiple fetch requests, due to the careful order of operations used to update the repository. Clients fetching may receive transient failures due to short reads on certain files if the protocol does not support atomic file replacement.

See Also
WalkRemoteObjectDatabase

Field Summary

Modifier and TypeField and Description
pack-priv final WalkRemoteObjectDatabase
dest

Database connection to the remote repository.

private final Repository
local

The repository this transport pushes out of.

private Map<String, Ref>
newRefs

Complete listing of refs the remote will have after our push.

private Collection<RemoteRefUpdate>
packedRefUpdates

Updates which require altering the packed-refs file to complete.

private LinkedHashMap<String, String>
packNames

Packs already known to reside in the remote repository.

private final Transport
transport

The configured transport we were constructed by.

private final URIish
uri

Location of the remote repository we are writing to.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.eclipse.jgit.transport.BaseConnection.close.

Implements org.eclipse.jgit.transport.Connection.close.

Closes this resource, relinquishing any underlying resources.

private void
private void
private boolean
private static String
public void
push(final ProgressMonitor
progress monitor to update the end-user about the amount of work completed, or to indicate cancellation. Implementors should poll the monitor at regular intervals to look for cancellation requests from the user.
monitor
,
final Map<String, RemoteRefUpdate>
map of remote refnames to remote refs update specifications/statuses. Can't be empty. This indicate what refs caller want to update on remote side. Only refs updates with org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED should passed. Implementation must ensure that and appropriate status with optional message should be set during call. No refUpdate with org.eclipse.jgit.transport.RemoteRefUpdate.Status#AWAITING_REPORT or org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED can be leaved by implementation after return from this call.
refUpdates
)

Implements org.eclipse.jgit.transport.PushConnection.push.

Pushes to the remote repository basing on provided specification.

public void
push(final ProgressMonitor
progress monitor to update the end-user about the amount of work completed, or to indicate cancellation. Implementors should poll the monitor at regular intervals to look for cancellation requests from the user.
monitor
,
final Map<String, RemoteRefUpdate>
map of remote refnames to remote refs update specifications/statuses. Can't be empty. This indicate what refs caller want to update on remote side. Only refs updates with org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED should passed. Implementation must ensure that and appropriate status with optional message should be set during call. No refUpdate with org.eclipse.jgit.transport.RemoteRefUpdate.Status#AWAITING_REPORT or org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED can be leaved by implementation after return from this call.
refUpdates
,
OutputStream
output stream to write sideband messages to
out
)

Implements org.eclipse.jgit.transport.PushConnection.push.

Pushes to the remote repository basing on provided specification.

private void
private static String
private void
sendpack(final List<RemoteRefUpdate> updates, final ProgressMonitor monitor)

private void
Inherited from org.eclipse.jgit.transport.BaseConnection:
availablegetMessagesgetMessageWritergetPeerUserAgentgetRefgetRefsgetRefsMapmarkStartedOperationsetMessageWritersetPeerUserAgent

Field Detail

destback to summary
pack-priv final WalkRemoteObjectDatabase dest

Database connection to the remote repository.

localback to summary
private final Repository local

The repository this transport pushes out of.

newRefsback to summary
private Map<String, Ref> newRefs

Complete listing of refs the remote will have after our push.

packedRefUpdatesback to summary
private Collection<RemoteRefUpdate> packedRefUpdates

Updates which require altering the packed-refs file to complete.

If this collection is non-empty then any refs listed in newRefs with a storage class of Storage#PACKED will be written.

packNamesback to summary
private LinkedHashMap<String, String> packNames

Packs already known to reside in the remote repository.

This is a LinkedHashMap to maintain the original order.

transportback to summary
private final Transport transport

The configured transport we were constructed by.

uriback to summary
private final URIish uri

Location of the remote repository we are writing to.

Constructor Detail

WalkPushConnectionback to summary
pack-priv WalkPushConnection(final WalkTransport walkTransport, final WalkRemoteObjectDatabase w)

Method Detail

closeback to summary
public void close()

Implements abstract org.eclipse.jgit.transport.BaseConnection.close.

Implements org.eclipse.jgit.transport.Connection.close.

Doc from org.eclipse.jgit.transport.Connection.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Close any resources used by this connection.

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.

If additional messages were produced by the remote peer, these should still be retained in the connection instance for getMessages().

AutoClosable.close() declares that it throws Exception. Implementers shouldn't throw checked exceptions. This override narrows the signature to prevent them from doing so.

Annotations
@Override
createNewRepositoryback to summary
private void createNewRepository(List<RemoteRefUpdate> updates) throws TransportException
deleteCommandback to summary
private void deleteCommand(RemoteRefUpdate u)
isNewRepositoryback to summary
private boolean isNewRepository()
pickHEADback to summary
private static String pickHEAD(List<RemoteRefUpdate> updates)
pushback to summary
public void push(final ProgressMonitor monitor, final Map<String, RemoteRefUpdate> refUpdates) throws TransportException

Implements org.eclipse.jgit.transport.PushConnection.push.

Doc from org.eclipse.jgit.transport.PushConnection.push.

Pushes to the remote repository basing on provided specification. This possibly result in update/creation/deletion of refs on remote repository and sending objects that remote repository need to have a consistent objects graph from new refs.

Only one call per connection is allowed. Subsequent calls will result in org.eclipse.jgit.errors.TransportException.

Implementation may use local repository to send a minimum set of objects needed by remote repository in efficient way. org.eclipse.jgit.transport.Transport#isPushThin() should be honored if applicable. refUpdates should be filled with information about status of each update.

Parameters
monitor:ProgressMonitor

progress monitor to update the end-user about the amount of work completed, or to indicate cancellation. Implementors should poll the monitor at regular intervals to look for cancellation requests from the user.

refUpdates:Map<String, RemoteRefUpdate>

map of remote refnames to remote refs update specifications/statuses. Can't be empty. This indicate what refs caller want to update on remote side. Only refs updates with org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED should passed. Implementation must ensure that and appropriate status with optional message should be set during call. No refUpdate with org.eclipse.jgit.transport.RemoteRefUpdate.Status#AWAITING_REPORT or org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED can be leaved by implementation after return from this call.

Annotations
@Override
Exceptions
TransportException:
objects could not be copied due to a network failure, critical protocol error, or error on remote side, or connection was already used for push - new connection must be created. Non-critical errors concerning only isolated refs should be placed in refUpdates.
pushback to summary
public void push(final ProgressMonitor monitor, final Map<String, RemoteRefUpdate> refUpdates, OutputStream out) throws TransportException

Implements org.eclipse.jgit.transport.PushConnection.push.

Doc from org.eclipse.jgit.transport.PushConnection.push.

Pushes to the remote repository basing on provided specification. This possibly result in update/creation/deletion of refs on remote repository and sending objects that remote repository need to have a consistent objects graph from new refs.

Only one call per connection is allowed. Subsequent calls will result in org.eclipse.jgit.errors.TransportException.

Implementation may use local repository to send a minimum set of objects needed by remote repository in efficient way. org.eclipse.jgit.transport.Transport#isPushThin() should be honored if applicable. refUpdates should be filled with information about status of each update.

Parameters
monitor:ProgressMonitor

progress monitor to update the end-user about the amount of work completed, or to indicate cancellation. Implementors should poll the monitor at regular intervals to look for cancellation requests from the user.

refUpdates:Map<String, RemoteRefUpdate>

map of remote refnames to remote refs update specifications/statuses. Can't be empty. This indicate what refs caller want to update on remote side. Only refs updates with org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED should passed. Implementation must ensure that and appropriate status with optional message should be set during call. No refUpdate with org.eclipse.jgit.transport.RemoteRefUpdate.Status#AWAITING_REPORT or org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED can be leaved by implementation after return from this call.

out:OutputStream

output stream to write sideband messages to

Annotations
@Override
Exceptions
TransportException:
objects could not be copied due to a network failure, critical protocol error, or error on remote side, or connection was already used for push - new connection must be created. Non-critical errors concerning only isolated refs should be placed in refUpdates.
safeDeleteback to summary
private void safeDelete(File path)
sanitizedPathback to summary
private static String sanitizedPath(File file)
sendpackback to summary
private void sendpack(final List<RemoteRefUpdate> updates, final ProgressMonitor monitor) throws TransportException
updateCommandback to summary
private void updateCommand(RemoteRefUpdate u)