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

public abstract Class BasePackPushConnection

extends BasePackConnection
implements PushConnection
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.transport.PushConnection, org.eclipse.jgit.transport.Connection, java.lang.AutoCloseable
Known Direct Subclasses
org.eclipse.jgit.transport.InternalPushConnection, org.eclipse.jgit.transport.TransportGitAnon.TcpPushConnection, org.eclipse.jgit.transport.TransportGitSsh.SshPushConnection, org.eclipse.jgit.transport.TransportHttp.SmartHttpPushConnection, org.eclipse.jgit.transport.TransportLocal.ForkLocalPushConnection
Static Imports
org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_ATOMIC

Push implementation using the native Git pack transfer service.

This is the canonical implementation for transferring objects to the remote repository from the local repository by talking to the 'git-receive-pack' service. Objects are packed on the local side into a pack file and then sent to the remote repository.

This connection requires only a bi-directional pipe or socket, and thus is easily wrapped up into a local process pipe, anonymous TCP socket, or a command executed through an SSH tunnel.

This implementation honors org.eclipse.jgit.transport.Transport#isPushThin() option.

Concrete implementations should just call init(java.io.InputStream, java.io.OutputStream) and readAdvertisedRefs() methods in constructor or before any use. They should also handle resources releasing in close() method if needed.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final boolean
public static final String
CAPABILITY_DELETE_REFS

The server supports deleting refs.

public static final String
CAPABILITY_OFS_DELTA

The server supports packs with OFS deltas.

public static final String
CAPABILITY_PUSH_OPTIONS

The server supports the receiving of push options.

public static final String
CAPABILITY_REPORT_STATUS

The client expects a status report after the server processes the pack.

public static final String
CAPABILITY_SIDE_BAND_64K

The client supports using the 64K side-band for progress messages.

private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private long
packTransferTime

Time in milliseconds spent transferring the pack data.

private List<String>
pushOptions

A list of option strings associated with this push.

private boolean
private final boolean
private final boolean
private boolean
Inherited from org.eclipse.jgit.transport.BasePackConnection:
additionalHavesCAPABILITY_SYMREF_PREFIXinlocaloutoutNeedsEndpckInpckOutstatelessRPCtimeoutIntimeoutOuttransporturi

Constructor Summary

AccessConstructor and Description
public
BasePackPushConnection(PackTransport
the transport.
packTransport
)

Create a new connection to push using the native git transport.

Method Summary

Modifier and TypeMethod and Description
protected void
doPush(final ProgressMonitor
progress monitor to receive status updates.
monitor
,
final Map<String, RemoteRefUpdate>
update commands to be applied to the remote repository.
refUpdates
,
OutputStream
output stream to write sideband messages to
outputStream
)

Push one or more objects and update the remote repository.

private String
enableCapabilities(final ProgressMonitor monitor, OutputStream outputStream)

public List<String>

Returns:

pushOptions
getPushOptions
()

Gets the list of option strings associated with this push.

public boolean

Returns:

true if push use bitmaps.
isUseBitmaps
()

Whether to use bitmaps for push.

protected TransportException
noRepository(Throwable
root cause exception
cause
)

Overrides org.eclipse.jgit.transport.BasePackConnection.noRepository.

Create an exception to indicate problems finding a remote repository.

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
outputStream
)

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

Pushes to the remote repository basing on provided specification.

private void
private String
private void
private void
writeCommands(final Collection<RemoteRefUpdate> refUpdates, final ProgressMonitor monitor, OutputStream outputStream)

private void
writePack(final Map<String, RemoteRefUpdate> refUpdates, final ProgressMonitor monitor)

Inherited from org.eclipse.jgit.transport.BasePackConnection:
addUserAgentCapabilitycloseendOutgetCapabilitygetPeerUserAgentgetProtocolVersioninitisCapableOflsRefsreadAdvertisedRefssetProtocolVersionupdateWithSymRefswantCapability

Field Detail

atomicback to summary
private final boolean atomic
CAPABILITY_DELETE_REFSback to summary
public static final String CAPABILITY_DELETE_REFS

The server supports deleting refs.

Since
2.0
CAPABILITY_OFS_DELTAback to summary
public static final String CAPABILITY_OFS_DELTA

The server supports packs with OFS deltas.

Since
2.0
CAPABILITY_PUSH_OPTIONSback to summary
public static final String CAPABILITY_PUSH_OPTIONS

