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

public Class ReceiveCommand

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.transport.TrackingRefUpdate.Command
Static Imports
org.eclipse.jgit.transport.ReceiveCommand.Result.NOT_ATTEMPTED, .ReceiveCommand.Result.REJECTED_OTHER_REASON

A command being processed by org.eclipse.jgit.transport.ReceivePack.

This command instance roughly translates to the server side representation of the org.eclipse.jgit.transport.RemoteRefUpdate created by the client.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ReceiveCommand.Result

Result of the update command.

public static enum
ReceiveCommand.Type

Type of operation requested.

Field Summary

Modifier and TypeField and Description
private boolean
private Boolean
private String
private final String
private final ObjectId
private final String
private final ObjectId
private final String
private Ref
private boolean
private String
private ReceiveCommand.Result
private ReceiveCommand.Type
private boolean

Constructor Summary

AccessConstructor and Description
public
ReceiveCommand(final ObjectId
the expected old object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref creation.
oldId
,
final ObjectId
the new object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref deletion.
newId
,
final String
name of the ref being affected.
name
)

Create a new command for org.eclipse.jgit.transport.ReceivePack.

public
ReceiveCommand(final ObjectId
the old object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref creation.
oldId
,
final ObjectId
the new object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref deletion.
newId
,
final String
name of the ref being affected.
name
,
final ReceiveCommand.Type type)

Create a new command for org.eclipse.jgit.transport.ReceivePack.

private
ReceiveCommand(ObjectId
the old object id; must not be null. Use ObjectId#zeroId() to indicate a ref creation.
oldId
,
String
new target, must begin with "refs/". Use null to indicate a ref deletion.
newSymref
,
String
name of the reference to make symbolic.
name
)

Create a command to switch a reference from object to symbolic.

private
ReceiveCommand(String
expected old target. Use null to indicate a ref creation.
oldSymref
,
ObjectId
the new object id; must not be null. Use ObjectId#zeroId() to indicate a ref deletion.
newId
,
String
name of the reference to convert from symbolic.
name
)

Create a command to switch a reference from symbolic to object.

private
ReceiveCommand(String
expected old target. Use null to indicate a ref creation.
oldTarget
,
String
new target. Use null to indicate a ref deletion.
newTarget
,
String
name of the reference to make symbolic.
name
)

Create a command to switch a symbolic reference's target.

Method Summary

Modifier and TypeMethod and Description
public static void
abort(Iterable<ReceiveCommand>
commands to mark as failed.
commands
)

Set unprocessed commands as failed due to transaction aborted.

public void
disableRefLog()

Don't record this update in the ref's associated reflog.

public void
execute(ReceivePack
receive-pack session.
rp
)

Execute this command during a receive-pack session.

public static List<ReceiveCommand>

Returns:

a copy of the command list containing only those commands with the desired status.
filter
(Iterable<ReceiveCommand>
commands to filter.
in
,
ReceiveCommand.Result
desired status to filter by.
want
)

Filter a collection of commands according to result.

public static List<ReceiveCommand>

Returns:

a copy of the command list containing only those commands with the desired status.
filter
(List<ReceiveCommand>
commands to filter.
commands
,
ReceiveCommand.Result
desired status to filter by.
want
)

Filter a list of commands according to result.

public String

Returns:

the message associated with a failure status.
getMessage
()

Get the message associated with a failure status.

public ObjectId

Returns:

the requested new value for this ref.
getNewId
()

Get the requested new value for this ref.

public String

Returns:

requested new target for a symbolic reference.
getNewSymref
()

Get requested new target for a symbolic reference.

public ObjectId

Returns:

the old value the client thinks the ref has.
getOldId
()

Get the old value the client thinks the ref has.

public String

Returns:

expected old target for a symbolic reference.
getOldSymref
()

Get expected old target for a symbolic reference.

public Ref

Returns:

the ref, if this was advertised by the connection.
getRef
()

Get the ref, if this was advertised by the connection.

public String

Returns:

message the caller wants to include in the reflog; null if the update should not be logged.
getRefLogMessage
()

