@@ -623,7 +623,7 @@ Repository.prototype.createCommitBuffer = function(
623623 * @param {Signature } committer
624624 * @param {String } message
625625 * @param {Tree|Oid|String } Tree
626- * @param {Array } parents
626+ * @param {Array of Commits } parents
627627 * @param {Function } onSignature Callback to be called with string to be signed
628628 * @return {Oid } The oid of the commit
629629 */
@@ -638,29 +638,24 @@ Repository.prototype.createCommitWithSignature = function(
638638) {
639639
640640 var repo = this ;
641- var promises = [ ] ;
642641 var commitContent ;
643642 var skippedSigning ;
644643
645- parents = parents || [ ] ;
646-
647- promises . push ( repo . getTree ( tree ) ) ;
648-
649- parents . forEach ( function ( parent ) {
650- promises . push ( repo . getCommit ( parent ) ) ;
651- } ) ;
644+ const directTreePromise = Promise . resolve ( tree ) ;
652645
653- const createCommitPromise = Promise . all ( promises ) . then ( function ( results ) {
654- tree = results [ 0 ] ;
646+ const getTreePromise = function ( ) {
647+ return repo . getTree ( tree ) ;
648+ } ;
655649
656- // Get the normalized values for our input into the function
657- var parentsLength = parents . length ;
658- parents = [ ] ;
650+ var treePromise ;
659651
660- for ( var i = 0 ; i < parentsLength ; i ++ ) {
661- parents . push ( results [ i + 1 ] ) ;
662- }
652+ if ( tree instanceof Tree ) {
653+ treePromise = directTreePromise ;
654+ } else {
655+ treePromise = getTreePromise ( ) ;
656+ }
663657
658+ const createCommitPromise = treePromise . then ( function ( tree ) {
664659 return Commit . createBuffer (
665660 repo ,
666661 author ,
0 commit comments