Class ResetCommand

java.lang.Object
org.eclipse.jgit.api.GitCommand<Ref>
org.eclipse.jgit.api.ResetCommand
All Implemented Interfaces:
Callable<Ref>

public class ResetCommand extends GitCommand<Ref>
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:
  • Field Details

  • Constructor Details

    • ResetCommand

      public ResetCommand(Repository repo)

      Constructor for ResetCommand.

      Parameters:
      repo - the Repository
  • Method Details

    • call

      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 interface Callable<Ref>
      Specified by:
      call in class GitCommand<Ref>
      Throws:
      GitAPIException
      CheckoutConflictException
    • parseCommit

      private RevCommit parseCommit(ObjectId commitId)
    • resolveRefToCommitId

      private ObjectId resolveRefToCommitId()
    • setRef

      public ResetCommand setRef(String ref)
      Set the name of the Ref 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(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 - if true 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 String getRefOrHEAD()
    • setProgressMonitor

      public ResetCommand setProgressMonitor(ProgressMonitor monitor)
      The progress monitor associated with the reset operation. By default, this is set to NullProgressMonitor
      Parameters:
      monitor - a ProgressMonitor
      Returns:
      this
      Since:
      4.11
      See Also:
    • resetIndexForPaths

      private void resetIndexForPaths(ObjectId commitTree)
    • resetIndex

      private void resetIndex(ObjectId commitTree) throws IOException
      Throws:
      IOException
    • checkoutIndex

      private void checkoutIndex(ObjectId commitTree) throws IOException, GitAPIException
      Throws:
      IOException
      GitAPIException
    • resetMerge

      private void resetMerge() throws IOException
      Throws:
      IOException
    • resetCherryPick

      private void resetCherryPick() throws IOException
      Throws:
      IOException
    • resetRevert

      private void resetRevert() throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object