Get the message to include in the reflog.

public String

Returns:

the name of the ref being updated.
getRefName
()

Get the name of the ref being updated.

public ReceiveCommand.Result

Returns:

the current status code of this command.
getResult
()

Get the current status code of this command.

public ReceiveCommand.Type

Returns:

the type of this command; see Type.
getType
()

Get the type of this command; see Type.

public boolean

Returns:

whether a custom reflog is set.
hasCustomRefLog
()

Check whether this command has a custom reflog message setting that should override defaults in any containing org.eclipse.jgit.lib.BatchRefUpdate.

public Boolean

Returns:

whether force writing is enabled; null if #setForceRefLog(boolean) was never called.
isForceRefLog
()

Check whether the reflog should be written regardless of repo defaults.

public boolean

Returns:

true if disabled.
isRefLogDisabled
()

Check whether log has been disabled by disableRefLog().

public boolean

Returns:

true if the message should include the result.
isRefLogIncludingResult
()

Check whether the reflog message should include the result of the update, such as fast-forward or force-update.

public static boolean

Returns:

whether the command failed due to transaction aborted, as in abort(Iterable).
isTransactionAborted
(ReceiveCommand
command.
cmd
)

Check whether a command failed due to transaction aborted.

pack-priv void
public void
setForceRefLog(boolean
whether to force.
force
)

Force writing a reflog for the updated ref.

pack-priv void
public void
setRefLogMessage(String
the message to describe this change. If null and appendStatus is false, the reflog will not be updated.
msg
,
boolean
true if the status of the ref change (fast-forward or forced-update) should be appended to the user supplied message.
appendStatus
)

Set the message to include in the reflog.

public void
setResult(ReceiveCommand.Result
the new status code for this command.
s
)

Set the status of this command.

public void
setResult(ReceiveCommand.Result
new status code for this command.
s
,
String
optional message explaining the new status.
m
)

Set the status of this command.

public void
setResult(RefUpdate.Result
the new result code for this command.
r
)

Set the result of this command.

pack-priv void
pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
updateType(RevWalk
an instance to perform the merge test with. The caller must allocate and release this object.
walk
)

Update the type of this command by checking for fast-forward.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

customRefLogback to summary
private boolean customRefLog
forceRefLogback to summary
private Boolean forceRefLog
messageback to summary
private String message
nameback to summary
private final String name
newIdback to summary
private final ObjectId newId
newSymrefback to summary
private final String newSymref
oldIdback to summary
private final ObjectId oldId
oldSymrefback to summary
private final String oldSymref
refback to summary
private Ref ref
refLogIncludeResultback to summary
private boolean refLogIncludeResult
refLogMessageback to summary
private String refLogMessage
statusback to summary
private ReceiveCommand.Result status
typeback to summary
private ReceiveCommand.Type type
typeIsCorrectback to summary
private boolean typeIsCorrect

Constructor Detail

ReceiveCommandback to summary
public ReceiveCommand(final ObjectId oldId, final ObjectId newId, final String name)

Create a new command for org.eclipse.jgit.transport.ReceivePack.

Parameters
oldId:ObjectId

the expected old object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref creation.

newId:ObjectId

the new object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref deletion.

name:String

name of the ref being affected.

ReceiveCommandback to summary
public ReceiveCommand(final ObjectId oldId, final ObjectId newId, final String name, final ReceiveCommand.Type type)

Create a new command for org.eclipse.jgit.transport.ReceivePack.

Parameters
oldId:ObjectId

the old object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref creation.

newId:ObjectId

the new object id; must not be null. Use org.eclipse.jgit.lib.ObjectId#zeroId() to indicate a ref deletion.

name:String

name of the ref being affected.

type:ReceiveCommand.Type

type of the command. Must be org.eclipse.jgit.transport.ReceiveCommand.Type#CREATE if oldId is zero, or org.eclipse.jgit.transport.ReceiveCommand.Type#DELETE if newId is zero.

