@@ -54,37 +54,20 @@ Commit.prototype.lookup = function(oid, callback) {
5454 *
5555 * @param {Commit~oidCallback } callback
5656 */
57- Commit . prototype . oid = function ( callback ) {
57+ Commit . prototype . oid = function ( ) {
5858 /**
5959 * @callback Commit~oidCallback Callback executed on OID retrieval.
6060 * @param {GitError|null } error An Error or null if successful.
6161 * @param {Oid|null } commit Retrieved OID object or null.
6262 */
63- callback ( null , new git . oid ( this . rawCommit . oid ( ) ) ) ;
63+ return new git . oid ( this . rawCommit . oid ( ) ) ;
6464} ;
6565
6666/**
6767 * Retrieve the SHA.
68- *
69- * @param {Commit~shaCallback } callback
7068 */
71- Commit . prototype . sha = function ( callback ) {
72- /**
73- * @callback Commit~shaCallback Callback executed on SHA retrieval.
74- * @param {GitError|null } error An Error or null if successful.
75- * @param {String|null } sha Retrieved SHA.
76- */
77- this . oid ( function ( error , oid ) {
78- if ( ! success ( error , callback ) ) {
79- return ;
80- }
81- oid . sha ( function ( error , sha ) {
82- if ( ! success ( error , callback ) ) {
83- return ;
84- }
85- callback ( null , sha ) ;
86- } ) ;
87- } ) ;
69+ Commit . prototype . sha = function ( ) {
70+ return this . oid ( ) . sha ( ) ;
8871} ;
8972
9073/**
@@ -254,41 +237,39 @@ Commit.prototype.history = function() {
254237 var event = new events . EventEmitter ( ) ,
255238 self = this ;
256239
257- self . oid ( function commitOid ( error , oid ) {
258- ( new git . revwalk ( self . rawRepo ) ) . allocate ( function createRevwalk ( error , revwalk ) {
259- var commits = [ ] ;
260- revwalk . walk ( oid , function commitRevWalk ( error , index , commit , noMoreCommits ) {
261- if ( error ) {
262- event . emit ( 'end' , error , commits ) ;
263- return false ;
264- }
240+ var oid = self . oid ( ) ;
241+ ( new git . revwalk ( self . rawRepo ) ) . allocate ( function createRevwalk ( error , revwalk ) {
242+ var commits = [ ] ;
243+ revwalk . walk ( oid , function commitRevWalk ( error , index , commit , noMoreCommits ) {
244+ if ( error ) {
245+ event . emit ( 'end' , error , commits ) ;
246+ return false ;
247+ }
265248
266- if ( noMoreCommits ) {
267- /**
268- * End event.
269- *
270- * @event Commit#end
271- *
272- * @param {GitError|null } error An error object if there was an issue, null otherwise.
273- * @param {Commit[] } commits The commits.
274- */
275- event . emit ( 'end' , null , commits ) ;
276- return ;
277- }
249+ if ( noMoreCommits ) {
278250 /**
279- * Commit event.
251+ * End event.
280252 *
281- * @event Commit#commit
253+ * @event Commit#end
282254 *
283255 * @param {GitError|null } error An error object if there was an issue, null otherwise.
284- * @param {Commit } commit The commit .
256+ * @param {Commit[] } commits The commits .
285257 */
286- event . emit ( 'commit' , null , commit ) ;
287- commits . push ( commit ) ;
288- } ) ;
258+ event . emit ( 'end' , null , commits ) ;
259+ return ;
260+ }
261+ /**
262+ * Commit event.
263+ *
264+ * @event Commit#commit
265+ *
266+ * @param {GitError|null } error An error object if there was an issue, null otherwise.
267+ * @param {Commit } commit The commit.
268+ */
269+ event . emit ( 'commit' , null , commit ) ;
270+ commits . push ( commit ) ;
289271 } ) ;
290272 } ) ;
291-
292273 return event ;
293274} ;
294275
@@ -328,27 +309,22 @@ Commit.prototype.parentsDiffTrees = function(callback) {
328309 * @param {DiffList[]|null } diffLists Array of DiffTrees showing changes between this commit and its parent(s)
329310 */
330311 var self = this ;
331- self . sha ( function ( error , commitSha ) {
312+ var commitSha = self . sha ( ) ;
313+ self . parents ( function commitParents ( error , parents ) {
332314 if ( ! success ( error , callback ) ) {
333315 return ;
334316 }
335- self . parents ( function commitParents ( error , parents ) {
336- if ( ! success ( error , callback ) ) {
337- return ;
338- }
339- var parentDiffLists = [ ] ;
340- parents . forEach ( function commitEachParent ( parent ) {
341- parent . sha ( function commitParentSha ( error , parentSha ) {
342- ( new git . diffList ( self . rawRepo ) ) . treeToTree ( parentSha , commitSha , function walkDiffList ( error , diffList ) {
343- if ( ! success ( error , callback ) ) {
344- return ;
345- }
346- parentDiffLists . push ( diffList ) ;
347- if ( parentDiffLists . length === parents . length ) {
348- callback ( null , parentDiffLists ) ;
349- }
350- } ) ;
351- } ) ;
317+ var parentDiffLists = [ ] ;
318+ parents . forEach ( function commitEachParent ( parent ) {
319+ var parentSha = parent . sha ( ) ;
320+ ( new git . diffList ( self . rawRepo ) ) . treeToTree ( parentSha , commitSha , function walkDiffList ( error , diffList ) {
321+ if ( ! success ( error , callback ) ) {
322+ return ;
323+ }
324+ parentDiffLists . push ( diffList ) ;
325+ if ( parentDiffLists . length === parents . length ) {
326+ callback ( null , parentDiffLists ) ;
327+ }
352328 } ) ;
353329 } ) ;
354330 } ) ;
0 commit comments