Class BasePackPushConnection

    • Field Detail

      • CAPABILITY_REPORT_STATUS

        public static final java.lang.String CAPABILITY_REPORT_STATUS
        The client expects a status report after the server processes the pack.
        Since:
        2.0
        See Also:
        Constant Field Values
      • CAPABILITY_DELETE_REFS

        public static final java.lang.String CAPABILITY_DELETE_REFS
        The server supports deleting refs.
        Since:
        2.0
        See Also:
        Constant Field Values
      • CAPABILITY_OFS_DELTA

        public static final java.lang.String CAPABILITY_OFS_DELTA
        The server supports packs with OFS deltas.
        Since:
        2.0
        See Also:
        Constant Field Values
      • CAPABILITY_SIDE_BAND_64K

        public static final java.lang.String CAPABILITY_SIDE_BAND_64K
        The client supports using the 64K side-band for progress messages.
        Since:
        2.0
        See Also:
        Constant Field Values
      • CAPABILITY_PUSH_OPTIONS

        public static final java.lang.String CAPABILITY_PUSH_OPTIONS
        The server supports the receiving of push options.
        Since:
        4.5
        See Also:
        Constant Field Values
      • thinPack

        private final boolean thinPack
      • atomic

        private final boolean atomic
      • pushOptions

        private java.util.List<java.lang.String> pushOptions
        A list of option strings associated with this push.
      • capableAtomic

        private boolean capableAtomic
      • capableDeleteRefs

        private boolean capableDeleteRefs
      • capableReport

        private boolean capableReport
      • capableSideBand

        private boolean capableSideBand
      • capableOfsDelta

        private boolean capableOfsDelta
      • capablePushOptions

        private boolean capablePushOptions
      • sentCommand

        private boolean sentCommand
      • writePack

        private boolean writePack
      • packTransferTime

        private long packTransferTime
        Time in milliseconds spent transferring the pack data.
    • Constructor Detail

      • BasePackPushConnection

        public BasePackPushConnection​(PackTransport packTransport)
        Create a new connection to push using the native git transport.
        Parameters:
        packTransport - the transport.
    • Method Detail

      • push

        public void push​(ProgressMonitor monitor,
                         java.util.Map<java.lang.String,​RemoteRefUpdate> refUpdates)
                  throws TransportException
        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 TransportException.

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

        Specified by:
        push in interface PushConnection
        Parameters:
        monitor - 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 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 RemoteRefUpdate.Status.NOT_ATTEMPTED should passed. Implementation must ensure that and appropriate status with optional message should be set during call. No refUpdate with RemoteRefUpdate.Status.AWAITING_REPORT or RemoteRefUpdate.Status.NOT_ATTEMPTED can be leaved by implementation after return from this call.
        Throws:
        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.
      • push

        public void push​(ProgressMonitor monitor,
                         java.util.Map<java.lang.String,​RemoteRefUpdate> refUpdates,
                         java.io.OutputStream outputStream)
                  throws TransportException
        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 TransportException.

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

        Specified by:
        push in interface PushConnection
        Parameters:
        monitor - 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 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 RemoteRefUpdate.Status.NOT_ATTEMPTED should passed. Implementation must ensure that and appropriate status with optional message should be set during call. No refUpdate with RemoteRefUpdate.Status.AWAITING_REPORT or RemoteRefUpdate.Status.NOT_ATTEMPTED can be leaved by implementation after return from this call.
        outputStream - output stream to write sideband messages to
        Throws:
        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.
      • noRepository

        protected TransportException noRepository​(java.lang.Throwable cause)
        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.
        Overrides:
        noRepository in class BasePackConnection
        Parameters:
        cause - root cause exception
        Returns:
        a TransportException saying a repository cannot be found and possibly why.
      • doPush

        protected void doPush​(ProgressMonitor monitor,
                              java.util.Map<java.lang.String,​RemoteRefUpdate> refUpdates,
                              java.io.OutputStream outputStream)
                       throws TransportException
        Push one or more objects and update the remote repository.
        Parameters:
        monitor - progress monitor to receive status updates.
        refUpdates - update commands to be applied to the remote repository.
        outputStream - output stream to write sideband messages to
        Throws:
        TransportException - if any exception occurs.
        Since:
        3.0
      • writeCommands

        private void writeCommands​(java.util.Collection<RemoteRefUpdate> refUpdates,
                                   ProgressMonitor monitor,
                                   java.io.OutputStream outputStream)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • transmitOptions

        private void transmitOptions()
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • enableCapabilities

        private java.lang.String enableCapabilities​(ProgressMonitor monitor,
                                                    java.io.OutputStream outputStream)
      • writePack

        private void writePack​(java.util.Map<java.lang.String,​RemoteRefUpdate> refUpdates,
                               ProgressMonitor monitor)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readStatusReport

        private void readStatusReport​(java.util.Map<java.lang.String,​RemoteRefUpdate> refUpdates)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readStringLongTimeout

        private java.lang.String readStringLongTimeout()
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getPushOptions

        public java.util.List<java.lang.String> getPushOptions()
        Gets the list of option strings associated with this push.
        Returns:
        pushOptions
        Since:
        4.5