File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -169,16 +169,21 @@ Commit.prototype.parents = function() {
169169Commit . prototype . getDiff = function ( callback ) {
170170 var commit = this ;
171171
172- return commit . getParents ( ) . then ( function ( parents ) {
173- var diffs = parents . map ( function ( parent ) {
174- return parent . getTree ( ) . then ( function ( parentTree ) {
175- return commit . getTree ( ) . then ( function ( thisTree ) {
176- return thisTree . diff ( parentTree ) ;
172+ return commit . getTree ( ) . then ( function ( thisTree ) {
173+ return commit . getParents ( ) . then ( function ( parents ) {
174+ var diffs ;
175+ if ( parents . length ) {
176+ diffs = parents . map ( function ( parent ) {
177+ return parent . getTree ( ) . then ( function ( parentTree ) {
178+ return thisTree . diff ( parentTree ) ;
179+ } ) ;
177180 } ) ;
178- } ) ;
179- } ) ;
181+ } else {
182+ diffs = [ thisTree . diff ( null ) ] ;
183+ }
180184
181- return Promise . all ( diffs ) ;
185+ return Promise . all ( diffs ) ;
186+ } ) ;
182187 } ) . then ( function ( diffs ) {
183188 if ( typeof callback === "function" ) {
184189 callback ( null , diffs ) ;
You can’t perform that action at this time.
0 commit comments