Package org.eclipse.jgit.api
Class StashApplyCommand
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContentMergeStrategyprivate static final Stringprivate booleanprivate booleanprivate booleanprivate Stringprivate MergeStrategyFields inherited from class org.eclipse.jgit.api.GitCommand
repo -
Constructor Summary
ConstructorsConstructorDescriptionStashApplyCommand(Repository repo) Create command to apply the changes of a stashed commit -
Method Summary
Modifier and TypeMethodDescriptioncall()private voidcheckoutPath(DirCacheEntry entry, ObjectReader reader, DirCacheCheckout.CheckoutMetadata checkoutMetadata) private ObjectIdignoreRepositoryState(boolean willIgnoreRepositoryState) Whether to ignore the repository state when applying the stashprivate voidresetIndex(RevTree tree) private voidresetUntracked(RevTree tree) voidsetApplyIndex(boolean applyIndex) Deprecated.voidsetApplyUntracked(boolean applyUntracked) Deprecated.usesetRestoreUntracked(boolean)insteadsetContentMergeStrategy(ContentMergeStrategy strategy) Sets the content merge strategy to use if themerge strategyis "resolve" or "recursive".setRestoreIndex(boolean restoreIndex) Whether to restore the index statesetRestoreUntracked(boolean restoreUntracked) Whether the command should restore untracked filessetStashRef(String stashRef) Set the stash reference to applysetStrategy(MergeStrategy strategy) Set theMergeStrategyto use.Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
DEFAULT_REF
- See Also:
-
stashRef
-
restoreIndex
private boolean restoreIndex -
restoreUntracked
private boolean restoreUntracked -
ignoreRepositoryState
private boolean ignoreRepositoryState -
strategy
-
contentStrategy
-
-
Constructor Details
-
StashApplyCommand
Create command to apply the changes of a stashed commit- Parameters:
repo- theRepositoryto apply the stash to
-
-
Method Details
-
setStashRef
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
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
- Throws:
GitAPIException
-
call
public ObjectId call() throws GitAPIException, WrongRepositoryStateException, NoHeadException, StashApplyFailureExceptionExecute the command
Apply the changes in a stashed commit to the working directory and index
- Specified by:
callin interfaceCallable<ObjectId>- Specified by:
callin classGitCommand<ObjectId>- Throws:
GitAPIExceptionWrongRepositoryStateExceptionNoHeadExceptionStashApplyFailureException
-
setApplyIndex
Deprecated.usesetRestoreIndex(boolean)insteadWhether to restore the index state- Parameters:
applyIndex- true (default) if the command should restore the index state
-
setRestoreIndex
Whether to restore the index state- Parameters:
restoreIndex- true (default) if the command should restore the index state- Returns:
this- Since:
- 5.3
-
setStrategy
Set theMergeStrategyto use.- Parameters:
strategy- The merge strategy to use in order to merge during this command execution.- Returns:
this- Since:
- 3.4
-
setContentMergeStrategy
Sets the content merge strategy to use if themerge strategyis "resolve" or "recursive".- Parameters:
strategy- theContentMergeStrategyto be used- Returns:
this- Since:
- 5.12
-
setApplyUntracked
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
Whether the command should restore untracked files- Parameters:
restoreUntracked- true (default) if the command should restore untracked files- Returns:
this- Since:
- 5.3
-
resetIndex
- Throws:
IOException
-
resetUntracked
- Throws:
CheckoutConflictExceptionIOException
-
checkoutPath
private void checkoutPath(DirCacheEntry entry, ObjectReader reader, DirCacheCheckout.CheckoutMetadata checkoutMetadata)
-
setRestoreIndex(boolean)instead