Package org.eclipse.jgit.transport
Class RemoteRefUpdate
- java.lang.Object
-
- org.eclipse.jgit.transport.RemoteRefUpdate
-
public class RemoteRefUpdate extends java.lang.Object
Represent request and status of a remote ref update. Specification is provided by client, while status is handled byPushProcess
class, being read-only for client.Client can create instances of this class directly, basing on user specification and advertised refs (
Connection
or throughTransport
helper methods. Apply this specification on remote repository usingTransport.push(org.eclipse.jgit.lib.ProgressMonitor, java.util.Collection)
method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RemoteRefUpdate.Status
Represent current status of a remote ref update.
-
Field Summary
Fields Modifier and Type Field Description private ObjectId
expectedOldObjectId
private boolean
fastForward
private boolean
forceUpdate
private Repository
localDb
private RefUpdate
localUpdate
private java.lang.String
message
private ObjectId
newObjectId
private java.lang.String
remoteName
private java.lang.String
srcRef
private RemoteRefUpdate.Status
status
private TrackingRefUpdate
trackingRefUpdate
-
Constructor Summary
Constructors Constructor Description RemoteRefUpdate(Repository localDb, java.lang.String srcRef, java.lang.String remoteName, boolean forceUpdate, java.lang.String localName, ObjectId expectedOldObjectId)
Construct remote ref update request by providing an update specification.RemoteRefUpdate(Repository localDb, java.lang.String srcRef, ObjectId srcId, java.lang.String remoteName, boolean forceUpdate, java.lang.String localName, ObjectId expectedOldObjectId)
Construct remote ref update request by providing an update specification.RemoteRefUpdate(Repository localDb, Ref srcRef, java.lang.String remoteName, boolean forceUpdate, java.lang.String localName, ObjectId expectedOldObjectId)
Construct remote ref update request by providing an update specification.RemoteRefUpdate(RemoteRefUpdate base, ObjectId newExpectedOldObjectId)
Create a new instance of this object basing on existing instance for configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectId
getExpectedOldObjectId()
Get expected old object idjava.lang.String
getMessage()
Get message describing reasons of status when needed/possible; may be null.ObjectId
getNewObjectId()
Get new object idjava.lang.String
getRemoteName()
Get name of remote ref to updatejava.lang.String
getSrcRef()
Get source revision as specified by user (in constructor)RemoteRefUpdate.Status
getStatus()
Get status of remote ref update operation.TrackingRefUpdate
getTrackingRefUpdate()
Get tracking branch update if localName was set in constructor.boolean
hasTrackingRefUpdate()
Whether user specified a local tracking branch for remote updateboolean
isDelete()
Whether this update is a deleting updateboolean
isExpectingOldObjectId()
Whether some object is required to be advertised by remote side, as set in constructorboolean
isFastForward()
Check whether update was fast-forward.boolean
isForceUpdate()
Whether this update is forced regardless of old remote ref object(package private) void
setExpectedOldObjectId(ObjectId id)
(package private) void
setFastForward(boolean fastForward)
(package private) void
setMessage(java.lang.String message)
(package private) void
setStatus(RemoteRefUpdate.Status status)
java.lang.String
toString()
protected void
updateTrackingRef(RevWalk walk)
Update locally stored tracking branch with the new object.
-
-
-
Field Detail
-
expectedOldObjectId
private ObjectId expectedOldObjectId
-
newObjectId
private final ObjectId newObjectId
-
remoteName
private final java.lang.String remoteName
-
trackingRefUpdate
private final TrackingRefUpdate trackingRefUpdate
-
srcRef
private final java.lang.String srcRef
-
forceUpdate
private final boolean forceUpdate
-
status
private RemoteRefUpdate.Status status
-
fastForward
private boolean fastForward
-
message
private java.lang.String message
-
localDb
private final Repository localDb
-
localUpdate
private RefUpdate localUpdate
-
-
Constructor Detail
-
RemoteRefUpdate
public RemoteRefUpdate(Repository localDb, java.lang.String srcRef, java.lang.String remoteName, boolean forceUpdate, java.lang.String localName, ObjectId expectedOldObjectId) throws java.io.IOException
Construct remote ref update request by providing an update specification. Object is created with defaultRemoteRefUpdate.Status.NOT_ATTEMPTED
status and no message.- Parameters:
localDb
- local repository to push from.srcRef
- source revision - any string resolvable byRepository.resolve(String)
. This resolves to the new object that the caller want remote ref to be after update. Use null orObjectId.zeroId()
string for delete request.remoteName
- full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).forceUpdate
- true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).localName
- 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
- 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. UseObjectId.zeroId()
when expecting no remote ref with this name.- Throws:
java.io.IOException
- when I/O error occurred during creatingTrackingRefUpdate
for local tracking branch or srcRef can't be resolved to any object.java.lang.IllegalArgumentException
- if some required parameter was null
-
RemoteRefUpdate
public RemoteRefUpdate(Repository localDb, Ref srcRef, java.lang.String remoteName, boolean forceUpdate, java.lang.String localName, ObjectId expectedOldObjectId) throws java.io.IOException
Construct remote ref update request by providing an update specification. Object is created with defaultRemoteRefUpdate.Status.NOT_ATTEMPTED
status and no message.- Parameters:
localDb
- local repository to push from.srcRef
- source revision. Use null to delete.remoteName
- full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).forceUpdate
- true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).localName
- 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
- 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. UseObjectId.zeroId()
when expecting no remote ref with this name.- Throws:
java.io.IOException
- when I/O error occurred during creatingTrackingRefUpdate
for local tracking branch or srcRef can't be resolved to any object.java.lang.IllegalArgumentException
- if some required parameter was null
-
RemoteRefUpdate
public RemoteRefUpdate(Repository localDb, java.lang.String srcRef, ObjectId srcId, java.lang.String remoteName, boolean forceUpdate, java.lang.String localName, ObjectId expectedOldObjectId) throws java.io.IOException
Construct remote ref update request by providing an update specification. Object is created with defaultRemoteRefUpdate.Status.NOT_ATTEMPTED
status and no message.- Parameters:
localDb
- local repository to push from.srcRef
- source revision to label srcId with. If null srcId.name() will be used instead.srcId
- The new object that the caller wants remote ref to be after update. Use null orObjectId.zeroId()
for delete request.remoteName
- full name of a remote ref to update, e.g. "refs/heads/master" (no wildcard, no short name).forceUpdate
- true when caller want remote ref to be updated regardless whether it is fast-forward update (old object is ancestor of new object).localName
- 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
- 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. UseObjectId.zeroId()
when expecting no remote ref with this name.- Throws:
java.io.IOException
- when I/O error occurred during creatingTrackingRefUpdate
for local tracking branch or srcRef can't be resolved to any object.java.lang.IllegalArgumentException
- if some required parameter was null
-
RemoteRefUpdate
public RemoteRefUpdate(RemoteRefUpdate base, ObjectId newExpectedOldObjectId) throws java.io.IOException
Create a new instance of this object basing on existing instance for configuration. State (likegetMessage()
,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
- configuration base.newExpectedOldObjectId
- new expected object id value.- Throws:
java.io.IOException
- when I/O error occurred during creatingTrackingRefUpdate
for local tracking branch or srcRef of base object no longer can be resolved to any object.
-
-
Method Detail
-
getExpectedOldObjectId
public ObjectId getExpectedOldObjectId()
Get expected old object id- Returns:
- expectedOldObjectId required to be advertised by remote side, as set in constructor; may be null.
-
isExpectingOldObjectId
public boolean isExpectingOldObjectId()
Whether some object is required to be advertised by remote side, as set in constructor- Returns:
- true if some object is required to be advertised by remote side, as set in constructor; false otherwise.
-
getNewObjectId
public ObjectId getNewObjectId()
Get new object id- Returns:
- newObjectId for remote ref, as set in constructor.
-
isDelete
public boolean isDelete()
Whether this update is a deleting update- Returns:
- true if this update is deleting update; false otherwise.
-
getRemoteName
public java.lang.String getRemoteName()
Get name of remote ref to update- Returns:
- name of remote ref to update, as set in constructor.
-
getTrackingRefUpdate
public TrackingRefUpdate getTrackingRefUpdate()
Get tracking branch update if localName was set in constructor.- Returns:
- local tracking branch update if localName was set in constructor.
-
getSrcRef
public java.lang.String getSrcRef()
Get source revision as specified by user (in constructor)- Returns:
- source revision as specified by user (in constructor), could be
any string parseable by
Repository.resolve(String)
; can be null if specified that way in constructor - this stands for delete request.
-
hasTrackingRefUpdate
public boolean hasTrackingRefUpdate()
Whether user specified a local tracking branch for remote update- Returns:
- true if user specified a local tracking branch for remote update; false otherwise.
-
isForceUpdate
public boolean isForceUpdate()
Whether this update is forced regardless of old remote ref object- Returns:
- true if this update is forced regardless of old remote ref object; false otherwise.
-
getStatus
public RemoteRefUpdate.Status getStatus()
Get status of remote ref update operation.- Returns:
- status of remote ref update operation.
-
isFastForward
public boolean isFastForward()
Check whether update was fast-forward. Note that this result is meaningful only after successful update (when status isRemoteRefUpdate.Status.OK
).- Returns:
- true if update was fast-forward; false otherwise.
-
getMessage
public java.lang.String getMessage()
Get message describing reasons of status when needed/possible; may be null.- Returns:
- message describing reasons of status when needed/possible; may be null.
-
setExpectedOldObjectId
void setExpectedOldObjectId(ObjectId id)
-
setStatus
void setStatus(RemoteRefUpdate.Status status)
-
setFastForward
void setFastForward(boolean fastForward)
-
setMessage
void setMessage(java.lang.String message)
-
updateTrackingRef
protected void updateTrackingRef(RevWalk walk) throws java.io.IOException
Update locally stored tracking branch with the new object.- Parameters:
walk
- walker used for checking update properties.- Throws:
java.io.IOException
- when I/O error occurred during update
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-