public class CommitBuilder extends ObjectBuilder
CommitCommand.
To read a commit object, construct a RevWalk
and obtain a RevCommit instance by calling
RevWalk.parseCommit(AnyObjectId).| Constructor and Description |
|---|
CommitBuilder()
Initialize an empty commit.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addParentId(AnyObjectId additionalParent)
Add a parent onto the end of the parent list.
|
byte[] |
build()
Format this builder's state as a git object.
|
PersonIdent |
getAuthor()
Get the author of this commit (who wrote it).
|
PersonIdent |
getCommitter()
Get the committer and commit time for this object.
|
ObjectId[] |
getParentIds()
Get the ancestors of this commit.
|
ObjectId |
getTreeId()
Get id of the root tree listing this commit's snapshot.
|
void |
setAuthor(PersonIdent newAuthor)
Set the author (name, email address, and date) of who wrote the commit.
|
void |
setCommitter(PersonIdent newCommitter)
Set the committer and commit time for this object.
|
void |
setEncoding(String encodingName)
Deprecated.
use
ObjectBuilder.setEncoding(Charset) instead. |
void |
setParentId(AnyObjectId newParent)
Set the parent of this commit.
|
void |
setParentIds(AnyObjectId parent1,
AnyObjectId parent2)
Set the parents of this commit.
|
void |
setParentIds(List<? extends AnyObjectId> newParents)
Set the parents of this commit.
|
void |
setParentIds(ObjectId... newParents)
Set the parents of this commit.
|
void |
setTreeId(AnyObjectId id)
Set the tree id for this commit object.
|
byte[] |
toByteArray()
Format this builder's state as a commit object.
|
String |
toString() |
getEncoding, getGpgSignature, getMessage, setEncoding, setGpgSignature, setMessagepublic ObjectId getTreeId()
public void setTreeId(AnyObjectId id)
id - the tree identity.public PersonIdent getAuthor()
getAuthor in class ObjectBuilderpublic void setAuthor(PersonIdent newAuthor)
setAuthor in class ObjectBuildernewAuthor - the new author. Should not be null.public PersonIdent getCommitter()
public void setCommitter(PersonIdent newCommitter)
newCommitter - the committer information. Should not be null.public ObjectId[] getParentIds()
public void setParentId(AnyObjectId newParent)
newParent - the single parent for the commit.public void setParentIds(AnyObjectId parent1, AnyObjectId parent2)
parent1 - the first parent of this commit. Typically this is the current
value of the HEAD reference and is thus the current
branch's position in history.parent2 - the second parent of this merge commit. Usually this is the
branch being merged into the current branch.public void setParentIds(ObjectId... newParents)
newParents - the entire list of parents for this commit.public void setParentIds(List<? extends AnyObjectId> newParents)
newParents - the entire list of parents for this commit.public void addParentId(AnyObjectId additionalParent)
additionalParent - new parent to add onto the end of the current parent list.@Deprecated public void setEncoding(String encodingName)
ObjectBuilder.setEncoding(Charset) instead.encodingName - the encoding name. See
Charset.forName(String).public byte[] build()
throws UnsupportedEncodingException
ObjectBuilderbuild in class ObjectBuilderUnsupportedEncodingException - the encoding specified by ObjectBuilder.getEncoding() is not
supported by this Java runtime.public byte[] toByteArray()
throws UnsupportedEncodingException
UnsupportedEncodingException - the encoding specified by ObjectBuilder.getEncoding() is not
supported by this Java runtime.Copyright © 2021 Eclipse JGit Project. All rights reserved.