@@ -143,14 +143,16 @@ void GitIndex::OpenAfterWork(uv_work_t *req) {
143143 result
144144 };
145145 baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
146- } else if (baton->error ) {
147- Handle<Value> argv[1 ] = {
148- Exception::Error (String::New (baton->error ->message ))
149- };
150- baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
151146 } else {
152- baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
153- }
147+ if (baton->error ) {
148+ Handle<Value> argv[1 ] = {
149+ Exception::Error (String::New (baton->error ->message ))
150+ };
151+ baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
152+ } else {
153+ baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
154+ }
155+ }
154156
155157 if (try_catch.HasCaught ()) {
156158 node::FatalException (try_catch);
@@ -200,21 +202,22 @@ void GitIndex::ReadAfterWork(uv_work_t *req) {
200202
201203 TryCatch try_catch;
202204 if (baton->error_code == GIT_OK) {
203-
204205 Handle<Value> result = Local<Value>::New (Undefined ());
205206 Handle<Value> argv[2 ] = {
206207 Local<Value>::New (Null ()),
207208 result
208209 };
209210 baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
210- } else if (baton->error ) {
211- Handle<Value> argv[1 ] = {
212- Exception::Error (String::New (baton->error ->message ))
213- };
214- baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
215211 } else {
216- baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
217- }
212+ if (baton->error ) {
213+ Handle<Value> argv[1 ] = {
214+ Exception::Error (String::New (baton->error ->message ))
215+ };
216+ baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
217+ } else {
218+ baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
219+ }
220+ }
218221
219222 if (try_catch.HasCaught ()) {
220223 node::FatalException (try_catch);
@@ -263,21 +266,22 @@ void GitIndex::WriteAfterWork(uv_work_t *req) {
263266
264267 TryCatch try_catch;
265268 if (baton->error_code == GIT_OK) {
266-
267269 Handle<Value> result = Local<Value>::New (Undefined ());
268270 Handle<Value> argv[2 ] = {
269271 Local<Value>::New (Null ()),
270272 result
271273 };
272274 baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
273- } else if (baton->error ) {
274- Handle<Value> argv[1 ] = {
275- Exception::Error (String::New (baton->error ->message ))
276- };
277- baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
278275 } else {
279- baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
280- }
276+ if (baton->error ) {
277+ Handle<Value> argv[1 ] = {
278+ Exception::Error (String::New (baton->error ->message ))
279+ };
280+ baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
281+ } else {
282+ baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
283+ }
284+ }
281285
282286 if (try_catch.HasCaught ()) {
283287 node::FatalException (try_catch);
@@ -335,21 +339,22 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) {
335339
336340 TryCatch try_catch;
337341 if (baton->error_code == GIT_OK) {
338-
339342 Handle<Value> result = Local<Value>::New (Undefined ());
340343 Handle<Value> argv[2 ] = {
341344 Local<Value>::New (Null ()),
342345 result
343346 };
344347 baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
345- } else if (baton->error ) {
346- Handle<Value> argv[1 ] = {
347- Exception::Error (String::New (baton->error ->message ))
348- };
349- baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
350348 } else {
351- baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
352- }
349+ if (baton->error ) {
350+ Handle<Value> argv[1 ] = {
351+ Exception::Error (String::New (baton->error ->message ))
352+ };
353+ baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
354+ } else {
355+ baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
356+ }
357+ }
353358
354359 if (try_catch.HasCaught ()) {
355360 node::FatalException (try_catch);
@@ -414,14 +419,17 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) {
414419 result
415420 };
416421 baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
417- } else if (baton->error ) {
418- Handle<Value> argv[1 ] = {
419- Exception::Error (String::New (baton->error ->message ))
420- };
421- baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
422422 } else {
423- baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
424- }
423+ if (baton->error ) {
424+ Handle<Value> argv[1 ] = {
425+ Exception::Error (String::New (baton->error ->message ))
426+ };
427+ baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
428+ } else {
429+ baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
430+ }
431+ free (baton->out );
432+ }
425433
426434 if (try_catch.HasCaught ()) {
427435 node::FatalException (try_catch);
@@ -611,21 +619,22 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) {
611619
612620 TryCatch try_catch;
613621 if (baton->error_code == GIT_OK) {
614-
615622 Handle<Value> result = Local<Value>::New (Undefined ());
616623 Handle<Value> argv[2 ] = {
617624 Local<Value>::New (Null ()),
618625 result
619626 };
620627 baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
621- } else if (baton->error ) {
622- Handle<Value> argv[1 ] = {
623- Exception::Error (String::New (baton->error ->message ))
624- };
625- baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
626628 } else {
627- baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
628- }
629+ if (baton->error ) {
630+ Handle<Value> argv[1 ] = {
631+ Exception::Error (String::New (baton->error ->message ))
632+ };
633+ baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
634+ } else {
635+ baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
636+ }
637+ }
629638
630639 if (try_catch.HasCaught ()) {
631640 node::FatalException (try_catch);
@@ -833,14 +842,16 @@ void GitIndex::IndexToWorkdirAfterWork(uv_work_t *req) {
833842 result
834843 };
835844 baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
836- } else if (baton->error ) {
837- Handle<Value> argv[1 ] = {
838- Exception::Error (String::New (baton->error ->message ))
839- };
840- baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
841845 } else {
842- baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
843- }
846+ if (baton->error ) {
847+ Handle<Value> argv[1 ] = {
848+ Exception::Error (String::New (baton->error ->message ))
849+ };
850+ baton->callback ->Call (Context::GetCurrent ()->Global (), 1 , argv);
851+ } else {
852+ baton->callback ->Call (Context::GetCurrent ()->Global (), 0 , NULL );
853+ }
854+ }
844855
845856 if (try_catch.HasCaught ()) {
846857 node::FatalException (try_catch);
0 commit comments