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

public Class StashCreateCommand

extends GitCommand<RevCommit>
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH

Command class to stash changes in the working directory and index in a commit.
Since
2.0
See Also
Git documentation about Stash

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
StashCreateCommand(Repository repo)

Create a command to stash changes in the working directory and index

Method Summary

Modifier and TypeMethod and Description
public RevCommit
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 CommitBuilder
private Ref
private RevCommit
parseCommit(final ObjectReader reader, final ObjectId headId)

public StashCreateCommand

Returns:

this
setIncludeUntracked
(boolean
whether to include untracked files in the stash
includeUntracked
)

Whether to include untracked files in the stash.

public StashCreateCommand

Returns:

this
setIndexMessage
(String
the stash message
message
)

Set the message used when committing index changes

The message will be formatted with the current branch, abbreviated commit id, and short commit message when used.

public StashCreateCommand

Returns:

this
setPerson
(PersonIdent
the org.eclipse.jgit.lib.PersonIdent of the person who creates the stash.
person
)

Set the person to use as the author and committer in the commits made

public StashCreateCommand

Returns:

this
setRef
(String
the name of the Ref to update
ref
)

Set the reference to update with the stashed commit id If null, no reference is updated

This value defaults to org.eclipse.jgit.lib.Constants#R_STASH

public StashCreateCommand

Returns:

this
setWorkingDirectoryMessage
(String
the working directory message
message
)

Set the message used when committing working directory changes

The message will be formatted with the current branch, abbreviated commit id, and short commit message when used.

private void
updateStashRef(ObjectId commitId, PersonIdent refLogIdent, String refLogMessage)

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

Field Detail

includeUntrackedback to summary
private boolean includeUntracked
indexMessageback to summary
private String indexMessage
MSG_INDEXback to summary
private static final String MSG_INDEX
MSG_UNTRACKEDback to summary
private static final String MSG_UNTRACKED
MSG_WORKING_DIRback to summary
private static final String MSG_WORKING_DIR
personback to summary
private PersonIdent person
refback to summary
private String ref
workingDirectoryMessageback to summary
private String workingDirectoryMessage

Constructor Detail

StashCreateCommandback to summary
public StashCreateCommand(Repository repo)

Create a command to stash changes in the working directory and index

Parameters
repo:Repository

a org.eclipse.jgit.lib.Repository object.

Method Detail

callback to summary
public RevCommit call() throws GitAPIException

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

Stash the contents on the working directory and index in separate commits and reset to the current HEAD commit.

Returns:RevCommit

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

computed result

Annotations
@Override
createBuilderback to summary
private CommitBuilder createBuilder()
getHeadback to summary
private Ref getHead() throws GitAPIException
parseCommitback to summary
private RevCommit parseCommit(final ObjectReader reader, final ObjectId headId) throws IOException
setIncludeUntrackedback to summary
public StashCreateCommand setIncludeUntracked(boolean includeUntracked)

Whether to include untracked files in the stash.

Parameters
includeUntracked:boolean

whether to include untracked files in the stash

Returns:StashCreateCommand

this

Since
3.4
setIndexMessageback to summary
public StashCreateCommand setIndexMessage(String message)

Set the message used when committing index changes

The message will be formatted with the current branch, abbreviated commit id, and short commit message when used.

Parameters
message:String

the stash message

Returns:StashCreateCommand

this

setPersonback to summary
public StashCreateCommand setPerson(PersonIdent person)

Set the person to use as the author and committer in the commits made

Parameters
person:PersonIdent

the org.eclipse.jgit.lib.PersonIdent of the person who creates the stash.

Returns:StashCreateCommand

this

setRefback to summary
public StashCreateCommand setRef(String ref)

Set the reference to update with the stashed commit id If null, no reference is updated

This value defaults to org.eclipse.jgit.lib.Constants#R_STASH

Parameters
ref:String

the name of the Ref to update

Returns:StashCreateCommand

this

setWorkingDirectoryMessageback to summary
public StashCreateCommand setWorkingDirectoryMessage(String message)

Set the message used when committing working directory changes

The message will be formatted with the current branch, abbreviated commit id, and short commit message when used.

Parameters
message:String

the working directory message

Returns:StashCreateCommand

this

updateStashRefback to summary
private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, String refLogMessage) throws IOException