Commit.create Async
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 . |
Commit.createBuffer Async
Commit.createBuffer(repo, author, committer, message_encoding, message, tree, parent_count, parents).then(function(buffer) {
// Use buffer
});
Parameters |
Type |
|
repo |
Repository |
Repository where the referenced tree and parents live |
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 . |
Returns |
|
Buffer |
the buffer into which to write the commit object content |
Commit.createV Sync
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. Leave NULL to create a commit without adding a signature field. |
signature_field |
String |
which header field should contain this signature. Leave NULL for the default of “gpgsig” |
Returns |
|
Oid |
the resulting commit id |
Commit.extractSignature(signature, signed_data, repo, commit_id, field).then(function(result) {
// Use result
});
Parameters |
Type |
|
signature |
Buf |
the signature block; existing content will be overwritten |
signed_data |
Buf |
signed data; this is the commit contents minus the signature block; existing content will be overwritten |
repo |
Repository |
the repository in which the commit exists |
commit_id |
Oid |
the commit from which to extract the data |
field |
String |
the name of the header field containing the signature block; pass NULL to extract the default ‘gpgsig’ |
Returns |
|
Number |
0 on success, GIT_ENOTFOUND if the id is not for a commit |
or the commit does not have a signature. |
|
Commit.lookup Async
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 Async
commit.amend(update_ref, author, committer, message_encoding, message, tree, callback).then(function() {
// method complete});
Amend a commit
Commit#amendWithSignature Async
commit.amendWithSignature(updateRef, author, committer, messageEncoding, message, tree, onSignature).then(function(oid) {
// Use oid
});
Amend a commit with the given signature
Parameters |
Type |
|
updateRef |
String |
|
author |
Signature |
|
committer |
Signature |
|
messageEncoding |
String |
|
message |
String |
|
tree |
Tree, Oid |
|
onSignature |
Function |
Callback to be called with string to be signed |
Commit#author Sync
var signature = commit.author();
Commit#authorWithMailmap Async
commit.authorWithMailmap(mailmap).then(function(signature) {
// Use signature
});
Parameters |
Type |
|
mailmap |
Mailmap |
the mailmap to resolve with. (may be NULL) |
Returns |
|
Signature |
store the resolved signature. |
Commit#body Sync
var string = commit.body();
Returns |
|
String |
the body of a commit or NULL when no the message only |
consists of a summary |
|
Commit#committer Sync
var signature = commit.committer();
Commit#committerWithMailmap Async
commit.committerWithMailmap(mailmap).then(function(signature) {
// Use signature
});
Parameters |
Type |
|
mailmap |
Mailmap |
the mailmap to resolve with. (may be NULL) |
Returns |
|
Signature |
store the resolved signature. |
Commit#date Sync
var date = commit.date();
Retrieve the commit time as a Date object.
Commit#dup Async
commit.dup().then(function(commit) {
// Use commit
});
Commit#getDiff Async
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 Async
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 Async
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#getSignature Sync
var extractedSignature = commit.getSignature(field);
Retrieve the signature and signed data for a commit.
Parameters |
Type |
|
field |
String |
Optional field to get from the signature, defaults to gpgsig |
Returns |
|
extractedSignature |
|
Commit#getTree Async
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; existing content will be |
overwritten |
|
Commit#history Sync
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.
Commit#id Sync
Returns |
|
Oid |
object identity for the commit. |
Commit#message Sync
var string = commit.message();
Returns |
|
String |
the message of a commit |
Commit#messageEncoding Sync
var string = commit.messageEncoding();
Returns |
|
String |
NULL, or the encoding |
Commit#messageRaw Sync
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 |
Commit#owner Sync
var repository = commit.owner();
Returns |
|
Repository |
Repository that contains this commit. |
Commit#parent Async
commit.parent(the).then(function(commit) {
// Use commit
});
Get the specified parent of the commit.
Parameters |
Type |
|
the |
number |
position of the parent, starting from 0 |
Returns |
|
Commit |
the parent commit at the specified position |
Commit#parentId Sync
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. |
Commit#parentcount Sync
var result = commit.parentcount();
Returns |
|
Number |
integer of count of parents |
Commit#parents Sync
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 |
Commit#sha Sync
var string = commit.sha();
Retrieve the SHA.
Commit#summary Sync
var string = commit.summary();
Returns |
|
String |
the summary of a commit or NULL on error |
Commit#time Sync
var result = commit.time();
Returns |
|
Number |
the time of a commit |
Commit#timeMs Sync
var number = commit.timeMs();
Retrieve the commit time as a unix timestamp.
Commit#timeOffset Sync
var result = commit.timeOffset();
Returns |
|
Number |
positive or negative timezone offset, in minutes from UTC |
Commit#toString Sync
var string = commit.toString();
The sha of this commit
Commit#tree Sync
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 |
Commit#treeId Sync
var oid = commit.treeId();
Returns |
|
Oid |
the id of tree pointed to by commit. |