Package org.eclipse.jgit.api
Class StashCreateCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<RevCommit>
-
- org.eclipse.jgit.api.StashCreateCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<RevCommit>
public class StashCreateCommand extends GitCommand<RevCommit>
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
Fields Modifier and Type Field Description private booleanincludeUntrackedprivate java.lang.StringindexMessageprivate static java.lang.StringMSG_INDEXprivate static java.lang.StringMSG_UNTRACKEDprivate static java.lang.StringMSG_WORKING_DIRprivate PersonIdentpersonprivate java.lang.Stringrefprivate java.lang.StringworkingDirectoryMessage-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description StashCreateCommand(Repository repo)Create a command to stash changes in the working directory and index
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RevCommitcall()private CommitBuildercreateBuilder()private RefgetHead()private RevCommitparseCommit(ObjectReader reader, ObjectId headId)StashCreateCommandsetIncludeUntracked(boolean includeUntracked)Whether to include untracked files in the stash.StashCreateCommandsetIndexMessage(java.lang.String message)Set the message used when committing index changesStashCreateCommandsetPerson(PersonIdent person)Set the person to use as the author and committer in the commits madeStashCreateCommandsetRef(java.lang.String ref)Set the reference to update with the stashed commit id If null, no reference is updatedStashCreateCommandsetWorkingDirectoryMessage(java.lang.String message)Set the message used when committing working directory changesprivate voidupdateStashRef(ObjectId commitId, PersonIdent refLogIdent, java.lang.String refLogMessage)-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Field Detail
-
MSG_INDEX
private static final java.lang.String MSG_INDEX
- See Also:
- Constant Field Values
-
MSG_UNTRACKED
private static final java.lang.String MSG_UNTRACKED
- See Also:
- Constant Field Values
-
MSG_WORKING_DIR
private static final java.lang.String MSG_WORKING_DIR
- See Also:
- Constant Field Values
-
indexMessage
private java.lang.String indexMessage
-
workingDirectoryMessage
private java.lang.String workingDirectoryMessage
-
ref
private java.lang.String ref
-
person
private PersonIdent person
-
includeUntracked
private boolean includeUntracked
-
-
Constructor Detail
-
StashCreateCommand
public StashCreateCommand(Repository repo)
Create a command to stash changes in the working directory and index- Parameters:
repo- aRepositoryobject.
-
-
Method Detail
-
setIndexMessage
public StashCreateCommand setIndexMessage(java.lang.String message)
Set the message used when committing index changesThe message will be formatted with the current branch, abbreviated commit id, and short commit message when used.
- Parameters:
message- the stash message- Returns:
this
-
setWorkingDirectoryMessage
public StashCreateCommand setWorkingDirectoryMessage(java.lang.String message)
Set the message used when committing working directory changesThe message will be formatted with the current branch, abbreviated commit id, and short commit message when used.
- Parameters:
message- the working directory message- Returns:
this
-
setPerson
public StashCreateCommand setPerson(PersonIdent person)
Set the person to use as the author and committer in the commits made- Parameters:
person- thePersonIdentof the person who creates the stash.- Returns:
this
-
setRef
public StashCreateCommand setRef(java.lang.String ref)
Set the reference to update with the stashed commit id If null, no reference is updatedThis value defaults to
Constants.R_STASH- Parameters:
ref- the name of theRefto update- Returns:
this
-
setIncludeUntracked
public StashCreateCommand setIncludeUntracked(boolean includeUntracked)
Whether to include untracked files in the stash.- Parameters:
includeUntracked- whether to include untracked files in the stash- Returns:
this- Since:
- 3.4
-
parseCommit
private RevCommit parseCommit(ObjectReader reader, ObjectId headId) throws java.io.IOException
- Throws:
java.io.IOException
-
createBuilder
private CommitBuilder createBuilder()
-
updateStashRef
private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, java.lang.String refLogMessage) throws java.io.IOException
- Throws:
java.io.IOException
-
getHead
private Ref getHead() throws GitAPIException
- Throws:
GitAPIException
-
call
public RevCommit call() throws GitAPIException
Execute the command
Stash the contents on the working directory and index in separate commits and reset to the current HEAD commit.
- Specified by:
callin interfacejava.util.concurrent.Callable<RevCommit>- Specified by:
callin classGitCommand<RevCommit>- Throws:
GitAPIException
-
-