org.eclipse.jgit.api

## 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:
  Git documentation about Stash

### Field Summary

### Fields inherited from class org.eclipse.jgit.api.GitCommand

`repo`

### Constructor Summary

Constructors
Constructor and Description
`StashApplyCommand(Repository repo)` Create command to apply the changes of a stashed commit

### Method Summary

Methods
`ObjectId` `call()` Apply the changes in a stashed commit to the working directory and index
`StashApplyCommand` `ignoreRepositoryState(boolean ignoreRepositoryState)`
`void` `setApplyIndex(boolean applyIndex)`
`StashApplyCommand` `setStashRef(String stashRef)` Set the stash reference to apply

### Methods inherited from class org.eclipse.jgit.api.GitCommand

`checkCallable, getRepository, setCallable`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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 apply

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

Parameters:
  `stashRef` -
Returns:
  `this`

#### ignoreRepositoryState

    public StashApplyCommand ignoreRepositoryState(boolean ignoreRepositoryState)

Parameters:
  `ignoreRepositoryState` -
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 interface `Callable<ObjectId>`
Specified by:
  `call` in class `GitCommand<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