Top Description Fields Constructors Methods
org.eclipse.jgit.api

public Class StashApplyCommand

extends GitCommand<ObjectId>
Class Inheritance
Static Imports
org.eclipse.jgit.treewalk.TreeWalk.OperationType.CHECKOUT_OP

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

Modifier and TypeField and Description
private ContentMergeStrategy
private static final String
private boolean
private boolean
private boolean
private String
private MergeStrategy
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
public
StashApplyCommand(Repository
the org.eclipse.jgit.lib.Repository to apply the stash to
repo
)

Create command to apply the changes of a stashed commit

Method Summary

Modifier and TypeMethod and Description
public ObjectId
call()

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

private void
checkoutPath(DirCacheEntry entry, String gitPath, ObjectReader reader, Checkout checkout, DirCacheCheckout.CheckoutMetadata checkoutMetadata)

private ObjectId
public StashApplyCommand

Returns:

this
ignoreRepositoryState
(boolean
whether to ignore the repository state when applying the stash
willIgnoreRepositoryState
)

Whether to ignore the repository state when applying the stash

private void
private void
public StashApplyCommand

Returns:

this
setContentMergeStrategy
(ContentMergeStrategy
the ContentMergeStrategy to be used
strategy
)

Sets the content merge strategy to use if the merge strategy is "resolve" or "recursive".

public StashApplyCommand

Returns:

this
setRestoreIndex
(boolean
true (default) if the command should restore the index state
restoreIndex
)

Whether to restore the index state

public StashApplyCommand

Returns:

this
setRestoreUntracked
(boolean
true (default) if the command should restore untracked files
restoreUntracked
)

Whether the command should restore untracked files

public StashApplyCommand

Returns:

this
setStashRef
(String
name of the stash Ref to apply
stashRef
)

Set the stash reference to apply

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

public StashApplyCommand

Returns:

this
setStrategy
(MergeStrategy
The merge strategy to use in order to merge during this command execution.
strategy
)

Set the MergeStrategy to use.

Inherited from org.eclipse.jgit.api.GitCommand:
checkCallablegetRepositorysetCallable

Field Detail

contentStrategyback to summary
private ContentMergeStrategy contentStrategy
DEFAULT_REFback to summary
private static final String DEFAULT_REF
ignoreRepositoryStateback to summary
private boolean ignoreRepositoryState
restoreIndexback to summary
private boolean restoreIndex
restoreUntrackedback to summary
private boolean restoreUntracked
stashRefback to summary
private String stashRef
strategyback to summary
private MergeStrategy strategy

Constructor Detail

StashApplyCommandback to summary
public StashApplyCommand(Repository repo)

Create command to apply the changes of a stashed commit

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository to apply the stash to

Method Detail

callback to summary
public ObjectId call() throws GitAPIException, WrongRepositoryStateException, NoHeadException, StashApplyFailureException

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Doc from org.eclipse.jgit.api.GitCommand.call.

Computes a result, or throws an exception if unable to do so.

Execute the command

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

Returns:ObjectId

Doc from java.util.concurrent.Callable.call.

computed result

Annotations
@Override
checkoutPathback to summary
private void checkoutPath(DirCacheEntry entry, String gitPath, ObjectReader reader, Checkout checkout, DirCacheCheckout.CheckoutMetadata checkoutMetadata)
getStashIdback to summary
private ObjectId getStashId() throws GitAPIException
ignoreRepositoryStateback to summary
public StashApplyCommand ignoreRepositoryState(boolean willIgnoreRepositoryState)

Whether to ignore the repository state when applying the stash

Parameters
willIgnoreRepositoryState:boolean

whether to ignore the repository state when applying the stash

Returns:StashApplyCommand

this

Since
3.2
resetIndexback to summary
private void resetIndex(RevTree tree) throws IOException
resetUntrackedback to summary
private void resetUntracked(RevTree tree) throws CheckoutConflictException, IOException
setContentMergeStrategyback to summary
public StashApplyCommand setContentMergeStrategy(ContentMergeStrategy strategy)

Sets the content merge strategy to use if the merge strategy is "resolve" or "recursive".

Parameters
strategy:ContentMergeStrategy

the ContentMergeStrategy to be used

Returns:StashApplyCommand

this

Since
5.12
setRestoreIndexback to summary
public StashApplyCommand setRestoreIndex(boolean restoreIndex)

Whether to restore the index state

Parameters
restoreIndex:boolean

true (default) if the command should restore the index state

Returns:StashApplyCommand

this

Since
5.3
setRestoreUntrackedback to summary
public StashApplyCommand setRestoreUntracked(boolean restoreUntracked)

Whether the command should restore untracked files

Parameters
restoreUntracked:boolean

true (default) if the command should restore untracked files

Returns:StashApplyCommand

this

Since
5.3
setStashRefback to summary
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:String

name of the stash Ref to apply

Returns:StashApplyCommand

this

setStrategyback to summary
public StashApplyCommand setStrategy(MergeStrategy strategy)

Set the MergeStrategy to use.

Parameters
strategy:MergeStrategy

The merge strategy to use in order to merge during this command execution.

Returns:StashApplyCommand

this

Since
3.4