Tree.entryCmp Sync
var result = Tree.entryCmp(e1, e2);
| Returns | |
| — | — |
| Number |
<
0 if e1 is before e2, 0 if e1 == e2, >0 if e1 is after e2 |
Tree.lookup Async
Tree.lookup(repo, id, callback).then(function(tree) {
// Use tree
});
Retrieves the tree pointed to by the oid
Parameters |
Type |
|
repo |
Repository |
The repo that the tree lives in |
id |
String, Oid, Tree |
The tree to lookup |
callback |
Function |
|
Tree.lookupPrefix Async
Tree.lookupPrefix(repo, id, len).then(function(tree) {
// Use tree
});
Parameters |
Type |
|
repo |
Repository |
the repo to use when locating the tree. |
id |
Oid |
identity of the tree to locate. |
len |
Number |
the length of the short identifier |
Tree#_entryByIndex Sync
var treeEntry = tree._entryByIndex(idx);
Parameters |
Type |
|
idx |
Number |
the position in the entry list |
Returns |
|
TreeEntry |
the tree entry; NULL if not found |
Tree#_entryByName Sync
var treeEntry = tree._entryByName(filename);
Parameters |
Type |
|
filename |
String |
the filename of the desired entry |
Returns |
|
TreeEntry |
the tree entry; NULL if not found |
Tree#builder Sync
var treebuilder = tree.builder();
Make builder. This is helpful for modifying trees.
Tree#createUpdated Async
tree.createUpdated(repo, nupdates, updates).then(function(oid) {
// Use oid
});
Parameters |
Type |
|
repo |
Repository |
the repository in which to create the tree, must be the same as for baseline |
nupdates |
Number |
the number of elements in the update list |
updates |
Array |
the list of updates to perform |
Returns |
|
Oid |
id of the new tree |
Tree#diff Async
tree.diff(tree, callback).then(function(diffList) {
// Use diffList
});
Diff two trees
Parameters |
Type |
|
tree |
Tree |
to diff against |
callback |
Function |
|
Tree#diffWithOptions Async
tree.diffWithOptions(tree, options, callback).then(function(diffList) {
// Use diffList
});
Diff two trees with options
Parameters |
Type |
|
tree |
Tree |
to diff against |
options |
Object |
|
callback |
Function |
|
Tree#dup Async
tree.dup().then(function(tree) {
// Use tree
});
Tree#entries Sync
var arrayTreeEntry = tree.entries();
Return an array of the entries in this tree (excluding its children).
Returns |
|
Array<TreeEntry> |
an array of TreeEntrys |
Tree#entryById Sync
var treeEntry = tree.entryById(id);
Parameters |
Type |
|
id |
Oid |
the sha being looked for |
Returns |
|
TreeEntry |
the tree entry; NULL if not found |
Tree#entryByIndex Sync
var treeEntry = tree.entryByIndex(i);
Get an entry at the ith position.
Tree#entryByName Sync
var treeEntry = tree.entryByName(name);
Get an entry by name; if the tree is a directory, the name is the filename.
Parameters |
Type |
|
name |
String |
|
Tree#entryByPath Async
tree.entryByPath(path).then(function(treeEntry) {
// Use treeEntry
});
Parameters |
Type |
|
path |
String |
Path to the contained entry |
Tree#entryCount Sync
var result = tree.entryCount();
Returns |
|
Number |
the number of entries in the tree |
Tree#getEntry Async
tree.getEntry(filePath).then(function(treeEntry) {
// Use treeEntry
});
Get an entry at a path. Unlike by name, this takes a fully
qualified path, like /foo/bar/baz.javascript
Parameters |
Type |
|
filePath |
String |
|
Tree#id Sync
Returns |
|
Oid |
object identity for the tree. |
Tree#owner Sync
var repository = tree.owner();
Returns |
|
Repository |
Repository that contains this tree. |
Tree#path Sync
var string = tree.path();
Return the path of this tree, like /lib/foo/bar
Tree#walk Sync
var eventEmitter = tree.walk([blobsOnly);
eventEmitter.on('entry', function(tree) {
// Use tree
});
eventEmitter.on('end', function(trees) {
// Use trees
});
eventEmitter.on('error', function(error) {
// Use error
});
Recursively walk the tree in breadth-first order. Fires an event for each
entry.
Parameters |
Type |
|
[blobsOnly |
Boolean |
= true] True to emit only blob & blob executable entries. |
Tree.UPDATE ENUM
Flag |
Value |
Tree.UPDATE.UPSERT |
0 |
Tree.UPDATE.REMOVE |
1 |
Tree.WALK_MODE ENUM
Flag |
Value |
Tree.WALK_MODE.WALK_PRE |
0 |
Tree.WALK_MODE.WALK_POST |
1 |