layout
default
menu_item
api
title
Tree
description
Version 0.26.1
return_to
API Documentation Index
/api/
sections
entryCmp
lookup
lookupPrefix
#_entryByIndex
#_entryByName
#builder
#createUpdated
#diff
#diffWithOptions
#dup
#entries
#entryById
#entryByIndex
#entryByName
#entryByPath
#entryCount
#getEntry
#id
#owner
#path
#walk
UPDATE
WALK_MODE
#entryCmp
#lookup
#lookupPrefix
#_entryByIndex
#_entryByName
#builder
#createUpdated
#diff
#diffWithOptions
#dup
#entries
#entryById
#entryByIndex
#entryByName
#entryByPath
#entryCount
#getEntry
#id
#owner
#path
#walk
#UPDATE
#WALK_MODE
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 ( 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 ( 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
var treeEntry = tree . _entryByIndex ( idx ) ;
| Parameters | Type |
| --- | --- | --- |
| idx | Number | the position in the entry list |
Returns
TreeEntry
the tree entry; NULL if not found
var treeEntry = tree . _entryByName ( filename ) ;
| Parameters | Type |
| --- | --- | --- |
| filename | String | the filename of the desired entry |
Returns
TreeEntry
the tree entry; NULL if not found
var treebuilder = tree . builder ( ) ;
Make builder. This is helpful for modifying trees.
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 ( 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 ( ) . then ( function ( tree ) {
// Use tree
} ) ;
var arrayTreeEntry = tree . entries ( ) ;
Return an array of the entries in this tree (excluding its children).
Returns
Array<TreeEntry >
an array of TreeEntrys
var treeEntry = tree . entryById ( id ) ;
| Parameters | Type |
| --- | --- | --- |
| id | Oid | the sha being looked for |
Returns
TreeEntry
the tree entry; NULL if not found
var treeEntry = tree . entryByIndex ( i ) ;
Get an entry at the ith position.
| Parameters | Type |
| --- | --- | --- |
| i | Number | |
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 ( path ) . then ( function ( treeEntry ) {
// Use treeEntry
} ) ;
| Parameters | Type |
| --- | --- | --- |
| path | String | Path to the contained entry |
var result = tree . entryCount ( ) ;
Returns
Number
the number of entries in the tree
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 | |
Returns
Oid
object identity for the tree.
var repository = tree . owner ( ) ;
Returns
Repository
Repository that contains this tree.
var string = tree . path ( ) ;
Return the path of this tree, like /lib/foo/bar
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. |
| Flag | Value |
| --- | --- | --- |
| Tree.UPDATE. UPSERT | 0 |
| Tree.UPDATE. REMOVE | 1 |
| Flag | Value |
| --- | --- | --- |
| Tree.WALK_MODE. WALK_PRE | 0 |
| Tree.WALK_MODE. WALK_POST | 1 |