Package org.eclipse.jgit.api
Class StashApplyCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<ObjectId>
-
- org.eclipse.jgit.api.StashApplyCommand
-
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:
- Git documentation about Stash
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description StashApplyCommand(Repository repo)
Create command to apply the changes of a stashed commit
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectId
call()
Apply the changes in a stashed commit to the working directory and indexStashApplyCommand
ignoreRepositoryState(boolean willIgnoreRepositoryState)
void
setApplyIndex(boolean applyIndex)
void
setApplyUntracked(boolean applyUntracked)
StashApplyCommand
setStashRef(String stashRef)
Set the stash reference to applyStashApplyCommand
setStrategy(MergeStrategy strategy)
-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
StashApplyCommand
public StashApplyCommand(Repository repo)
Create command to apply the changes of a stashed commit- Parameters:
repo
-
-
-
Method Detail
-
setStashRef
public StashApplyCommand setStashRef(String stashRef)
Set the stash reference to applyThis will default to apply the latest stashed commit (stash@{0}) if unspecified
- Parameters:
stashRef
-- Returns:
this
-
ignoreRepositoryState
public StashApplyCommand ignoreRepositoryState(boolean willIgnoreRepositoryState)
- Parameters:
willIgnoreRepositoryState
-- Returns:
this
- Since:
- 3.2
-
call
public ObjectId call() throws GitAPIException, WrongRepositoryStateException, NoHeadException, StashApplyFailureException
Apply the changes in a stashed commit to the working directory and index- Specified by:
call
in interfaceCallable<ObjectId>
- Specified by:
call
in classGitCommand<ObjectId>
- Returns:
- id of stashed commit that was applied TODO: Does anyone depend on this, or could we make it more like Merge/CherryPick/Revert?
- Throws:
GitAPIException
WrongRepositoryStateException
NoHeadException
StashApplyFailureException
-
setApplyIndex
public void setApplyIndex(boolean applyIndex)
- Parameters:
applyIndex
- true (default) if the command should restore the index state
-
setStrategy
public StashApplyCommand setStrategy(MergeStrategy strategy)
- Parameters:
strategy
- The merge strategy to use in order to merge during this command execution.- Returns:
this
- Since:
- 3.4
-
setApplyUntracked
public void setApplyUntracked(boolean applyUntracked)
- Parameters:
applyUntracked
- true (default) if the command should restore untracked files- Since:
- 3.4
-
-