Class ResetCommand

  • All Implemented Interfaces:
    java.util.concurrent.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:
    Git documentation about Reset
    • Field Detail

      • ref

        private java.lang.String ref
      • filepaths

        private java.util.Collection<java.lang.String> filepaths
      • isReflogDisabled

        private boolean isReflogDisabled
    • Constructor Detail

      • ResetCommand

        public ResetCommand​(Repository repo)

        Constructor for ResetCommand.

        Parameters:
        repo - the Repository
    • Method Detail

      • resolveRefToCommitId

        private ObjectId resolveRefToCommitId()
      • setRef

        public ResetCommand setRef​(java.lang.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
      • 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 - 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 java.lang.String getRefOrHEAD()
      • resetIndexForPaths

        private void resetIndexForPaths​(ObjectId commitTree)
      • resetIndex

        private void resetIndex​(ObjectId commitTree)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • 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 class java.lang.Object