public class ReceivePack extends BaseReceivePack
BaseReceivePack.FirstLine, BaseReceivePack.MessageOutputWrapper, BaseReceivePack.ReceiveConfig, BaseReceivePack.Reporter
Modifier and Type | Field and Description |
---|---|
private PostReceiveHook |
postReceive
Hook to report on the commands after execution.
|
private PreReceiveHook |
preReceive
Hook to validate the update commands before execution.
|
private java.util.List<java.lang.String> |
pushOptions |
private boolean |
reportStatus
If
BasePackPushConnection.CAPABILITY_REPORT_STATUS is enabled. |
private boolean |
usePushOptions
Whether the client intends to use push options.
|
Constructor and Description |
---|
ReceivePack(Repository into)
Create a new pack receive for an open repository.
|
Modifier and Type | Method and Description |
---|---|
private void |
autoGc() |
protected void |
enableCapabilities()
Enable capabilities based on a previously read capabilities line.
|
java.util.Map<java.lang.String,Ref> |
getAdvertisedRefs()
Get refs which were advertised to the client.
|
protected java.lang.String |
getLockMessageProcessName()
Get the process name used for pack lock messages.
|
PostReceiveHook |
getPostReceiveHook()
Get the hook invoked after updates occur.
|
PreReceiveHook |
getPreReceiveHook()
Get the hook invoked before updates occur.
|
PushCertificate |
getPushCertificate()
Get the push certificate used to verify the pusher's identity.
|
java.util.List<java.lang.String> |
getPushOptions()
Gets an unmodifiable view of the option strings associated with the push.
|
Repository |
getRepository()
Get the repository this receive completes into.
|
RevWalk |
getRevWalk()
Get the RevWalk instance used by this connection.
|
(package private) void |
readPostCommands(PacketLineIn in) |
void |
receive(java.io.InputStream input,
java.io.OutputStream output,
java.io.OutputStream messages)
Execute the receive task on the socket.
|
private void |
service() |
void |
setAdvertisedRefs(java.util.Map<java.lang.String,Ref> allRefs,
java.util.Set<ObjectId> additionalHaves)
Set the refs advertised by this ReceivePack.
|
void |
setEchoCommandFailures(boolean echo)
Deprecated.
no widely used Git versions need this any more
|
void |
setPostReceiveHook(PostReceiveHook h)
Set the hook which is invoked after commands are executed.
|
void |
setPreReceiveHook(PreReceiveHook h)
Set the hook which is invoked prior to commands being executed.
|
void |
setPushCertificate(PushCertificate cert)
Set the push certificate used to verify the pusher's identity.
|
void |
setPushOptions(java.util.List<java.lang.String> options)
Set the push options supplied by the client.
|
anyRejects, checkRequestWasRead, close, executeCommands, failPendingCommands, filterCommands, getAdvertisedObjects, getAdvertisedOrDefaultRefs, getAdvertiseRefsHook, getAllCommands, getClientShallowCommits, getMessageOutputStream, getPackSize, getPeerUserAgent, getReceivedPackStatistics, getRefFilter, getRefLogIdent, getTimeout, hasCommands, hasError, init, isAllowBranchDeletes, isAllowCreates, isAllowDeletes, isAllowNonFastForwards, isAllowPushOptions, isAllowQuiet, isAtomic, isBiDirectionalPipe, isCapabilityEnabled, isCheckReceivedObjects, isCheckReferencedObjectsAreReachable, isExpectDataAfterPackFooter, isQuiet, isSideBand, needPack, parseCommand, receivePackAndCheckConnectivity, recvCommands, release, sendAdvertisedRefs, sendError, sendMessage, sendStatusReport, setAdvertiseRefsHook, setAllowBranchDeletes, setAllowCreates, setAllowDeletes, setAllowNonFastForwards, setAllowPushOptions, setAllowQuiet, setAtomic, setBiDirectionalPipe, setCheckReceivedObjects, setCheckReferencedObjectsAreReachable, setExpectDataAfterPackFooter, setMaxCommandBytes, setMaxCommandDiscardBytes, setMaxObjectSizeLimit, setMaxPackSizeLimit, setObjectChecker, setRefFilter, setRefLogIdent, setSignedPushConfig, setTimeout, unlockPack, validateCommands
private PreReceiveHook preReceive
private PostReceiveHook postReceive
private boolean reportStatus
BasePackPushConnection.CAPABILITY_REPORT_STATUS
is enabled.private boolean usePushOptions
private java.util.List<java.lang.String> pushOptions
public ReceivePack(Repository into)
into
- the destination repository.public final Repository getRepository()
getRepository
in class BaseReceivePack
public final RevWalk getRevWalk()
getRevWalk
in class BaseReceivePack
public final java.util.Map<java.lang.String,Ref> getAdvertisedRefs()
getAdvertisedRefs
in class BaseReceivePack
setAdvertisedRefs(Map, Set)
has not been called yet.public void setAdvertisedRefs(java.util.Map<java.lang.String,Ref> allRefs, java.util.Set<ObjectId> additionalHaves)
Intended to be called from a
PreReceiveHook
.
setAdvertisedRefs
in class BaseReceivePack
allRefs
- explicit set of references to claim as advertised by this
ReceivePack instance. This overrides any references that may
exist in the source repository. The map is passed to the
configured BaseReceivePack.getRefFilter()
. If null, assumes all refs
were advertised.additionalHaves
- explicit set of additional haves to claim as advertised. If
null, assumes the default set of additional haves from the
repository.public PushCertificate getPushCertificate()
Only valid after commands are read from the wire.
getPushCertificate
in class BaseReceivePack
public void setPushCertificate(PushCertificate cert)
Should only be called if reconstructing an instance without going through
the normal BaseReceivePack.recvCommands()
flow.
setPushCertificate
in class BaseReceivePack
cert
- the push certificate to set.@Nullable public java.util.List<java.lang.String> getPushOptions()
public void setPushOptions(@Nullable java.util.List<java.lang.String> options)
Should only be called if reconstructing an instance without going through
the normal BaseReceivePack.recvCommands()
flow.
options
- the list of options supplied by the client. The
ReceivePack
instance takes ownership of this list.
Callers are encouraged to first create a copy if the list may
be modified later.public PreReceiveHook getPreReceiveHook()
public void setPreReceiveHook(PreReceiveHook h)
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.
h
- the hook instance; may be null to disable the hook.public PostReceiveHook getPostReceiveHook()
public void setPostReceiveHook(PostReceiveHook h)
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.
h
- the hook instance; may be null to disable the hook.@Deprecated public void setEchoCommandFailures(boolean echo)
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.public void receive(java.io.InputStream input, java.io.OutputStream output, java.io.OutputStream messages) throws java.io.IOException
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.java.io.IOException
protected void enableCapabilities()
enableCapabilities
in class BaseReceivePack
void readPostCommands(PacketLineIn in) throws java.io.IOException
readPostCommands
in class BaseReceivePack
in
- request stream.java.io.IOException
- request line cannot be read.private void service() throws java.io.IOException
java.io.IOException
private void autoGc()
protected java.lang.String getLockMessageProcessName()
getLockMessageProcessName
in class BaseReceivePack