55 * Dual licensed under the MIT and GPL licenses.
66 */
77
8- #include < string.h>
98#include < v8.h>
109#include < node.h>
10+ #include < string.h>
1111
1212#include " git2.h"
1313#include " cvv8/v8-convert.hpp"
2121#include " ../include/error.h"
2222
2323#include " ../include/functions/utilities.h"
24+ #include " ../include/functions/string.h"
2425
2526using namespace v8 ;
2627using namespace cvv8 ;
@@ -36,7 +37,6 @@ void GitCommit::Initialize(Handle<Object> target) {
3637
3738 NODE_SET_PROTOTYPE_METHOD (tpl, " lookup" , Lookup);
3839 NODE_SET_PROTOTYPE_METHOD (tpl, " oid" , Oid);
39- NODE_SET_PROTOTYPE_METHOD (tpl, " sha" , Sha);
4040 NODE_SET_PROTOTYPE_METHOD (tpl, " message" , Message);
4141 NODE_SET_PROTOTYPE_METHOD (tpl, " time" , Time);
4242 NODE_SET_PROTOTYPE_METHOD (tpl, " offset" , Offset);
@@ -162,45 +162,6 @@ Handle<Value> GitCommit::Oid(const Arguments& args) {
162162 return scope.Close (oid);
163163}
164164
165- Handle<Value> GitCommit::Sha (const Arguments& args) {
166- HandleScope scope;
167-
168- if (args.Length () == 0 || !args[0 ]->IsFunction ()) {
169- return ThrowException (Exception::Error (String::New (" Callback is required and must be a Function." )));
170- }
171-
172- ShaBaton* baton = new ShaBaton;
173- baton->request .data = baton;
174- baton->rawOid = ObjectWrap::Unwrap<GitCommit>(args.This ())->oid ;
175- baton->callback = Persistent<Function>::New (Local<Function>::Cast (args[0 ]));
176-
177- uv_queue_work (uv_default_loop (), &baton->request , ShaWork, (uv_after_work_cb)ShaAfterWork);
178-
179- return Undefined ();
180- }
181- void GitCommit::ShaWork (uv_work_t * req) {
182- ShaBaton *baton = static_cast <ShaBaton *>(req->data );
183-
184- baton->sha [GIT_OID_HEXSZ] = ' \0 ' ;
185- git_oid_fmt (baton->sha , baton->rawOid );
186- }
187- void GitCommit::ShaAfterWork (uv_work_t * req) {
188- HandleScope scope;
189- ShaBaton *baton = static_cast <ShaBaton *>(req->data );
190-
191- Handle<Value> argv[2 ] = {
192- Local<Value>::New (Null ()),
193- String::New (baton->sha )
194- };
195-
196- TryCatch try_catch;
197- baton->callback ->Call (Context::GetCurrent ()->Global (), 2 , argv);
198- if (try_catch.HasCaught ()) {
199- node::FatalException (try_catch);
200- }
201- delete req;
202- }
203-
204165Handle<Value> GitCommit::Message (const Arguments& args) {
205166 HandleScope scope;
206167
0 commit comments