org.eclipse.jgit.lib
Class Commit

java.lang.Object
  extended by org.eclipse.jgit.lib.Commit
All Implemented Interfaces:
Treeish

public class Commit
extends java.lang.Object
implements Treeish

Instances of this class represent a Commit object. It represents a snapshot in a Git repository, who created it and when.


Constructor Summary
Commit(Repository db)
          Create an empty commit object.
Commit(Repository db, ObjectId[] parentIds)
          Create a commit associated with these parents and associate it with a repository.
Commit(Repository db, ObjectId id, byte[] raw)
          Create a commit object with the specified id and data from and existing commit object in a repository.
 
Method Summary
 void commit()
          Persist this commit object
 PersonIdent getAuthor()
           
 ObjectId getCommitId()
           
 PersonIdent getCommitter()
           
 java.lang.String getEncoding()
           
 java.lang.String getMessage()
           
 ObjectId[] getParentIds()
           
 Repository getRepository()
           
 Tree getTree()
           
 ObjectId getTreeId()
           
 void setAuthor(PersonIdent a)
          Set the author and authoring time for this commit
 void setCommitId(ObjectId id)
          Set the id of this object.
 void setCommitter(PersonIdent c)
          Set the committer and commit time for this object
 void setEncoding(java.nio.charset.Charset e)
          State the encoding for the commit information
 void setEncoding(java.lang.String e)
          State the encoding for the commit information
 void setMessage(java.lang.String m)
          Set the commit message
 void setParentIds(ObjectId[] parentIds)
          Set the parents of this commit
 void setTree(Tree t)
          Set the tree object for this commit
 void setTreeId(ObjectId id)
          Set the tree id for this commit object
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Commit

public Commit(Repository db)
Create an empty commit object. More information must be fed to this object to make it useful.

Parameters:
db - The repository with which to associate it.

Commit

public Commit(Repository db,
              ObjectId[] parentIds)
Create a commit associated with these parents and associate it with a repository.

Parameters:
db - The repository to which this commit object belongs
parentIds - Id's of the parent(s)

Commit

public Commit(Repository db,
              ObjectId id,
              byte[] raw)
Create a commit object with the specified id and data from and existing commit object in a repository.

Parameters:
db - The repository to which this commit object belongs
id - Commit id
raw - Raw commit object data
Method Detail

getRepository

public Repository getRepository()
Returns:
get repository for the commit

getCommitId

public ObjectId getCommitId()
Returns:
The commit object id

setCommitId

public void setCommitId(ObjectId id)
Set the id of this object.

Parameters:
id - the id that we calculated for this object.

getTreeId

public ObjectId getTreeId()
Specified by:
getTreeId in interface Treeish
Returns:
the id of this tree

setTreeId

public void setTreeId(ObjectId id)
Set the tree id for this commit object

Parameters:
id -

getTree

public Tree getTree()
             throws java.io.IOException
Specified by:
getTree in interface Treeish
Returns:
the tree of this tree-ish object
Throws:
java.io.IOException

setTree

public void setTree(Tree t)
Set the tree object for this commit

Parameters:
t - the Tree object
See Also:
setTreeId(org.eclipse.jgit.lib.ObjectId)

getAuthor

public PersonIdent getAuthor()
Returns:
the author and authoring time for this commit

setAuthor

public void setAuthor(PersonIdent a)
Set the author and authoring time for this commit

Parameters:
a -

getCommitter

public PersonIdent getCommitter()
Returns:
the committer and commit time for this object

setCommitter

public void setCommitter(PersonIdent c)
Set the committer and commit time for this object

Parameters:
c - the committer information

getParentIds

public ObjectId[] getParentIds()
Returns:
the object ids of this commit

getMessage

public java.lang.String getMessage()
Returns:
the commit message

setParentIds

public void setParentIds(ObjectId[] parentIds)
Set the parents of this commit

Parameters:
parentIds -

setMessage

public void setMessage(java.lang.String m)
Set the commit message

Parameters:
m - the commit message

commit

public void commit()
            throws java.io.IOException
Persist this commit object

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setEncoding

public void setEncoding(java.lang.String e)
State the encoding for the commit information

Parameters:
e - the encoding. See Charset

setEncoding

public void setEncoding(java.nio.charset.Charset e)
State the encoding for the commit information

Parameters:
e - the encoding. See Charset

getEncoding

public java.lang.String getEncoding()
Returns:
the encoding used. See Charset