Package org.eclipse.jgit.transport
Class ReceiveCommand
- java.lang.Object
-
- org.eclipse.jgit.transport.ReceiveCommand
-
public class ReceiveCommand extends java.lang.ObjectA command being processed byBaseReceivePack.This command instance roughly translates to the server side representation of the
RemoteRefUpdatecreated by the client.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReceiveCommand.ResultResult of the update command.static classReceiveCommand.TypeType of operation requested.
-
Constructor Summary
Constructors Constructor Description ReceiveCommand(ObjectId oldId, ObjectId newId, java.lang.String name)Create a new command forBaseReceivePack.ReceiveCommand(ObjectId oldId, ObjectId newId, java.lang.String name, ReceiveCommand.Type type)Create a new command forBaseReceivePack.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(BaseReceivePack rp)Execute this command during a receive-pack session.static java.util.List<ReceiveCommand>filter(java.util.List<ReceiveCommand> commands, ReceiveCommand.Result want)Filter a list of commands according to result.java.lang.StringgetMessage()ObjectIdgetNewId()ObjectIdgetOldId()RefgetRef()java.lang.StringgetRefName()ReceiveCommand.ResultgetResult()ReceiveCommand.TypegetType()voidsetResult(RefUpdate.Result r)Set the result of this command.voidsetResult(ReceiveCommand.Result s)Set the status of this command.voidsetResult(ReceiveCommand.Result s, java.lang.String m)Set the status of this command.java.lang.StringtoString()voidupdateType(RevWalk walk)Update the type of this command by checking for fast-forward.
-
-
-
Constructor Detail
-
ReceiveCommand
public ReceiveCommand(ObjectId oldId, ObjectId newId, java.lang.String name)
Create a new command forBaseReceivePack.- Parameters:
oldId- the old object id; must not be null. UseObjectId.zeroId()to indicate a ref creation.newId- the new object id; must not be null. UseObjectId.zeroId()to indicate a ref deletion.name- name of the ref being affected.
-
ReceiveCommand
public ReceiveCommand(ObjectId oldId, ObjectId newId, java.lang.String name, ReceiveCommand.Type type)
Create a new command forBaseReceivePack.- Parameters:
oldId- the old object id; must not be null. UseObjectId.zeroId()to indicate a ref creation.newId- the new object id; must not be null. UseObjectId.zeroId()to indicate a ref deletion.name- name of the ref being affected.type- type of the command.- Since:
- 2.0
-
-
Method Detail
-
filter
public static java.util.List<ReceiveCommand> filter(java.util.List<ReceiveCommand> commands, ReceiveCommand.Result want)
Filter a list of commands according to result.- Parameters:
commands- commands to filter.want- desired status to filter by.- Returns:
- a copy of the command list containing only those commands with the desired status.
- Since:
- 2.0
-
getOldId
public ObjectId getOldId()
- Returns:
- the old value the client thinks the ref has.
-
getNewId
public ObjectId getNewId()
- Returns:
- the requested new value for this ref.
-
getRefName
public java.lang.String getRefName()
- Returns:
- the name of the ref being updated.
-
getType
public ReceiveCommand.Type getType()
- Returns:
- the type of this command; see
ReceiveCommand.Type.
-
getRef
public Ref getRef()
- Returns:
- the ref, if this was advertised by the connection.
-
getResult
public ReceiveCommand.Result getResult()
- Returns:
- the current status code of this command.
-
getMessage
public java.lang.String getMessage()
- Returns:
- the message associated with a failure status.
-
setResult
public void setResult(ReceiveCommand.Result s)
Set the status of this command.- Parameters:
s- the new status code for this command.
-
setResult
public void setResult(ReceiveCommand.Result s, java.lang.String m)
Set the status of this command.- Parameters:
s- new status code for this command.m- optional message explaining the new status.
-
updateType
public void updateType(RevWalk walk) throws java.io.IOException
Update the type of this command by checking for fast-forward.If the command's current type is UPDATE, a merge test will be performed using the supplied RevWalk to determine if
getOldId()is fully merged intogetNewId(). If some commits are not merged the update type is changed toReceiveCommand.Type.UPDATE_NONFASTFORWARD.- Parameters:
walk- an instance to perform the merge test with. The caller must allocate and release this object.- Throws:
java.io.IOException- either oldId or newId is not accessible in the repository used by the RevWalk. This usually indicates data corruption, and the command cannot be processed.
-
execute
public void execute(BaseReceivePack rp)
Execute this command during a receive-pack session.Sets the status of the command as a side effect.
- Parameters:
rp- receive-pack session.- Since:
- 2.0
-
setResult
public void setResult(RefUpdate.Result r)
Set the result of this command.- Parameters:
r- the new result code for this command.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-