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

public Class ResetCommand

extends GitCommand<Ref>
Class Inheritance
Imports
java.io.IOException, java.text.MessageFormat, java.util.ArrayList, .Collection, org.eclipse.jgit.api.errors.CheckoutConflictException, .GitAPIException, .JGitInternalException, org.eclipse.jgit.dircache.DirCache, .DirCacheBuildIterator, .DirCacheBuilder, .DirCacheCheckout, .DirCacheEntry, .DirCacheIterator, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Constants, .NullProgressMonitor, .ObjectId, .ProgressMonitor, .Ref, .RefUpdate, .Repository, .RepositoryState, org.eclipse.jgit.revwalk.RevCommit, .RevWalk, org.eclipse.jgit.treewalk.AbstractTreeIterator, .CanonicalTreeParser, .EmptyTreeIterator, .TreeWalk, org.eclipse.jgit.treewalk.filter.PathFilterGroup

A class used to execute a Reset command. It has setters for all supported options and arguments of this command and a call() method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call to call())
See Also
Git documentation about Reset

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private Collection<String>
private boolean
private ResetCommand.ResetType
private ProgressMonitor
private String
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
public
ResetCommand(Repository repo)

Constructor for ResetCommand.

Method Summary

Modifier and TypeMethod and Description
public ResetCommand

Returns:

this instance
addPath
(String
repository-relative path of file/directory to reset (with / as separator)
path
)

Repository relative path of file or directory to reset

public Ref
call()

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

private void
checkoutIndex(ObjectId commitTree)

public ResetCommand

Returns:

this instance
disableRefLog
(boolean
if true disables writing a reflog entry for this reset command
disable
)

Whether to disable reflog

private String
public boolean

Returns:

true if writing reflog is disabled for this reset command
isReflogDisabled
()

Whether reflog is disabled

private RevCommit
private void
private void
resetIndex(ObjectId commitTree)

private void
private void
private void
private ObjectId
public ResetCommand

Returns:

this instance
setMode
(ResetCommand.ResetType
the mode of the reset command
mode
)

Set the reset mode

public ResetCommand

Returns:

this
setProgressMonitor
(ProgressMonitor monitor)

The progress monitor associated with the reset operation.

public ResetCommand

Returns:

this instance
setRef
(String
the ref to reset to, defaults to HEAD if not specified
ref
)

Set the name of the Ref to reset to

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jgit.api.GitCommand:
checkCallablegetRepositorysetCallable

Field Detail

filepathsback to summary
private Collection<String> filepaths
isReflogDisabledback to summary
private boolean isReflogDisabled
modeback to summary
private ResetCommand.ResetType mode
monitorback to summary
private ProgressMonitor monitor
refback to summary
private String ref

Constructor Detail

ResetCommandback to summary
public ResetCommand(Repository repo)

Constructor for ResetCommand.

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

addPathback to summary
public ResetCommand addPath(String path)

Repository relative path of file or directory to reset

Parameters
path:String

repository-relative path of file/directory to reset (with / as separator)

Returns:ResetCommand

this instance

callback to summary
public Ref call() throws GitAPIException, CheckoutConflictException

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Doc from org.eclipse.jgit.api.GitCommand.call.

Computes a result, or throws an exception if unable to do so.

Execute the command

Executes the Reset command. Each instance of this class should only be used for one invocation of the command. Don't call this method twice on an instance.

Returns:Ref

Doc from java.util.concurrent.Callable.call.

computed result

Annotations
@Override
checkoutIndexback to summary
private void checkoutIndex(ObjectId commitTree) throws IOException, GitAPIException
disableRefLogback to summary
public ResetCommand disableRefLog(boolean disable)

Whether to disable reflog

Parameters
disable:boolean

if true disables writing a reflog entry for this reset command

Returns:ResetCommand

this instance

Since
4.5
getRefOrHEADback to summary
private String getRefOrHEAD()
isReflogDisabledback to summary
public boolean isReflogDisabled()

Whether reflog is disabled

Returns:boolean

true if writing reflog is disabled for this reset command

Since
4.5
parseCommitback to summary
private RevCommit parseCommit(ObjectId commitId)
resetCherryPickback to summary
private void resetCherryPick() throws IOException
resetIndexback to summary
private void resetIndex(ObjectId commitTree) throws IOException
resetIndexForPathsback to summary
private void resetIndexForPaths(ObjectId commitTree)
resetMergeback to summary
private void resetMerge() throws IOException
resetRevertback to summary
private void resetRevert() throws IOException
resolveRefToCommitIdback to summary
private ObjectId resolveRefToCommitId()
setModeback to summary
public ResetCommand setMode(ResetCommand.ResetType mode)

Set the reset mode

Parameters
mode:ResetCommand.ResetType

the mode of the reset command

Returns:ResetCommand

this instance

setProgressMonitorback to summary
public ResetCommand setProgressMonitor(ProgressMonitor monitor)

The progress monitor associated with the reset operation. By default, this is set to NullProgressMonitor

Parameters
monitor:ProgressMonitor

a org.eclipse.jgit.lib.ProgressMonitor

Returns:ResetCommand

this

Since
4.11
See Also
NullProgressMonitor
setRefback to summary
public ResetCommand setRef(String ref)

Set the name of the Ref to reset to

Parameters
ref:String

the ref to reset to, defaults to HEAD if not specified

Returns:ResetCommand

this instance

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

public final Enum ResetCommand.ResetType

extends Enum<ResetCommand.ResetType>
Class Inheritance

Kind of reset

Field Summary

Modifier and TypeField and Description
public static final ResetCommand.ResetType
HARD

Change the ref, the index and the workdir

public static final ResetCommand.ResetType
KEEP

Change the ref, the index and the workdir that are different between respective commit and HEAD

public static final ResetCommand.ResetType
MERGE

Resets the index and updates the files in the working tree that are different between respective commit and HEAD, but keeps those which are different between the index and working tree

public static final ResetCommand.ResetType
MIXED

Change the ref and the index, the workdir is not changed.

public static final ResetCommand.ResetType
SOFT

Just change the ref, the index and workdir are not changed.

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Field Detail

HARDback to summary
public static final ResetCommand.ResetType HARD

Change the ref, the index and the workdir

KEEPback to summary
public static final ResetCommand.ResetType KEEP

Change the ref, the index and the workdir that are different between respective commit and HEAD

MERGEback to summary
public static final ResetCommand.ResetType MERGE

Resets the index and updates the files in the working tree that are different between respective commit and HEAD, but keeps those which are different between the index and working tree

MIXEDback to summary
public static final ResetCommand.ResetType MIXED

Change the ref and the index, the workdir is not changed.

SOFTback to summary
public static final ResetCommand.ResetType SOFT

Just change the ref, the index and workdir are not changed.

Constructor Detail

ResetTypeback to summary
private ResetType()

Method Detail

valueOfback to summary
public static ResetCommand.ResetType valueOf(String name)
valuesback to summary
public static ResetCommand.ResetType[] values()