nl_tokens: Github doesn t support deleting entries via the createTree API so we need to manually create those affected trees and modify the request .
pl_tokens: function slowUpdateTree ( entries , toDelete , callback ) { callback = singleCall ( callback ) ; var root = entries . base ; var left = 0 ; // Calculate trees that need to be re-built and save any provided content. var parents = { } ; toDelete . forEach ( function ( path ) { var parentPath = path . substr ( 0 , path . lastIndexOf ( "/" ) ) ; var parent = parents [ parentPath ] || ( parents [ parentPath ] = { add : { } , del : [ ] } ) ; var name = path . substr ( path . lastIndexOf ( "/" ) + 1 ) ; parent . del . push ( name ) ; } ) ; var other = entries . filter ( function ( entry ) { if ( ! entry . mode ) return false ; var parentPath = entry . path . substr ( 0 , entry . path . lastIndexOf ( "/" ) ) ; var parent = parents [ parentPath ] ; if ( ! parent ) return true ; var name = entry . path . substr ( entry . path . lastIndexOf ( "/" ) + 1 ) ; if ( entry . hash ) { parent . add [ name ] = { mode : entry . mode , hash : entry . hash } ; return false ; } left ++ ; repo . saveAs ( "blob" , <mask> . content , function ( err , hash ) { if ( err ) return callback ( err ) ; parent . add [ name ] = { mode : entry . mode , hash : hash } ; if ( ! -- left ) onParents ( ) ; } ) ; return false ; } ) ; if ( ! left ) onParents ( ) ; function onParents ( ) { Object . keys ( parents ) . forEach ( function ( parentPath ) { left ++ ; // TODO: remove this dependency on pathToEntry repo . pathToEntry ( root , parentPath , function ( err , entry ) { if ( err ) return callback ( err ) ; var tree = entry . tree ; var commands = parents [ parentPath ] ; commands . del . forEach ( function ( name ) { delete tree [ name ] ; } ) ; for ( var name in commands . add ) { tree [ name ] = commands . add [ name ] ; } repo . saveAs ( "tree" , tree , function ( err , hash , tree ) { if ( err ) return callback ( err ) ; other . push ( { path : parentPath , hash : hash , mode : modes . tree } ) ; if ( ! -- left ) { other . base = entries . base ; if ( other . length === 1 && other [ 0 ] . path === "" ) { return callback ( null , hash , tree ) ; } fastUpdateTree ( other , callback ) ; } } ) ; } ) ; } ) ; } }