The server supports the receiving of push options.

Since
4.5
CAPABILITY_REPORT_STATUSback to summary
public static final String CAPABILITY_REPORT_STATUS

The client expects a status report after the server processes the pack.

Since
2.0
CAPABILITY_SIDE_BAND_64Kback to summary
public static final String CAPABILITY_SIDE_BAND_64K

The client supports using the 64K side-band for progress messages.

Since
2.0
capableAtomicback to summary
private boolean capableAtomic
capableDeleteRefsback to summary
private boolean capableDeleteRefs
capableOfsDeltaback to summary
private boolean capableOfsDelta
capablePushOptionsback to summary
private boolean capablePushOptions
capableReportback to summary
private boolean capableReport
capableSideBandback to summary
private boolean capableSideBand
packTransferTimeback to summary
private long packTransferTime

Time in milliseconds spent transferring the pack data.

pushOptionsback to summary
private List<String> pushOptions

A list of option strings associated with this push.

sentCommandback to summary
private boolean sentCommand
thinPackback to summary
private final boolean thinPack
useBitmapsback to summary
private final boolean useBitmaps
writePackback to summary
private boolean writePack

Constructor Detail

BasePackPushConnectionback to summary
public BasePackPushConnection(PackTransport packTransport)

Create a new connection to push using the native git transport.

Parameters
packTransport:PackTransport

the transport.

Method Detail

doPushback to summary
protected void doPush(final ProgressMonitor monitor, final Map<String, RemoteRefUpdate> refUpdates, OutputStream outputStream) throws TransportException

Push one or more objects and update the remote repository.

Parameters
monitor:ProgressMonitor

progress monitor to receive status updates.

refUpdates:Map<String, RemoteRefUpdate>

update commands to be applied to the remote repository.

outputStream:OutputStream

output stream to write sideband messages to

Exceptions
TransportException:
if any exception occurs.
Since
3.0
enableCapabilitiesback to summary
private String enableCapabilities(final ProgressMonitor monitor, OutputStream outputStream)
getPushOptionsback to summary
public List<String> getPushOptions()

Gets the list of option strings associated with this push.

Returns:List<String>

pushOptions

Since
4.5
isUseBitmapsback to summary
public boolean isUseBitmaps()

Whether to use bitmaps for push.

Returns:boolean

true if push use bitmaps.

Since
6.4
noRepositoryback to summary
protected TransportException noRepository(Throwable cause)

Overrides org.eclipse.jgit.transport.BasePackConnection.noRepository.

Doc from org.eclipse.jgit.transport.BasePackConnection.noRepository.

Create an exception to indicate problems finding a remote repository. The caller is expected to throw the returned exception. Subclasses may override this method to provide better diagnostics.

Parameters
cause:Throwable

root cause exception

Returns:TransportException

a TransportException saying a repository cannot be found and possibly why.

Annotations
@Override
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 outputStream) 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.

outputStream: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.
readStatusReportback to summary
private void readStatusReport(Map<String, RemoteRefUpdate> refUpdates) throws IOException
readStringLongTimeoutback to summary
private String readStringLongTimeout() throws IOException
transmitOptionsback to summary
private void transmitOptions() throws IOException
writeCommandsback to summary
private void writeCommands(final Collection<RemoteRefUpdate> refUpdates, final ProgressMonitor monitor, OutputStream outputStream) throws IOException
writePackback to summary
private void writePack(final Map<String, RemoteRefUpdate> refUpdates, final ProgressMonitor monitor) throws IOException
org.eclipse.jgit.transport back to summary

private Class BasePackPushConnection.CheckingSideBandOutputStream

extends OutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final InputStream
private final OutputStream

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private IOException
public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.

public void
write(int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[]
the data.
buf
,
int
the start offset in the data.
ptr
,
int
the number of bytes to write.
cnt
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.OutputStream:
closenullOutputStreamwrite

Field Detail

inback to summary
private final InputStream in
outback to summary
private final OutputStream out

Constructor Detail

CheckingSideBandOutputStreamback to summary
pack-priv CheckingSideBandOutputStream(InputStream in, OutputStream out)

Method Detail

checkErrorback to summary
private IOException checkError(IOException e1)
flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeback to summary
public void write(byte[] buf, int ptr, int cnt) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
buf:byte[]

the data.

ptr:int

the start offset in the data.

cnt:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.