Package org.eclipse.jgit.api
Class StashApplyCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<ObjectId>
-
- org.eclipse.jgit.api.StashApplyCommand
-
- All Implemented Interfaces:
java.util.concurrent.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:
- Git documentation about Stash
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_REFprivate booleanignoreRepositoryStateprivate booleanrestoreIndexprivate booleanrestoreUntrackedprivate java.lang.StringstashRefprivate MergeStrategystrategy-
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 Deprecated Methods Modifier and Type Method Description ObjectIdcall()private voidcheckoutPath(DirCacheEntry entry, java.lang.String gitPath, ObjectReader reader, Checkout checkout, DirCacheCheckout.CheckoutMetadata checkoutMetadata)private ObjectIdgetStashId()StashApplyCommandignoreRepositoryState(boolean willIgnoreRepositoryState)Whether to ignore the repository state when applying the stashprivate voidresetIndex(RevTree tree)private voidresetUntracked(RevTree tree)voidsetApplyIndex(boolean applyIndex)Deprecated.usesetRestoreIndex(boolean)insteadvoidsetApplyUntracked(boolean applyUntracked)Deprecated.usesetRestoreUntracked(boolean)insteadStashApplyCommandsetRestoreIndex(boolean restoreIndex)Whether to restore the index stateStashApplyCommandsetRestoreUntracked(boolean restoreUntracked)Whether the command should restore untracked filesStashApplyCommandsetStashRef(java.lang.String stashRef)Set the stash reference to applyStashApplyCommandsetStrategy(MergeStrategy strategy)Set theMergeStrategyto use.-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Field Detail
-
DEFAULT_REF
private static final java.lang.String DEFAULT_REF
- See Also:
- Constant Field Values
-
stashRef
private java.lang.String stashRef
-
restoreIndex
private boolean restoreIndex
-
restoreUntracked
private boolean restoreUntracked
-
ignoreRepositoryState
private boolean ignoreRepositoryState
-
strategy
private MergeStrategy strategy
-
-
Constructor Detail
-
StashApplyCommand
public StashApplyCommand(Repository repo)
Create command to apply the changes of a stashed commit- Parameters:
repo- theRepositoryto apply the stash to
-
-
Method Detail
-
setStashRef
public StashApplyCommand setStashRef(java.lang.String stashRef)
Set the stash reference to applyThis will default to apply the latest stashed commit (stash@{0}) if unspecified
- Parameters:
stashRef- name of the stashRefto 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
-
getStashId
private ObjectId getStashId() throws GitAPIException
- Throws:
GitAPIException
-
call
public ObjectId call() throws GitAPIException, WrongRepositoryStateException, NoHeadException, StashApplyFailureException
Execute the command
Apply the changes in a stashed commit to the working directory and index
- Specified by:
callin interfacejava.util.concurrent.Callable<ObjectId>- Specified by:
callin classGitCommand<ObjectId>- Throws:
GitAPIExceptionWrongRepositoryStateExceptionNoHeadExceptionStashApplyFailureException
-
setApplyIndex
@Deprecated public void setApplyIndex(boolean applyIndex)
Deprecated.usesetRestoreIndex(boolean)insteadWhether 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 theMergeStrategyto use.- Parameters:
strategy- The merge strategy to use in order to merge during this command execution.- Returns:
this- Since:
- 3.4
-
setApplyUntracked
@Deprecated public void setApplyUntracked(boolean applyUntracked)
Deprecated.usesetRestoreUntracked(boolean)insteadWhether 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
-
resetIndex
private void resetIndex(RevTree tree) throws java.io.IOException
- Throws:
java.io.IOException
-
resetUntracked
private void resetUntracked(RevTree tree) throws CheckoutConflictException, java.io.IOException
- Throws:
CheckoutConflictExceptionjava.io.IOException
-
checkoutPath
private void checkoutPath(DirCacheEntry entry, java.lang.String gitPath, ObjectReader reader, Checkout checkout, DirCacheCheckout.CheckoutMetadata checkoutMetadata)
-
-