@@ -21,13 +21,13 @@ Repository.prototype.getBranch = function(name, callback) {
2121
2222 return this . getReference ( "refs/heads/" + name ) . then ( function ( reference ) {
2323 return repository . getCommit ( reference . target ( ) ) . then ( function ( commit ) {
24- if ( callback ) {
24+ if ( typeof callback === "function" ) {
2525 callback ( null , commit ) ;
2626 }
2727
2828 return commit ;
2929 } ) ;
30- } ) ;
30+ } , callback ) ;
3131} ;
3232
3333/**
@@ -43,15 +43,12 @@ Repository.prototype.getReference = function(name, callback) {
4343 return Reference . lookup ( this , name ) . then ( function ( reference ) {
4444 if ( reference . type ( ) == Reference . Type . Symbolic ) {
4545 return reference . resolve ( function ( error , reference ) {
46- if ( error ) {
47- return callback ( error ) ;
48- }
49-
5046 reference . repo = repository ;
5147
5248 if ( callback ) {
5349 callback ( null , reference ) ;
5450 }
51+
5552 return reference ;
5653 } ) ;
5754 } else {
@@ -61,7 +58,7 @@ Repository.prototype.getReference = function(name, callback) {
6158 }
6259 return reference ;
6360 }
64- } ) ;
61+ } , callback ) ;
6562} ;
6663
6764/**
@@ -79,12 +76,12 @@ Repository.prototype.getCommit = function(oid, callback) {
7976 return Commit . lookup ( repository , oid ) . then ( function ( commit ) {
8077 commit . repo = repository ;
8178
82- if ( callback ) {
79+ if ( typeof callback === "function" ) {
8380 callback ( null , commit ) ;
8481 }
8582
8683 return commit ;
87- } ) ;
84+ } , callback ) ;
8885} ;
8986
9087/**
@@ -102,7 +99,7 @@ Repository.prototype.getBlob = function(oid, callback) {
10299 return Blob . lookup ( repository , oid ) . then ( function ( blob ) {
103100 blob . repo = repository ;
104101
105- if ( callback ) {
102+ if ( typeof callback === "function" ) {
106103 callback ( null , blob ) ;
107104 }
108105
@@ -125,7 +122,7 @@ Repository.prototype.getTree = function(oid, callback) {
125122 return Tree . lookup ( repository , oid ) . then ( function ( tree ) {
126123 tree . repo = repository ;
127124
128- if ( callback ) {
125+ if ( typeof callback === "function" ) {
129126 callback ( null , tree ) ;
130127 }
131128
@@ -148,7 +145,7 @@ Repository.prototype.getTag = function(oid, callback) {
148145 return Reference . lookup ( repository , oid ) . then ( function ( reference ) {
149146 reference . repo = repository ;
150147
151- if ( callback ) {
148+ if ( typeof callback === "function" ) {
152149 callback ( null , reference ) ;
153150 }
154151
@@ -177,48 +174,62 @@ Repository.prototype.createRevWalk = function() {
177174 * @return {Branch }
178175 */
179176Repository . prototype . getMaster = function ( callback ) {
180- this . getBranch ( "master" , callback ) ;
177+ return this . getBranch ( "master" , callback ) ;
181178} ;
182179
183180/**
184181 * Create a commit
185182 *
186183 * @param {String } updateRef
187184 * @param {Signature } author
188- * @param {Signature } commiter
185+ * @param {Signature } committer
189186 * @param {String } message
190187 * @param {Tree|Oid|String } Tree
191188 * @param {Array } parents
192189 * @param {Function } callback
193190 * @return {Oid } The oid of the commit
194191 */
195192Repository . prototype . createCommit = function (
196- // FIXME
197193 updateRef , author , committer , message , tree , parents , callback ) {
194+
195+ var createCommit = null ;
196+ var commit = this ;
197+
198198 if ( tree instanceof Tree ) {
199- return Commit . createCommit . call (
199+ commit = Commit . createCommit . call (
200200 this ,
201201 updateRef ,
202202 author ,
203203 committer ,
204204 null /* use default message encoding */ ,
205205 message ,
206206 tree ,
207- parents . length , parents ) ;
207+ parents . length ,
208+ parents
209+ ) ;
208210 } else {
209- var self = this ;
210- return this . getTree ( tree ) . then ( function ( tree ) {
211+ createCommit = this . getTree ( tree ) . then ( function ( tree ) {
211212 return Commit . createCommit . call (
212- self ,
213+ commit ,
213214 updateRef ,
214215 author ,
215216 committer ,
216217 null /* use default message encoding */ ,
217218 message ,
218219 tree ,
219- parents . length , parents ) ;
220+ parents . length ,
221+ parents
222+ ) ;
220223 } ) ;
221224 }
225+
226+ return createCommit . then ( function ( commit ) {
227+ if ( typeof callback === "function" ) {
228+ callback ( null , commit ) ;
229+ }
230+
231+ return commit ;
232+ } , callback ) ;
222233} ;
223234
224235/**
@@ -228,20 +239,21 @@ Repository.prototype.createCommit = function(
228239 * @param {Function } callback
229240 * @return {Blob }
230241 */
231- Repository . prototype . createBlobFromBuffer = function ( buffer ) {
232- return Blob . createFrombuffer . call ( this , buffer , buffer . length ) ;
242+ Repository . prototype . createBlobFromBuffer = function ( buffer , callback ) {
243+ return Blob . createFrombuffer . call ( this , buffer , buffer . length , callback ) ;
233244} ;
234245
235246/**
236247 * Create a new tree builder.
237248 *
238249 * @param {Tree } tree
239- * @param {Function } callback
240250 */
241- Repository . prototype . treeBuilder = function ( callback ) {
251+ Repository . prototype . treeBuilder = function ( ) {
242252 var builder = TreeBuilder . create ( null ) ;
253+
243254 builder . root = builder ;
244255 builder . repo = this ;
256+
245257 return builder ;
246258} ;
247259
0 commit comments