layout
default
menu_item
api
title
Tree
description
Version 0.13.1
return_to
API Documentation Index
/api/
sections
entryCmp
entryDup
lookup
lookupPrefix
#_entryByIndex
#builder
#diff
#diffWithOptions
#entries
#entryById
#entryByIndex
#entryByName
#entryByPath
#entryCount
#free
#getEntry
#id
#owner
#path
#walk
WALK_MODE
#entryCmp
#entryDup
#lookup
#lookupPrefix
#_entryByIndex
#builder
#diff
#diffWithOptions
#entries
#entryById
#entryByIndex
#entryByName
#entryByPath
#entryCount
#free
#getEntry
#id
#owner
#path
#walk
#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
var result = Tree . entryDup ( dest , source ) ;
Parameters
Type
dest
TreeEntry
pointer where to store the copy
source
TreeEntry
tree entry to duplicate
Returns
Number
0 or an error code
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 treebuilder = tree . builder ( ) ;
Make builder. This is helpful for modifying trees.
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 | |
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
var treeEntry = tree . getEntry ( filePath ) ;
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.WALK_MODE. WALK_PRE | 0 |
| Tree.WALK_MODE. WALK_POST | 1 |