Package org.eclipse.jgit.api
Class ResetCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<Ref>
-
- org.eclipse.jgit.api.ResetCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<Ref>
public class ResetCommand extends GitCommand<Ref>
A class used to execute aReset
command. It has setters for all supported options and arguments of this command and acall()
method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call tocall()
)- See Also:
- Git documentation about Reset
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResetCommand.ResetType
Kind of reset
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<java.lang.String>
filepaths
private boolean
isReflogDisabled
private ResetCommand.ResetType
mode
private ProgressMonitor
monitor
private java.lang.String
ref
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description ResetCommand(Repository repo)
Constructor for ResetCommand.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResetCommand
addPath(java.lang.String path)
Repository relative path of file or directory to resetRef
call()
private void
checkoutIndex(ObjectId commitTree)
ResetCommand
disableRefLog(boolean disable)
Whether to disable reflogprivate java.lang.String
getRefOrHEAD()
boolean
isReflogDisabled()
Whether reflog is disabledprivate RevCommit
parseCommit(ObjectId commitId)
private void
resetCherryPick()
private void
resetIndex(ObjectId commitTree)
private void
resetIndexForPaths(ObjectId commitTree)
private void
resetMerge()
private void
resetRevert()
private ObjectId
resolveRefToCommitId()
ResetCommand
setMode(ResetCommand.ResetType mode)
Set the reset modeResetCommand
setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the reset operation.ResetCommand
setRef(java.lang.String ref)
Set the name of theRef
to reset tojava.lang.String
toString()
-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Field Detail
-
ref
private java.lang.String ref
-
mode
private ResetCommand.ResetType mode
-
filepaths
private java.util.Collection<java.lang.String> filepaths
-
isReflogDisabled
private boolean isReflogDisabled
-
monitor
private ProgressMonitor monitor
-
-
Constructor Detail
-
ResetCommand
public ResetCommand(Repository repo)
Constructor for ResetCommand.
- Parameters:
repo
- theRepository
-
-
Method Detail
-
call
public Ref call() throws GitAPIException, CheckoutConflictException
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.- Specified by:
call
in interfacejava.util.concurrent.Callable<Ref>
- Specified by:
call
in classGitCommand<Ref>
- Throws:
GitAPIException
CheckoutConflictException
-
resolveRefToCommitId
private ObjectId resolveRefToCommitId()
-
setRef
public ResetCommand setRef(java.lang.String ref)
Set the name of theRef
to reset to- Parameters:
ref
- the ref to reset to, defaults to HEAD if not specified- Returns:
- this instance
-
setMode
public ResetCommand setMode(ResetCommand.ResetType mode)
Set the reset mode- Parameters:
mode
- the mode of the reset command- Returns:
- this instance
-
addPath
public ResetCommand addPath(java.lang.String path)
Repository relative path of file or directory to reset- Parameters:
path
- repository-relative path of file/directory to reset (with/
as separator)- Returns:
- this instance
-
disableRefLog
public ResetCommand disableRefLog(boolean disable)
Whether to disable reflog- Parameters:
disable
- iftrue
disables writing a reflog entry for this reset command- Returns:
- this instance
- Since:
- 4.5
-
isReflogDisabled
public boolean isReflogDisabled()
Whether reflog is disabled- Returns:
true
if writing reflog is disabled for this reset command- Since:
- 4.5
-
getRefOrHEAD
private java.lang.String getRefOrHEAD()
-
setProgressMonitor
public ResetCommand setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the reset operation. By default, this is set toNullProgressMonitor
- Parameters:
monitor
- aProgressMonitor
- Returns:
this
- Since:
- 4.11
- See Also:
NullProgressMonitor
-
resetIndexForPaths
private void resetIndexForPaths(ObjectId commitTree)
-
resetIndex
private void resetIndex(ObjectId commitTree) throws java.io.IOException
- Throws:
java.io.IOException
-
checkoutIndex
private void checkoutIndex(ObjectId commitTree) throws java.io.IOException, GitAPIException
- Throws:
java.io.IOException
GitAPIException
-
resetMerge
private void resetMerge() throws java.io.IOException
- Throws:
java.io.IOException
-
resetCherryPick
private void resetCherryPick() throws java.io.IOException
- Throws:
java.io.IOException
-
resetRevert
private void resetRevert() throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-