Class ReceivePack


  • public class ReceivePack
    extends BaseReceivePack
    Implements the server side of a push connection, receiving objects.
    • Constructor Detail

      • ReceivePack

        public ReceivePack​(Repository into)
        Create a new pack receive for an open repository.
        Parameters:
        into - the destination repository.
    • Method Detail

      • getPreReceiveHook

        public PreReceiveHook getPreReceiveHook()
        Returns:
        the hook invoked before updates occur.
      • setPreReceiveHook

        public void setPreReceiveHook​(PreReceiveHook h)
        Set the hook which is invoked prior to commands being executed.

        Only valid commands (those which have no obvious errors according to the received input and this instance's configuration) are passed into the hook. The hook may mark a command with a result of any value other than ReceiveCommand.Result.NOT_ATTEMPTED to block its execution.

        The hook may be called with an empty command collection if the current set is completely invalid.

        Parameters:
        h - the hook instance; may be null to disable the hook.
      • getPostReceiveHook

        public PostReceiveHook getPostReceiveHook()
        Returns:
        the hook invoked after updates occur.
      • setPostReceiveHook

        public void setPostReceiveHook​(PostReceiveHook h)
        Set the hook which is invoked after commands are executed.

        Only successful commands (type is ReceiveCommand.Result.OK) are passed into the hook. The hook may be called with an empty command collection if the current set all resulted in an error.

        Parameters:
        h - the hook instance; may be null to disable the hook.
      • setEchoCommandFailures

        public void setEchoCommandFailures​(boolean echo)
        Parameters:
        echo - if true this class will report command failures as warning messages before sending the command results. This is usually not necessary, but may help buggy Git clients that discard the errors when all branches fail.
      • receive

        public void receive​(InputStream input,
                            OutputStream output,
                            OutputStream messages)
                     throws IOException
        Execute the receive task on the socket.
        Parameters:
        input - raw input to read client commands and pack data from. Caller must ensure the input is buffered, otherwise read performance may suffer.
        output - response back to the Git network client. Caller must ensure the output is buffered, otherwise write performance may suffer.
        messages - secondary "notice" channel to send additional messages out through. When run over SSH this should be tied back to the standard error channel of the command execution. For most other network connections this should be null.
        Throws:
        IOException