| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,7 +78,7 @@ class GitCommit : public ObjectWrap { | |||
| 78 | 78 | ||
| 79 | 79 | git_repository* repo; | |
| 80 | 80 | git_oid oid; | |
| 81 | - const char* sha; | ||
| 81 | + std::string sha; | ||
| 82 | 82 | git_commit* rawCommit; | |
| 83 | 83 | ||
| 84 | 84 | Persistent<Function> callback; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,8 @@ | |||
| 20 | 20 | #include "../include/commit.h" | |
| 21 | 21 | #include "../include/error.h" | |
| 22 | 22 | ||
| 23 | + #include "../include/functions/string.h" | ||
| 24 | + | ||
| 23 | 25 | using namespace v8; | |
| 24 | 26 | using namespace cvv8; | |
| 25 | 27 | using namespace node; | |
@@ -273,14 +275,10 @@ Handle<Value> GitCommit::Lookup(const Arguments& args) { | |||
| 273 | 275 | ||
| 274 | 276 | if (args[1]->IsObject()) { | |
| 275 | 277 | baton->oid = ObjectWrap::Unwrap<GitOid>(args[1]->ToObject())->GetValue(); | |
| 276 | - baton->sha = NULL; | ||
| 277 | 278 | } 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()); | ||
| 283 | 280 | } | |
| 281 | + | ||
| 284 | 282 | baton->callback = Persistent<Function>::New(Local<Function>::Cast(args[2])); | |
| 285 | 283 | ||
| 286 | 284 | uv_queue_work(uv_default_loop(), &baton->request, LookupWork, LookupAfterWork); | |
@@ -292,8 +290,8 @@ void GitCommit::LookupWork(uv_work_t *req) { | |||
| 292 | 290 | LookupBaton *baton = static_cast<LookupBaton *>(req->data); | |
| 293 | 291 | ||
| 294 | 292 | 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()); | ||
| 297 | 295 | if (returnCode != GIT_OK) { | |
| 298 | 296 | baton->error = giterr_last(); | |
| 299 | 297 | return; | |
@@ -353,6 +351,9 @@ Handle<Value> GitCommit::Close(const Arguments& args) { | |||
| 353 | 351 | return scope.Close(Undefined()); | |
| 354 | 352 | } | |
| 355 | 353 | ||
| 354 | + /** | ||
| 355 | + * @todo asynchronize | ||
| 356 | + */ | ||
| 356 | 357 | Handle<Value> GitCommit::Tree(const Arguments& args) { | |
| 357 | 358 | HandleScope scope; | |
| 358 | 359 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments