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

public Class RemoteRefUpdate

extends Object
Class Inheritance
Imports
java.io.IOException, java.text.MessageFormat, java.util.Collection, org.eclipse.jgit.annotations.NonNull, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.ObjectId, .Ref, .RefUpdate, .Repository, org.eclipse.jgit.revwalk.RevWalk

Represent request and status of a remote ref update. Specification is provided by client, while status is handled by org.eclipse.jgit.transport.PushProcess class, being read-only for client.

Client can create instances of this class directly, basing on user specification and advertised refs (org.eclipse.jgit.transport.Connection or through org.eclipse.jgit.transport.Transport helper methods. Apply this specification on remote repository using org.eclipse.jgit.transport.Transport#push(org.eclipse.jgit.lib.ProgressMonitor, java.util.Collection) method.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
RemoteRefUpdate.Status

Represent current status of a remote ref update.

Field Summary

Modifier and TypeField and Description
private ObjectId
private boolean
private Collection<RefSpec>
fetchSpecs

If set, the RemoteRefUpdate is a placeholder for the "matching" RefSpec to be expanded after the advertisements have been received in a push.

private final boolean
private final Repository
private RefUpdate
private String
private final ObjectId
private final String
private final String
private RemoteRefUpdate.Status
private final TrackingRefUpdate

Constructor Summary

AccessConstructor and Description
public
RemoteRefUpdate(Repository
local repository to push from.
localDb
,
String
source revision - any string resolvable by org.eclipse.jgit.lib.Repository#resolve(String). This resolves to the new object that the caller want remote ref to be after update. Use null or org.eclipse.jgit.lib.ObjectId#zeroId() string for delete request.
srcRef
,
String
full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).
remoteName
,
boolean
true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).
forceUpdate
,
String
optional full name of a local stored tracking branch, to update after push, e.g. "refs/remotes/zawir/dirty" (no wildcard, no short name); null if no local tracking branch should be updated.
localName
,
ObjectId
optional object id that caller is expecting, requiring to be advertised by remote side before update; update will take place ONLY if remote side advertise exactly this expected id; null if caller doesn't care what object id remote side advertise. Use org.eclipse.jgit.lib.ObjectId#zeroId() when expecting no remote ref with this name.
expectedOldObjectId
)

Construct remote ref update request by providing an update specification.

public
RemoteRefUpdate(Repository
local repository to push from.
localDb
,
Ref
source revision. Use null to delete.
srcRef
,
String
full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).
remoteName
,
boolean
true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).
forceUpdate
,
String
optional full name of a local stored tracking branch, to update after push, e.g. "refs/remotes/zawir/dirty" (no wildcard, no short name); null if no local tracking branch should be updated.
localName
,
ObjectId
optional object id that caller is expecting, requiring to be advertised by remote side before update; update will take place ONLY if remote side advertise exactly this expected id; null if caller doesn't care what object id remote side advertise. Use org.eclipse.jgit.lib.ObjectId#zeroId() when expecting no remote ref with this name.
expectedOldObjectId
)

Construct remote ref update request by providing an update specification.

public
RemoteRefUpdate(Repository
local repository to push from.
localDb
,
String
source revision to label srcId with. If null srcId.name() will be used instead.
srcRef
,
ObjectId
The new object that the caller wants remote ref to be after update. Use null or org.eclipse.jgit.lib.ObjectId#zeroId() for delete request.
srcId
,
String
full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).
remoteName
,
boolean
true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).
forceUpdate
,
String
optional full name of a local stored tracking branch, to update after push, e.g. "refs/remotes/zawir/dirty" (no wildcard, no short name); null if no local tracking branch should be updated.
localName
,
ObjectId
optional object id that caller is expecting, requiring to be advertised by remote side before update; update will take place ONLY if remote side advertise exactly this expected id; null if caller doesn't care what object id remote side advertise. Use org.eclipse.jgit.lib.ObjectId#zeroId() when expecting no remote ref with this name.
expectedOldObjectId
)

Construct remote ref update request by providing an update specification.

private
RemoteRefUpdate(Repository localDb, String srcRef, ObjectId srcId, String remoteName, boolean forceUpdate, String localName, Collection<RefSpec> fetchSpecs, ObjectId expectedOldObjectId)

public
RemoteRefUpdate(RemoteRefUpdate
configuration base.
base
,
ObjectId
new expected object id value.
newExpectedOldObjectId
)

Create a new instance of this object basing on existing instance for configuration.

pack-priv
RemoteRefUpdate(Repository
local repository to push from
localDb
,
boolean
whether non-fast-forward updates shall be allowed
forceUpdate
,
Collection<RefSpec>
The fetch RefSpecs to use when this placeholder is expanded to determine remote tracking branch updates
fetchSpecs
)

Creates a "placeholder" update for the "matching" RefSpec ":".

Method Summary

Modifier and TypeMethod and Description
public ObjectId

Returns:

expectedOldObjectId required to be advertised by remote side, as set in constructor; may be null.
getExpectedOldObjectId
()

Get expected old object id

pack-priv Collection<RefSpec>

Returns:

the fetch RefSpecs, or null if this.isMatching() == false
getFetchSpecs
()

Retrieves the fetch RefSpecs of this RemoteRefUpdate.

public String

Returns:

message describing reasons of status when needed/possible; may be null.
getMessage
()

Get message describing reasons of status when needed/possible; may be null.

public ObjectId

Returns:

newObjectId for remote ref, as set in constructor.
getNewObjectId
()

Get new object id

public String

Returns:

name of remote ref to update, as set in constructor.
getRemoteName
()

Get name of remote ref to update

public String

Returns:

source revision as specified by user (in constructor), could be any string parseable by org.eclipse.jgit.lib.Repository#resolve(String); can be null if specified that way in constructor - this stands for delete request.
getSrcRef
()

Get source revision as specified by user (in constructor)

public RemoteRefUpdate.Status

Returns:

status of remote ref update operation.
getStatus
()

Get status of remote ref update operation.

public TrackingRefUpdate

Returns:

local tracking branch update if localName was set in constructor.
getTrackingRefUpdate
()

Get tracking branch update if localName was set in constructor.

public boolean

Returns:

true if user specified a local tracking branch for remote update; false otherwise.
hasTrackingRefUpdate
()

Whether user specified a local tracking branch for remote update

public boolean

Returns:

true if this update is deleting update; false otherwise.
isDelete
()

Whether this update is a deleting update

public boolean

Returns:

true if some object is required to be advertised by remote side, as set in constructor; false otherwise.
isExpectingOldObjectId
()

Whether some object is required to be advertised by remote side, as set in constructor

public boolean

Returns:

true if update was fast-forward; false otherwise.
isFastForward
()

Check whether update was fast-forward.

public boolean

Returns:

true if this update is forced regardless of old remote ref object; false otherwise.
isForceUpdate
()

Whether this update is forced regardless of old remote ref object

public boolean

Returns:

true if this is a placeholder, false otherwise
isMatching
()

Tells whether this RemoteRefUpdate is a placeholder for a "matching" RefSpec.

pack-priv void
pack-priv void
setFastForward(boolean fastForward)

pack-priv void
setMessage(String message)

pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected void
updateTrackingRef(RevWalk
walker used for checking update properties.
walk
)

Update locally stored tracking branch with the new object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

expectedOldObjectIdback to summary
private ObjectId expectedOldObjectId
fastForwardback to summary
private boolean fastForward
fetchSpecsback to summary
private Collection<RefSpec> fetchSpecs

If set, the RemoteRefUpdate is a placeholder for the "matching" RefSpec to be expanded after the advertisements have been received in a push.

forceUpdateback to summary
private final boolean forceUpdate
localDbback to summary
private final Repository localDb
localUpdateback to summary
private RefUpdate localUpdate
messageback to summary
private String message
newObjectIdback to summary
private final ObjectId newObjectId
remoteNameback to summary
private final String remoteName
srcRefback to summary
private final String srcRef
statusback to summary
private RemoteRefUpdate.Status status
trackingRefUpdateback to summary
private final TrackingRefUpdate trackingRefUpdate

Constructor Detail

RemoteRefUpdateback to summary
public RemoteRefUpdate(Repository localDb, String srcRef, String remoteName, boolean forceUpdate, String localName, ObjectId expectedOldObjectId) throws IOException

Construct remote ref update request by providing an update specification. Object is created with default org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED status and no message.

Parameters
localDb:Repository

local repository to push from.

srcRef:String

source revision - any string resolvable by org.eclipse.jgit.lib.Repository#resolve(String). This resolves to the new object that the caller want remote ref to be after update. Use null or org.eclipse.jgit.lib.ObjectId#zeroId() string for delete request.

remoteName:String

full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).

forceUpdate:boolean

true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).

localName:String

optional full name of a local stored tracking branch, to update after push, e.g. "refs/remotes/zawir/dirty" (no wildcard, no short name); null if no local tracking branch should be updated.

expectedOldObjectId:ObjectId

optional object id that caller is expecting, requiring to be advertised by remote side before update; update will take place ONLY if remote side advertise exactly this expected id; null if caller doesn't care what object id remote side advertise. Use org.eclipse.jgit.lib.ObjectId#zeroId() when expecting no remote ref with this name.

Exceptions
IOException:
when I/O error occurred during creating org.eclipse.jgit.transport.TrackingRefUpdate for local tracking branch or srcRef can't be resolved to any object.
IllegalArgumentException:
if some required parameter was null
RemoteRefUpdateback to summary
public RemoteRefUpdate(Repository localDb, Ref srcRef, String remoteName, boolean forceUpdate, String localName, ObjectId expectedOldObjectId) throws IOException

Construct remote ref update request by providing an update specification. Object is created with default org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED status and no message.

Parameters
localDb:Repository

local repository to push from.

srcRef:Ref

source revision. Use null to delete.

remoteName:String

full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).

forceUpdate:boolean

true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).

localName:String

optional full name of a local stored tracking branch, to update after push, e.g. "refs/remotes/zawir/dirty" (no wildcard, no short name); null if no local tracking branch should be updated.

expectedOldObjectId:ObjectId

optional object id that caller is expecting, requiring to be advertised by remote side before update; update will take place ONLY if remote side advertise exactly this expected id; null if caller doesn't care what object id remote side advertise. Use org.eclipse.jgit.lib.ObjectId#zeroId() when expecting no remote ref with this name.

Exceptions
IOException:
when I/O error occurred during creating org.eclipse.jgit.transport.TrackingRefUpdate for local tracking branch or srcRef can't be resolved to any object.
IllegalArgumentException:
if some required parameter was null
RemoteRefUpdateback to summary
public RemoteRefUpdate(Repository localDb, String srcRef, ObjectId srcId, String remoteName, boolean forceUpdate, String localName, ObjectId expectedOldObjectId) throws IOException

Construct remote ref update request by providing an update specification. Object is created with default org.eclipse.jgit.transport.RemoteRefUpdate.Status#NOT_ATTEMPTED status and no message.

Parameters
localDb:Repository

local repository to push from.

srcRef:String

source revision to label srcId with. If null srcId.name() will be used instead.

srcId:ObjectId

The new object that the caller wants remote ref to be after update. Use null or org.eclipse.jgit.lib.ObjectId#zeroId() for delete request.

remoteName:String

full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).

forceUpdate:boolean

true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).

localName:String

optional full name of a local stored tracking branch, to update after push, e.g. "refs/remotes/zawir/dirty" (no wildcard, no short name); null if no local tracking branch should be updated.

expectedOldObjectId:ObjectId

optional object id that caller is expecting, requiring to be advertised by remote side before update; update will take place ONLY if remote side advertise exactly this expected id; null if caller doesn't care what object id remote side advertise. Use org.eclipse.jgit.lib.ObjectId#zeroId() when expecting no remote ref with this name.

