layout
default
menu_item
api
title
Tree
description
Version 0.10.0
return_to
API Documentation Index
/api/
sections
entryCmp
entryDup
entryFilemode
entryFilemodeRaw
entryId
entryName
entryToObject
entryType
lookup
lookupPrefix
#_entryByIndex
#builder
#diff
#diffWithOptions
#entries
#entryById
#entryByIndex
#entryByName
#entryByPath
#entryCount
#free
#getEntry
#id
#owner
#path
#walk
WALK_MODE
#entryCmp
#entryDup
#entryFilemode
#entryFilemodeRaw
#entryId
#entryName
#entryToObject
#entryType
#lookup
#lookupPrefix
#_entryByIndex
#builder
#diff
#diffWithOptions
#entries
#entryById
#entryByIndex
#entryByName
#entryByPath
#entryCount
#free
#getEntry
#id
#owner
#path
#walk
#WALK_MODE
Tree. entryCmp Sync Experimental
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. entryDup Sync Experimental
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. entryFilemode Sync Experimental
var result = Tree . entryFilemode ( entry ) ;
Returns
Number
filemode as an integer
Tree. entryFilemodeRaw Sync Experimental
var result = Tree . entryFilemodeRaw ( entry ) ;
Returns
Number
filemode as an integer
Tree. entryId Sync Experimental
var oid = Tree . entryId ( entry ) ;
Returns
Oid
the oid of the object
Tree. entryName Sync Experimental
var string = Tree . entryName ( entry ) ;
Returns
String
the name of the file
Tree. entryToObject Sync Experimental
var result = Tree . entryToObject ( object_out , repo , entry ) ;
Parameters
Type
object_out
Object
pointer to the converted object
repo
Repository
repository where to lookup the pointed object
entry
TreeEntry
a tree entry
Returns
Number
0 or an error code
Tree. entryType Sync Experimental
var result = Tree . entryType ( entry ) ;
Returns
Number
the type of the pointed object
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 Experimental
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 Experimental
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
Tree# entryById Sync Experimental
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 Async Experimental
tree . entryByPath ( path ) . then ( function ( treeEntry ) {
// Use treeEntry
} ) ;
| Parameters | Type |
| --- | --- | --- |
| path | String | Path to the contained entry |
Tree# entryCount Sync Experimental
var result = tree . entryCount ( ) ;
Returns
Number
the number of entries in the tree
Tree# free Sync Experimental
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.
Tree# owner Sync Experimental
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 |