| layout |
default |
| menu_item |
api |
| title |
Commit |
| description |
Version 0.19.0 |
| return_to |
| API Documentation Index |
/api/ |
|
| sections |
| create |
createV |
createWithSignature |
lookup |
lookupPrefix |
#amend |
#author |
#body |
#committer |
#date |
#dup |
#free |
#getDiff |
#getDiffWithOptions |
#getEntry |
#getParents |
#getTree |
#headerField |
#history |
#id |
#message |
#messageEncoding |
#messageRaw |
#nthGenAncestor |
#owner |
#parent |
#parentId |
#parentcount |
#parents |
#rawHeader |
#sha |
#summary |
#time |
#timeMs |
#timeOffset |
#toString |
#tree |
#treeId |
#create |
#createV |
#createWithSignature |
#lookup |
#lookupPrefix |
#amend |
#author |
#body |
#committer |
#date |
#dup |
#free |
#getDiff |
#getDiffWithOptions |
#getEntry |
#getParents |
#getTree |
#headerField |
#history |
#id |
#message |
#messageEncoding |
#messageRaw |
#nthGenAncestor |
#owner |
#parent |
#parentId |
#parentcount |
#parents |
#rawHeader |
#sha |
#summary |
#time |
#timeMs |
#timeOffset |
#toString |
#tree |
#treeId |
|
Commit.create(repo, update_ref, author, committer, message_encoding, message, tree, parent_count, parents).then(function(oid) {
// Use oid
});
| Parameters |
Type |
|
| repo |
Repository |
Repository where to store the commit |
| update_ref |
String |
If not NULL, name of the reference that will be updated to point to this commit. If the reference is not direct, it will be resolved to a direct reference. Use "HEAD" to update the HEAD of the current branch and make it point to this commit. If the reference doesn't exist yet, it will be created. If it does exist, the first parent must be the tip of this branch. |
| author |
Signature |
Signature with author and author time of commit |
| committer |
Signature |
Signature with committer and * commit time of commit |
| message_encoding |
String |
The encoding for the message in the commit, represented with a standard encoding name. E.g. "UTF-8". If NULL, no encoding header is written and UTF-8 is assumed. |
| message |
String |
Full message for this commit |
| tree |
Tree |
An instance of a git_tree object that will be used as the tree for the commit. This tree object must also be owned by the given repo. |
| parent_count |
Number |
Number of parents for this commit |
| parents |
Array |
Array of parent_count pointers to git_commit objects that will be used as the parents for this commit. This array may be NULL if parent_count is 0 (root commit). All the given commits must be owned by the repo. |
var result = Commit.createV(id, repo, update_ref, author, committer, message_encoding, message, tree, parent_count);
Commit.createWithSignature Async
Commit.createWithSignature(repo, commit_content, signature, signature_field).then(function(oid) {
// Use oid
});
| Parameters |
Type |
|
| repo |
Repository |
|
| commit_content |
String |
the content of the unsigned commit object |
| signature |
String |
the signature to add to the commit |
| signature_field |
String |
which header field should contain this signature. Leave NULL for the default of "gpgsig" |
| Returns |
|
| Oid |
the resulting commit id |
Commit.lookup(repo, id).then(function(commit) {
// Use commit
});
Retrieves the commit pointed to by the oid
| Parameters |
Type |
|
| repo |
Repository |
The repo that the commit lives in |
| id |
String, Oid, Commit |
The commit to lookup |
Commit.lookupPrefix Async
Commit.lookupPrefix(repo, id, len).then(function(commit) {
// Use commit
});
| Parameters |
Type |
|
| repo |
Repository |
the repo to use when locating the commit. |
| id |
Oid |
identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit. |
| len |
Number |
the length of the short identifier |
commit.amend(update_ref, author, committer, message_encoding, message, tree, callback).then(function() {
// method complete});
Amend a commit
| Parameters | Type |
| --- | --- | --- |
| update_ref | String | |
| author | Signature | |
| committer | Signature | |
| message_encoding | String | |
| message | String | |
| tree | Tree, Oid | |
| callback | Oid | |
var signature = commit.author();
var string = commit.body();
| Returns |
|
| String |
the body of a commit or NULL when no the message only |
| consists of a summary |
|
var signature = commit.committer();
var date = commit.date();
Retrieve the commit time as a Date object.
commit.dup().then(function(commit) {
// Use commit
});
commit.getDiff(callback).then(function(arrayDiff) {
// Use arrayDiff
});
Generate an array of diff trees showing changes between this commit
and its parent(s).
| Parameters | Type |
| --- | --- | --- |
| callback | Function | |
| Returns |
|
| Array<Diff> |
an array of diffs |
Commit#getDiffWithOptions Async
commit.getDiffWithOptions(options, callback).then(function(arrayDiff) {
// Use arrayDiff
});
Generate an array of diff trees showing changes between this commit
and its parent(s).
| Parameters | Type |
| --- | --- | --- |
| options | Object | |
| callback | Function | |
| Returns |
|
| Array<Diff> |
an array of diffs |
commit.getEntry(path).then(function(treeEntry) {
// Use treeEntry
});
Retrieve the entry represented by path for this commit.
Path must be relative to repository root.
| Parameters | Type |
| --- | --- | --- |
| path | String | |
commit.getParents(limit, callback).then(function(arrayCommit) {
// Use arrayCommit
});
Retrieve the commit's parents as commit objects.
| Parameters | Type |
| --- | --- | --- |
| limit | number | Optional amount of parents to return. |
| callback | Function | |
| Returns |
|
| Array<Commit> |
array of commits |
commit.getTree().then(function(tree) {
// Use tree
});
Get the tree associated with this commit.
commit.headerField(field).then(function(buf) {
// Use buf
});
| Parameters | Type |
| --- | --- | --- |
| field | String | the header field to return |
| Returns |
|
| Buf |
the buffer to fill |
var eventEmitter = commit.history();
eventEmitter.on('commit', function(commit) {
// Use commit
});
eventEmitter.on('end', function(commits) {
// Use commits
});
eventEmitter.on('error', function(error) {
// Use error
});
eventEmitter.start()
Walk the history from this commit backwards.
An EventEmitter is returned that will emit a "commit" event for each
commit in the history, and one "end" event when the walk is completed.
Don't forget to call start() on the returned event.
| Returns |
|
| Oid |
object identity for the commit. |
var string = commit.message();
| Returns |
|
| String |
the message of a commit |
Commit#messageEncoding Sync
var string = commit.messageEncoding();
| Returns |
|
| String |
NULL, or the encoding |
var string = commit.messageRaw();
| Returns |
|
| String |
the raw message of a commit |
Commit#nthGenAncestor Async
commit.nthGenAncestor(n).then(function(commit) {
// Use commit
});
| Parameters | Type |
| --- | --- | --- |
| n | Number | the requested generation |
| Returns |
|
| Commit |
the ancestor commit |
var repository = commit.owner();
| Returns |
|
| Repository |
Repository that contains this commit. |
commit.parent(n).then(function(commit) {
// Use commit
});
| Parameters | Type |
| --- | --- | --- |
| n | Number | the position of the parent (from 0 to parentcount) |
| Returns |
|
| Commit |
the parent commit |
var oid = commit.parentId(n);
| Parameters | Type |
| --- | --- | --- |
| n | Number | the position of the parent (from 0 to parentcount) |
| Returns |
|
| Oid |
the id of the parent, NULL on error. |
var result = commit.parentcount();
| Returns |
|
| Number |
integer of count of parents |
var arrayOid = commit.parents();
Retrieve the commit's parent shas.
| Returns |
|
| Array<Oid> |
array of oids |
var string = commit.rawHeader();
| Returns |
|
| String |
the header text of the commit |
var string = commit.sha();
Retrieve the SHA.
var string = commit.summary();
| Returns |
|
| String |
the summary of a commit or NULL on error |
var result = commit.time();
| Returns |
|
| Number |
the time of a commit |
var number = commit.timeMs();
Retrieve the commit time as a unix timestamp.
var result = commit.timeOffset();
| Returns |
|
| Number |
positive or negative timezone offset, in minutes from UTC |
var string = commit.toString();
The sha of this commit
var result = commit.tree(tree_out);
| Parameters | Type |
| --- | --- | --- |
| tree_out | Tree | pointer where to store the tree object |
| Returns |
|
| Number |
0 or an error code |
var oid = commit.treeId();
| Returns |
|
| Oid |
the id of tree pointed to by commit. |