1- var git = require ( '../' ) ,
2- success = require ( './utilities' ) . success ;
1+ var git = require ( '../' ) ;
32
43/**
54 * Convenience repository class.
@@ -24,9 +23,8 @@ Repo.init = function(directory, isBare, callback) {
2423 * @param {Repo|null } repo Initialized repository.
2524 */
2625 git . raw . Repo . init ( directory , isBare , function ( error , rawRepo ) {
27- if ( success ( error , callback ) ) {
28- callback ( null , new Repo ( rawRepo ) ) ;
29- }
26+ if ( error ) return callback ( error ) ;
27+ callback ( null , new Repo ( rawRepo ) ) ;
3028 } ) ;
3129} ;
3230
@@ -46,12 +44,11 @@ Repo.open = function(directory, callback) {
4644 * @param {Repo|null } repo Opened repository.
4745 */
4846 if ( typeof callback !== 'function' ) {
49- throw new git . error ( 'Callback is required and must be a Function' ) ;
47+ throw new Error ( 'Callback is required and must be a Function' ) ;
5048 }
5149 git . raw . Repo . open ( directory , function openRepository ( error , rawRepo ) {
52- if ( success ( error , callback ) ) {
53- callback ( null , new Repo ( rawRepo ) ) ;
54- }
50+ if ( error ) return callback ( error ) ;
51+ callback ( null , new Repo ( rawRepo ) ) ;
5552 } ) ;
5653} ;
5754
@@ -69,11 +66,11 @@ Repo.prototype.branch = function(name, callback) {
6966 */
7067 var self = this ;
7168 git . reference . lookup ( this . rawRepo , 'refs/heads/' + name , function referenceLookupCallback ( error , reference ) {
72- if ( ! success ( error , callback ) ) return ;
69+ if ( error ) return callback ( error ) ;
7370
7471 var oid = reference . oid ( ) ;
7572 self . commit ( oid , function commitLookupCallback ( error , commit ) {
76- if ( ! success ( error , callback ) ) return ;
73+ if ( error ) return callback ( error ) ;
7774
7875 callback ( null , commit ) ;
7976 } ) ;
@@ -97,9 +94,8 @@ Repo.prototype.commit = function(oid, callback) {
9794 if ( typeof oid === 'string' ) oid = git . raw . Oid . fromString ( oid ) ;
9895
9996 git . raw . Commit . lookup ( this . rawRepo , oid , function ( error , rawCommit ) {
100- if ( success ( error , callback ) ) {
101- callback ( null , new git . commit ( self , rawCommit ) ) ;
102- }
97+ if ( error ) return callback ( error ) ;
98+ callback ( null , new git . commit ( self , rawCommit ) ) ;
10399 } ) ;
104100 } catch ( e ) {
105101 callback ( e ) ;
@@ -119,9 +115,8 @@ Repo.prototype.blob = function(oid, callback) {
119115 * @param {Blob|null } blob Retrieved blob object or null.
120116 */
121117 git . raw . Blob . lookup ( this . rawRepo , oid . rawOid , function blobLookup ( error , rawBlob ) {
122- if ( success ( error , callback ) ) {
123- callback ( null , new git . blob ( rawBlob ) ) ;
124- }
118+ if ( error ) return callback ( error ) ;
119+ callback ( null , new git . blob ( rawBlob ) ) ;
125120 } ) ;
126121} ;
127122
@@ -139,9 +134,8 @@ Repo.prototype.tree = function(oid, callback) {
139134 */
140135 var self = this ;
141136 git . raw . Tree . lookup ( this . rawRepo , oid . rawOid , function ( error , rawTree ) {
142- if ( success ( error , callback ) ) {
143- callback ( null , new git . tree ( self , rawTree ) ) ;
144- }
137+ if ( error ) return callback ( error ) ;
138+ callback ( null , new git . tree ( self , rawTree ) ) ;
145139 } ) ;
146140} ;
147141
0 commit comments