Since
2.0
ReceiveCommandback to summary
private ReceiveCommand(ObjectId oldId, String newSymref, String name)

Create a command to switch a reference from object to symbolic.

Parameters
oldId:ObjectId

the old object id; must not be null. Use ObjectId#zeroId() to indicate a ref creation.

newSymref:String

new target, must begin with "refs/". Use null to indicate a ref deletion.

name:String

name of the reference to make symbolic.

Since
4.10
ReceiveCommandback to summary
private ReceiveCommand(String oldSymref, ObjectId newId, String name)

Create a command to switch a reference from symbolic to object.

Parameters
oldSymref:String

expected old target. Use null to indicate a ref creation.

newId:ObjectId

the new object id; must not be null. Use ObjectId#zeroId() to indicate a ref deletion.

name:String

name of the reference to convert from symbolic.

Since
4.10
ReceiveCommandback to summary
private ReceiveCommand(String oldTarget, String newTarget, String name)

Create a command to switch a symbolic reference's target.

Parameters
oldTarget:String

expected old target. Use null to indicate a ref creation.

newTarget:String

new target. Use null to indicate a ref deletion.

name:String

name of the reference to make symbolic.

Since
4.10

Method Detail

abortback to summary
public static void abort(Iterable<ReceiveCommand> commands)

Set unprocessed commands as failed due to transaction aborted.

If a command is still org.eclipse.jgit.transport.ReceiveCommand.Result#NOT_ATTEMPTED it will be set to org.eclipse.jgit.transport.ReceiveCommand.Result#REJECTED_OTHER_REASON.

Parameters
commands:Iterable<ReceiveCommand>

commands to mark as failed.

Since
4.2
disableRefLogback to summary
public void disableRefLog()

Don't record this update in the ref's associated reflog.

Equivalent to setRefLogMessage(null, false).

Since
4.9
executeback to summary
public void execute(ReceivePack rp)

Execute this command during a receive-pack session.

Sets the status of the command as a side effect.

Parameters
rp:ReceivePack

receive-pack session.

Since
5.6
filterback to summary
public static List<ReceiveCommand> filter(Iterable<ReceiveCommand> in, ReceiveCommand.Result want)

Filter a collection of commands according to result.

Parameters
in:Iterable<ReceiveCommand>

commands to filter.

want:ReceiveCommand.Result

desired status to filter by.

Returns:List<ReceiveCommand>

a copy of the command list containing only those commands with the desired status.

Since
4.2
filterback to summary
public static List<ReceiveCommand> filter(List<ReceiveCommand> commands, ReceiveCommand.Result want)

Filter a list of commands according to result.

Parameters
commands:List<ReceiveCommand>

commands to filter.

want:ReceiveCommand.Result

desired status to filter by.

Returns:List<ReceiveCommand>

a copy of the command list containing only those commands with the desired status.

Since
2.0
getMessageback to summary
public String getMessage()

Get the message associated with a failure status.

Returns:String

the message associated with a failure status.

getNewIdback to summary
public ObjectId getNewId()

Get the requested new value for this ref.

Returns:ObjectId

the requested new value for this ref.

getNewSymrefback to summary
public String getNewSymref()

Get requested new target for a symbolic reference.

Returns:String

requested new target for a symbolic reference.

Annotations
@Nullable
Since
4.10
getOldIdback to summary
public ObjectId getOldId()

Get the old value the client thinks the ref has.

Returns:ObjectId

the old value the client thinks the ref has.

getOldSymrefback to summary
public String getOldSymref()

Get expected old target for a symbolic reference.

Returns:String

expected old target for a symbolic reference.

Annotations
@Nullable
Since
4.10
getRefback to summary
public Ref getRef()

Get the ref, if this was advertised by the connection.

Returns:Ref

the ref, if this was advertised by the connection.

getRefLogMessageback to summary
public String getRefLogMessage()

Get the message to include in the reflog.

Returns:String

message the caller wants to include in the reflog; null if the update should not be logged.

Annotations
@Nullable
Since
4.9
getRefNameback to summary
public String getRefName()

