Skip to content

Instantly share code, notes, and snippets.

@bleathem
Created April 20, 2015 22:16
Show Gist options
  • Save bleathem/97f41de2e4d51ad6e899 to your computer and use it in GitHub Desktop.
Save bleathem/97f41de2e4d51ad6e899 to your computer and use it in GitHub Desktop.
void GitDiff::BlobToBufferWorker::Execute() {
int result = git_diff_blob_to_buffer(
baton->old_blob,baton->old_as_path,baton->buffer,baton->buffer_len,baton->buffer_as_path,baton->options,baton->file_cb,baton->hunk_cb,baton->line_cb,baton->payload );
}
void GitDiff::BlobToBufferWorker::HandleOKCallback() {
TryCatch try_catch;
if (baton->error_code == GIT_OK) {
Handle<v8::Value> to;
// start convert_to_v8 block
to = NanNew<Number>( result);
// end convert_to_v8 block
Handle<v8::Value> result = to;
Handle<v8::Value> argv[2] = {
NanNull(),
result
};
callback->Call(2, argv);
} else {
if (baton->error) {
Handle<v8::Value> argv[1] = {
NanError(baton->error->message)
};
callback->Call(1, argv);
if (baton->error->message)
free((void *)baton->error->message);
free((void *)baton->error);
} else {
callback->Call(0, NULL);
}
}
if (try_catch.HasCaught()) {
node::FatalException(try_catch);
}
free((void *)baton->old_as_path);
free((void *)baton->buffer);
free((void *)baton->buffer_as_path);
delete (BlobToBuffer_globalPayload*)baton->payload;
delete baton;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment