2020#include " ../include/commit.h"
2121#include " ../include/error.h"
2222
23+ #include " ../include/functions/string.h"
24+
2325using namespace v8 ;
2426using namespace cvv8 ;
2527using namespace node ;
@@ -273,14 +275,10 @@ Handle<Value> GitCommit::Lookup(const Arguments& args) {
273275
274276 if (args[1 ]->IsObject ()) {
275277 baton->oid = ObjectWrap::Unwrap<GitOid>(args[1 ]->ToObject ())->GetValue ();
276- baton->sha = NULL ;
277278 } else {
278- // Make this less ugly
279- String::AsciiValue shaValue (args[1 ]->ToString ());
280- char *sha = (char *) malloc (shaValue.length () + 1 );
281- strcpy (sha, *shaValue);
282- baton->sha = sha;
279+ baton->sha = stringArgToString (args[1 ]->ToString ());
283280 }
281+
284282 baton->callback = Persistent<Function>::New (Local<Function>::Cast (args[2 ]));
285283
286284 uv_queue_work (uv_default_loop (), &baton->request , LookupWork, LookupAfterWork);
@@ -292,8 +290,8 @@ void GitCommit::LookupWork(uv_work_t *req) {
292290 LookupBaton *baton = static_cast <LookupBaton *>(req->data );
293291
294292 git_oid oid = baton->oid ;
295- if (baton->sha != NULL ) {
296- int returnCode = git_oid_fromstr (&oid, baton->sha );
293+ if (! baton->sha . empty () ) {
294+ int returnCode = git_oid_fromstr (&oid, baton->sha . c_str () );
297295 if (returnCode != GIT_OK ) {
298296 baton->error = giterr_last ();
299297 return ;
@@ -353,6 +351,9 @@ Handle<Value> GitCommit::Close(const Arguments& args) {
353351 return scope.Close (Undefined ());
354352}
355353
354+ /* *
355+ * @todo asynchronize
356+ */
356357Handle<Value> GitCommit::Tree (const Arguments& args) {
357358 HandleScope scope;
358359
0 commit comments