Get the name of the ref being updated.

Returns:String

the name of the ref being updated.

getResultback to summary
public ReceiveCommand.Result getResult()

Get the current status code of this command.

Returns:ReceiveCommand.Result

the current status code of this command.

getTypeback to summary
public ReceiveCommand.Type getType()

Get the type of this command; see Type.

Returns:ReceiveCommand.Type

the type of this command; see Type.

hasCustomRefLogback to summary
public boolean hasCustomRefLog()

Check whether this command has a custom reflog message setting that should override defaults in any containing org.eclipse.jgit.lib.BatchRefUpdate.

Does not take into account whether #setForceRefLog(boolean) has been called.

Returns:boolean

whether a custom reflog is set.

Since
4.9
isForceRefLogback to summary
public Boolean isForceRefLog()

Check whether the reflog should be written regardless of repo defaults.

Returns:Boolean

whether force writing is enabled; null if #setForceRefLog(boolean) was never called.

Annotations
@Nullable
Since
4.9
isRefLogDisabledback to summary
public boolean isRefLogDisabled()

Check whether log has been disabled by disableRefLog().

Returns:boolean

true if disabled.

Since
4.9
isRefLogIncludingResultback to summary
public boolean isRefLogIncludingResult()

Check whether the reflog message should include the result of the update, such as fast-forward or force-update.

Returns:boolean

true if the message should include the result.

Since
4.9
isTransactionAbortedback to summary
public static boolean isTransactionAborted(ReceiveCommand cmd)

Check whether a command failed due to transaction aborted.

Parameters
cmd:ReceiveCommand

command.

Returns:boolean

whether the command failed due to transaction aborted, as in abort(Iterable).

Since
4.9
rejectback to summary
pack-priv void reject(IOException err)
setForceRefLogback to summary
public void setForceRefLog(boolean force)

Force writing a reflog for the updated ref.

Parameters
force:boolean

whether to force.

Since
4.9
setRefback to summary
pack-priv void setRef(Ref r)
setRefLogMessageback to summary
public void setRefLogMessage(String msg, boolean appendStatus)

Set the message to include in the reflog.

Overrides the default set by setRefLogMessage on any containing org.eclipse.jgit.lib.BatchRefUpdate.

Parameters
msg:String

the message to describe this change. If null and appendStatus is false, the reflog will not be updated.

appendStatus:boolean

true if the status of the ref change (fast-forward or forced-update) should be appended to the user supplied message.

Since
4.9
setResultback to summary
public void setResult(ReceiveCommand.Result s)

Set the status of this command.

Parameters
s:ReceiveCommand.Result

the new status code for this command.

setResultback to summary
public void setResult(ReceiveCommand.Result s, String m)

Set the status of this command.

Parameters
s:ReceiveCommand.Result

new status code for this command.

m:String

optional message explaining the new status.

setResultback to summary
public void setResult(RefUpdate.Result r)

Set the result of this command.

Parameters
r:RefUpdate.Result

the new result code for this command.

setTypeback to summary
pack-priv void setType(ReceiveCommand.Type t)
setTypeFastForwardUpdateback to summary
pack-priv void setTypeFastForwardUpdate()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@SuppressWarnings:nls
@Override
updateTypeback to summary
public void updateType(RevWalk walk) throws 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 into getNewId(). If some commits are not merged the update type is changed to org.eclipse.jgit.transport.ReceiveCommand.Type#UPDATE_NONFASTFORWARD.

Parameters
walk:RevWalk

an instance to perform the merge test with. The caller must allocate and release this object.

Exceptions
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.
org.eclipse.jgit.transport back to summary

public final Enum ReceiveCommand.Result

extends Enum<ReceiveCommand.Result>
Class Inheritance

Result of the update command.

Field Summary

Modifier and TypeField and Description
public static final ReceiveCommand.Result
LOCK_FAILURE

The ref could not be locked and updated atomically; try again.

public static final ReceiveCommand.Result
NOT_ATTEMPTED

The command has not yet been attempted by the server.