Exceptions
IOException:
when I/O error occurred during creating org.eclipse.jgit.transport.TrackingRefUpdate for local tracking branch or srcRef can't be resolved to any object.
IllegalArgumentException:
if some required parameter was null
RemoteRefUpdateback to summary
private RemoteRefUpdate(Repository localDb, String srcRef, ObjectId srcId, String remoteName, boolean forceUpdate, String localName, Collection<RefSpec> fetchSpecs, ObjectId expectedOldObjectId) throws IOException
RemoteRefUpdateback to summary
public RemoteRefUpdate(RemoteRefUpdate base, ObjectId newExpectedOldObjectId) throws IOException

Create a new instance of this object basing on existing instance for configuration. State (like getMessage(), getStatus()) of base object is not shared. Expected old object id is set up from scratch, as this constructor may be used for 2-stage push: first one being dry run, second one being actual push.

Parameters
base:RemoteRefUpdate

configuration base.

newExpectedOldObjectId:ObjectId

new expected object id value.

Exceptions
IOException:
when I/O error occurred during creating org.eclipse.jgit.transport.TrackingRefUpdate for local tracking branch or srcRef of base object no longer can be resolved to any object.
RemoteRefUpdateback to summary
pack-priv RemoteRefUpdate(Repository localDb, boolean forceUpdate, Collection<RefSpec> fetchSpecs)

Creates a "placeholder" update for the "matching" RefSpec ":".

Parameters
localDb:Repository

local repository to push from

forceUpdate:boolean

whether non-fast-forward updates shall be allowed

fetchSpecs:Collection<RefSpec>

The fetch RefSpecs to use when this placeholder is expanded to determine remote tracking branch updates

Method Detail

getExpectedOldObjectIdback to summary
public ObjectId getExpectedOldObjectId()

Get expected old object id

Returns:ObjectId

expectedOldObjectId required to be advertised by remote side, as set in constructor; may be null.

getFetchSpecsback to summary
pack-priv Collection<RefSpec> getFetchSpecs()

Retrieves the fetch RefSpecs of this RemoteRefUpdate.

Returns:Collection<RefSpec>

the fetch RefSpecs, or null if this.isMatching() == false

getMessageback to summary
public String getMessage()

Get message describing reasons of status when needed/possible; may be null.

Returns:String

message describing reasons of status when needed/possible; may be null.

getNewObjectIdback to summary
public ObjectId getNewObjectId()

Get new object id

Returns:ObjectId

newObjectId for remote ref, as set in constructor.

getRemoteNameback to summary
public String getRemoteName()

Get name of remote ref to update

Returns:String

name of remote ref to update, as set in constructor.

getSrcRefback to summary
public String getSrcRef()

Get source revision as specified by user (in constructor)

Returns:String

source revision as specified by user (in constructor), could be any string parseable by org.eclipse.jgit.lib.Repository#resolve(String); can be null if specified that way in constructor - this stands for delete request.

getStatusback to summary
public RemoteRefUpdate.Status getStatus()

Get status of remote ref update operation.

Returns:RemoteRefUpdate.Status

status of remote ref update operation.

getTrackingRefUpdateback to summary
public TrackingRefUpdate getTrackingRefUpdate()

Get tracking branch update if localName was set in constructor.

Returns:TrackingRefUpdate

local tracking branch update if localName was set in constructor.

hasTrackingRefUpdateback to summary
public boolean hasTrackingRefUpdate()

Whether user specified a local tracking branch for remote update

Returns:boolean

true if user specified a local tracking branch for remote update; false otherwise.

isDeleteback to summary
public boolean isDelete()

Whether this update is a deleting update

Returns:boolean

true if this update is deleting update; false otherwise.

isExpectingOldObjectIdback to summary
public boolean isExpectingOldObjectId()

Whether some object is required to be advertised by remote side, as set in constructor

Returns:boolean

true if some object is required to be advertised by remote side, as set in constructor; false otherwise.

isFastForwardback to summary
public boolean isFastForward()

