Class StashApplyCommand

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

public class StashApplyCommand extends GitCommand<ObjectId>
Command class to apply a stashed commit. This class behaves like git stash apply --index, i.e. it tries to recover the stashed index state in addition to the working tree state.
Since:
2.0
See Also:
  • Constructor Details

    • StashApplyCommand

      public StashApplyCommand(Repository repo)
      Create command to apply the changes of a stashed commit
      Parameters:
      repo - the Repository to apply the stash to
  • Method Details

    • setStashRef

      public StashApplyCommand setStashRef(String stashRef)
      Set the stash reference to apply

      This will default to apply the latest stashed commit (stash@{0}) if unspecified

      Parameters:
      stashRef - name of the stash Ref to apply
      Returns:
      this
    • ignoreRepositoryState

      public StashApplyCommand ignoreRepositoryState(boolean willIgnoreRepositoryState)
      Whether to ignore the repository state when applying the stash
      Parameters:
      willIgnoreRepositoryState - whether to ignore the repository state when applying the stash
      Returns:
      this
      Since:
      3.2
    • call

      Execute the command

      Apply the changes in a stashed commit to the working directory and index

      Specified by:
      call in interface Callable<ObjectId>
      Specified by:
      call in class GitCommand<ObjectId>
      Throws:
      GitAPIException
      WrongRepositoryStateException
      NoHeadException
      StashApplyFailureException
    • setApplyIndex

      @Deprecated public void setApplyIndex(boolean applyIndex)
      Deprecated.
      Whether to restore the index state
      Parameters:
      applyIndex - true (default) if the command should restore the index state
    • setRestoreIndex

      public StashApplyCommand setRestoreIndex(boolean restoreIndex)
      Whether to restore the index state
      Parameters:
      restoreIndex - true (default) if the command should restore the index state
      Returns:
      this
      Since:
      5.3
    • setStrategy

      public StashApplyCommand setStrategy(MergeStrategy strategy)
      Set the MergeStrategy to use.
      Parameters:
      strategy - The merge strategy to use in order to merge during this command execution.
      Returns:
      this
      Since:
      3.4
    • setContentMergeStrategy

      public StashApplyCommand setContentMergeStrategy(ContentMergeStrategy strategy)
      Sets the content merge strategy to use if the merge strategy is "resolve" or "recursive".
      Parameters:
      strategy - the ContentMergeStrategy to be used
      Returns:
      this
      Since:
      5.12
    • setApplyUntracked

      @Deprecated public void setApplyUntracked(boolean applyUntracked)
      Deprecated.
      Whether the command should restore untracked files
      Parameters:
      applyUntracked - true (default) if the command should restore untracked files
      Since:
      3.4
    • setRestoreUntracked

      public StashApplyCommand setRestoreUntracked(boolean restoreUntracked)
      Whether the command should restore untracked files
      Parameters:
      restoreUntracked - true (default) if the command should restore untracked files
      Returns:
      this
      Since:
      5.3