public static final ReceiveCommand.Result
OK

The change was completed successfully.

public static final ReceiveCommand.Result
REJECTED_CURRENT_BRANCH

The update affects HEAD and cannot be permitted.

public static final ReceiveCommand.Result
REJECTED_MISSING_OBJECT

One or more objects aren't in the repository.

public static final ReceiveCommand.Result
REJECTED_NOCREATE

The server is configured to deny creation of this ref.

public static final ReceiveCommand.Result
REJECTED_NODELETE

The server is configured to deny deletion of this ref.

public static final ReceiveCommand.Result
REJECTED_NONFASTFORWARD

The update is a non-fast-forward update and isn't permitted.

public static final ReceiveCommand.Result

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ReceiveCommand.Result
public static ReceiveCommand.Result[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

LOCK_FAILUREback to summary
public static final ReceiveCommand.Result LOCK_FAILURE

The ref could not be locked and updated atomically; try again.

NOT_ATTEMPTEDback to summary
public static final ReceiveCommand.Result NOT_ATTEMPTED

The command has not yet been attempted by the server.

OKback to summary
public static final ReceiveCommand.Result OK

The change was completed successfully.

REJECTED_CURRENT_BRANCHback to summary
public static final ReceiveCommand.Result REJECTED_CURRENT_BRANCH

The update affects HEAD and cannot be permitted.

REJECTED_MISSING_OBJECTback to summary
public static final ReceiveCommand.Result REJECTED_MISSING_OBJECT

One or more objects aren't in the repository.

This is severe indication of either repository corruption on the server side, or a bug in the client wherein the client did not supply all required objects during the pack transfer.

REJECTED_NOCREATEback to summary
public static final ReceiveCommand.Result REJECTED_NOCREATE

The server is configured to deny creation of this ref.

REJECTED_NODELETEback to summary
public static final ReceiveCommand.Result REJECTED_NODELETE

The server is configured to deny deletion of this ref.

REJECTED_NONFASTFORWARDback to summary
public static final ReceiveCommand.Result REJECTED_NONFASTFORWARD

The update is a non-fast-forward update and isn't permitted.

REJECTED_OTHER_REASONback to summary
public static final ReceiveCommand.Result REJECTED_OTHER_REASON

Other failure; see ReceiveCommand#getMessage().

Constructor Detail

Resultback to summary
private Result()

Method Detail

valueOfback to summary
public static ReceiveCommand.Result valueOf(String name)
valuesback to summary
public static ReceiveCommand.Result[] values()
org.eclipse.jgit.transport back to summary

public final Enum ReceiveCommand.Type

extends Enum<ReceiveCommand.Type>
Class Inheritance

Type of operation requested.

Field Summary

Modifier and TypeField and Description
public static final ReceiveCommand.Type
CREATE

Create a new ref; the ref must not already exist.

public static final ReceiveCommand.Type
DELETE

Delete an existing ref; the ref should already exist.

public static final ReceiveCommand.Type
UPDATE

Update an existing ref with a fast-forward update.

public static final ReceiveCommand.Type
UPDATE_NONFASTFORWARD

Update an existing ref by potentially discarding objects.

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public static ReceiveCommand.Type
public static ReceiveCommand.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CREATEback to summary
public static final ReceiveCommand.Type CREATE

Create a new ref; the ref must not already exist.

DELETEback to summary
public static final ReceiveCommand.Type DELETE

Delete an existing ref; the ref should already exist.

UPDATEback to summary
public static final ReceiveCommand.Type UPDATE

Update an existing ref with a fast-forward update.

During a fast-forward update no changes will be lost; only new commits are inserted into the ref.

UPDATE_NONFASTFORWARDback to summary
public static final ReceiveCommand.Type UPDATE_NONFASTFORWARD

Update an existing ref by potentially discarding objects.

The current value of the ref is not fully reachable from the new value of the ref, so a successful command may result in one or more objects becoming unreachable.

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static ReceiveCommand.Type valueOf(String name)
valuesback to summary
public static ReceiveCommand.Type[] values()