Check whether update was fast-forward. Note that this result is meaningful only after successful update (when status is org.eclipse.jgit.transport.RemoteRefUpdate.Status#OK).

Returns:boolean

true if update was fast-forward; false otherwise.

isForceUpdateback to summary
public boolean isForceUpdate()

Whether this update is forced regardless of old remote ref object

Returns:boolean

true if this update is forced regardless of old remote ref object; false otherwise.

isMatchingback to summary
public boolean isMatching()

Tells whether this RemoteRefUpdate is a placeholder for a "matching" RefSpec.

Returns:boolean

true if this is a placeholder, false otherwise

Since
6.1
setExpectedOldObjectIdback to summary
pack-priv void setExpectedOldObjectId(ObjectId id)
setFastForwardback to summary
pack-priv void setFastForward(boolean fastForward)
setMessageback to summary
pack-priv void setMessage(String message)
setStatusback to summary
pack-priv void setStatus(RemoteRefUpdate.Status status)
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
updateTrackingRefback to summary
protected void updateTrackingRef(RevWalk walk) throws IOException

Update locally stored tracking branch with the new object.

Parameters
walk:RevWalk

walker used for checking update properties.

Exceptions
IOException:
when I/O error occurred during update
org.eclipse.jgit.transport back to summary

public final Enum RemoteRefUpdate.Status

extends Enum<RemoteRefUpdate.Status>
Class Inheritance

Represent current status of a remote ref update.

Field Summary

Modifier and TypeField and Description
public static final RemoteRefUpdate.Status
AWAITING_REPORT

Push process is awaiting update report from remote repository.

public static final RemoteRefUpdate.Status
NON_EXISTING

Remote ref didn't exist.

public static final RemoteRefUpdate.Status
NOT_ATTEMPTED

Push process hasn't yet attempted to update this ref.

public static final RemoteRefUpdate.Status
OK

Remote ref was successfully updated.

public static final RemoteRefUpdate.Status
REJECTED_NODELETE

Remote ref update was rejected, because remote side doesn't support/allow deleting refs.

public static final RemoteRefUpdate.Status
REJECTED_NONFASTFORWARD

Remote ref update was rejected, as it would cause non fast-forward update.

public static final RemoteRefUpdate.Status
REJECTED_OTHER_REASON

Remote ref update was rejected for other reason, possibly described in RemoteRefUpdate#getMessage().

public static final RemoteRefUpdate.Status
REJECTED_REMOTE_CHANGED

Remote ref update was rejected, because old object id on remote repository wasn't the same as defined expected old object.

public static final RemoteRefUpdate.Status
UP_TO_DATE

Remote ref was up to date, there was no need to update anything.

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Field Detail

AWAITING_REPORTback to summary
public static final RemoteRefUpdate.Status AWAITING_REPORT

Push process is awaiting update report from remote repository. This is a temporary state or state after critical error in push process.

NON_EXISTINGback to summary
public static final RemoteRefUpdate.Status NON_EXISTING

Remote ref didn't exist. Can occur on delete request of a non existing ref.

NOT_ATTEMPTEDback to summary
public static final RemoteRefUpdate.Status NOT_ATTEMPTED

Push process hasn't yet attempted to update this ref. This is the default status, prior to push process execution.

OKback to summary
public static final RemoteRefUpdate.Status OK

Remote ref was successfully updated.

REJECTED_NODELETEback to summary
public static final RemoteRefUpdate.Status REJECTED_NODELETE

Remote ref update was rejected, because remote side doesn't support/allow deleting refs.

REJECTED_NONFASTFORWARDback to summary
public static final RemoteRefUpdate.Status REJECTED_NONFASTFORWARD

Remote ref update was rejected, as it would cause non fast-forward update.

REJECTED_OTHER_REASONback to summary
public static final RemoteRefUpdate.Status REJECTED_OTHER_REASON

Remote ref update was rejected for other reason, possibly described in RemoteRefUpdate#getMessage().

REJECTED_REMOTE_CHANGEDback to summary
public static final RemoteRefUpdate.Status REJECTED_REMOTE_CHANGED

Remote ref update was rejected, because old object id on remote repository wasn't the same as defined expected old object.

UP_TO_DATEback to summary
public static final RemoteRefUpdate.Status UP_TO_DATE

Remote ref was up to date, there was no need to update anything.

Constructor Detail

Statusback to summary
private Status()

Method Detail

valueOfback to summary
public static RemoteRefUpdate.Status valueOf(String name)
valuesback to summary
public static RemoteRefUpdate.Status[] values()