diff --git a/README.md b/README.md index 2442f8583..cd3769037 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ nodegit > Node.js libgit2 bindings -**v0.0.72** [![Build +**v0.0.74** [![Build Status](https://travis-ci.org/tbranyen/nodegit.png)](https://travis-ci.org/tbranyen/nodegit) Maintained by Tim Branyen [@tbranyen](http://twitter.com/tbranyen) and Michael @@ -28,7 +28,7 @@ Building and installing ----------------------- ### Dependencies ### -To install `nodegit` you need `Node.js` and `cmake`. To run unit tests you will need to have +To install `nodegit` you need `Node.js`, `python` and `cmake`. To run unit tests you will need to have `git` installed and accessible from your `PATH` to fetch any `vendor/` addons. ### Easy install (Recommended) ### @@ -69,34 +69,32 @@ API Example Usage #### Convenience API #### -```` javascript +```JavaScript var git = require("nodegit"); // Read a repository -git.repo('.git', function(err, repo) { - // Success is always 0, failure is always an error string +var git = require('nodegit'); + +// nodegit follows the error, values ... callback argument convention +git.repo('.git', function(error, repo) { if (error) { throw error; } // Use the master branch - repo.branch('master', function(err, branch) { + repo.branch('master', function(error, branch) { if (error) { throw error; } - // Iterate over the revision history - var history = branch.history(); - - // Commit event emits commit object - history.on('commit', function(commit) { - // Print out `git log` emulation + // Print out `git log` emulation for each commit in the branch's history + branch.history().on('commit', function(error, commit) { console.log('commit ' + commit.sha); console.log(commit.author.name + '<' + commit.author.email + '>'); - console.log(commit.time); + console.log(new Date(commit.time * 1000)); console.log("\n"); console.log(commit.message); console.log("\n"); }); }); }); -```` +``` #### Raw API #### diff --git a/include/commit.h b/include/commit.h index da626c8ac..84e20a829 100755 --- a/include/commit.h +++ b/include/commit.h @@ -77,7 +77,7 @@ class GitCommit : public ObjectWrap { const git_error* error; git_repository* repo; - git_oid oid; + git_oid rawOid; std::string sha; git_commit* rawCommit; diff --git a/include/reference.h b/include/reference.h old mode 100755 new mode 100644 index 8037f2dad..46226573a --- a/include/reference.h +++ b/include/reference.h @@ -1,6 +1,9 @@ -/* -Copyright (c) 2011, Tim Branyen @tbranyen -*/ +/** + * Copyright (c) 2011, Tim Branyen @tbranyen + * @author Michael Robinson @codeofinterest + * + * Dual licensed under the MIT and GPL licenses. + */ #ifndef REF_H #define REF_H @@ -19,32 +22,49 @@ using namespace v8; class GitReference : public ObjectWrap { public: - static Persistent constructor_template; + const git_oid* Oid(); + static Persistent constructor_template; static void Initialize(Handle target); + git_reference* GetValue(); void SetValue(git_reference* ref); - int Lookup(git_repository* repo, const char* name); - const git_oid* Oid(); protected: GitReference() {} ~GitReference() {} static Handle New(const Arguments& args); + static Handle Oid(const Arguments& args); + static void OidWork(uv_work_t* req); + static void OidAfterWork(uv_work_t* req); + static Handle Lookup(const Arguments& args); - static void EIO_Lookup(uv_work_t* req); - static void EIO_AfterLookup(uv_work_t* req); + static void LookupWork(uv_work_t* req); + static void LookupAfterWork(uv_work_t* req); - static Handle Oid(const Arguments& args); private: git_reference *ref; - struct lookup_request { + struct LookupBaton { + uv_work_t request; + const git_error* error; + GitReference* ref; - GitRepo* repo; - int err; + git_reference* rawRef; + git_repository* rawRepo; std::string name; + + Persistent callback; + }; + + struct OidBaton { + uv_work_t request; + const git_error* error; + + const git_oid* rawOid; + git_reference* rawRef; + Persistent callback; }; }; diff --git a/install.js b/install.js index 2275fff38..e5a15e53e 100644 --- a/install.js +++ b/install.js @@ -5,7 +5,8 @@ var async = require('async'), request = require('request'), zlib = require('zlib'), fs = require('fs-extra'), - tar = require('tar'); + tar = require('tar'), + exec = require('child_process').exec; function passthru() { var args = Array.prototype.slice.call(arguments); @@ -62,7 +63,28 @@ var checkoutDependencies = function(mainCallback) { }; var libgit2BuildDirectory = path.join(__dirname, 'vendor/libgit2/build'); + +// The python executable to use when building libgit2 +var pythonExecutable = 'python'; + async.series([ + function checkPython2Exists(callback) { + exec('which python2', + function (error) { + if (error !== null) { + pythonExecutable = 'python2'; + callback(); + return; + } + // python2 is not available, check for python + exec('which python', function(error) { + if (error) { + throw new Error('Python is required to build libgit2'); + } + }); + }); + + }, function prepareLibgit2Repository(callback) { // Check for presence of .git folder fs.exists(__dirname + '/.git', function(exists) { @@ -99,7 +121,7 @@ async.series([ function configureNodegit(callback) { console.log('[nodegit] Building native module.'); // shpassthru('node-gyp configure --python python2 --debug', callback); - shpassthru('node-gyp configure --python python2', callback); + shpassthru('node-gyp configure --python ' + pythonExecutable, callback); }, function buildNodegit(callback) { shpassthru('node-gyp build', callback); diff --git a/lib/commit.js b/lib/commit.js index 5a75b5103..c952f4d36 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -11,6 +11,10 @@ var git = require( '../' ), function applyDetails(details, context) { if (details) { for (var detailKey in details) { + if (detailKey === 'id') { + context[detailKey] = git.oid(details[detailKey]); + continue; + } context[detailKey] = details[detailKey]; } } @@ -61,11 +65,14 @@ var _Commit = function(rawCommit) { * with the result. * * @param {Repo} repo - * @param {Oid|String} oid Raw OID object or SHA string + * @param {Oid|String|RawOid} oid Raw or convenience OID object or SHA string * @param {Function} callback */ self.lookup = function(repo, oid, callback) { self.repo = repo; + if (typeof oid !== 'string' && !(oid instanceof git.raw.Oid)) { + oid = oid.getRawOid(); + } self.commit.lookup(repo, oid, function(error, commit) { if (error) { callback(git.error(error), null); diff --git a/lib/index.js b/lib/index.js index 37c6e39c0..6d37ebac3 100755 --- a/lib/index.js +++ b/lib/index.js @@ -1,25 +1,25 @@ // Used to detect for Cygwin -var os = require("os"); +var os = require('os'); // Required for Windows/Cygwin support -var root = [__dirname, "/../vendor/libgit2/build/shared"].join(""), +var root = [__dirname, '/../vendor/libgit2/build/shared'].join(''), path = process.env.PATH; -if (~os.type().indexOf("CYGWIN") && !~path.indexOf(root)) { - process.env.PATH = root + ":" + path; +if (~os.type().indexOf('CYGWIN') && !~path.indexOf(root)) { + process.env.PATH = root + ':' + path; } // Import libraries -exports.blob = require("./blob.js").blob; -exports.repo = require("./repo.js").repo; -exports.sig = require("./sig.js").sig; -exports.oid = require("./oid.js").oid; -exports.object = require("./object.js").object; -exports.ref = require("./ref.js").ref; -exports.revwalk = require("./revwalk.js").revwalk; -exports.commit = require("./commit.js").commit; -exports.tree = require("./tree.js").tree; -exports.entry = require("./tree_entry.js").entry; +exports.blob = require('./blob.js').blob; +exports.repo = require('./repo.js').repo; +exports.sig = require('./sig.js').sig; +exports.oid = require('./oid.js').oid; +exports.object = require('./object.js').object; +exports.reference = require('./reference.js').reference; +exports.revwalk = require('./revwalk.js').revwalk; +exports.commit = require('./commit.js').commit; +exports.tree = require('./tree.js').tree; +exports.entry = require('./tree_entry.js').entry; // Assign raw api to module try { @@ -29,8 +29,8 @@ try { } // Initialize objects that need to access their raw counterparts -exports.diffList = require("./diff_list.js").diffList; -exports.error = require("./error.js").error; +exports.diffList = require('./diff_list.js').diffList; +exports.error = require('./error.js').error; // Set version exports.version = require('../package').version; diff --git a/lib/oid.js b/lib/oid.js index cda090b15..972933392 100644 --- a/lib/oid.js +++ b/lib/oid.js @@ -1,18 +1,19 @@ var git = require( '../' ); -var _Oid = function(obj) { +var Oid = function(rawOid) { var self = {}; - if(obj instanceof git.raw.Oid) { - self.oid = obj; + if(rawOid instanceof git.raw.Oid) { + self.oid = rawOid; } else { self.oid = new git.raw.Oid(); - - if (typeof obj === 'string') { - self.oid.mkstr(obj); - } } + + self.getRawOid = function() { + return self.oid; + }; + return self; }; -exports.oid = _Oid; +exports.oid = Oid; diff --git a/lib/ref.js b/lib/ref.js deleted file mode 100644 index 5c244cece..000000000 --- a/lib/ref.js +++ /dev/null @@ -1,36 +0,0 @@ -var git = require('../'); - -var _Ref = function(obj) { - var self = {}; - - if(obj instanceof git.raw.Repo) { - self.repo = obj; - self.ref = new git.raw.Ref(obj); - } else if(obj instanceof git.raw.Ref) { - self.ref = obj; - } - - self.lookup = function(name, callback) { - if(!callback || typeof callback !== 'function') { - throw new Error('Callback is required and must be a function'); - } - - self.ref.lookup(self.repo, name, function(error) { - if (error) { - callback(git.error(error), self); - return; - } - callback(null, self); - }); - }; - - self.oid = function() { - var oid = git.oid(); - self.ref.oid(oid.oid); - return oid; - }; - - return self; -}; - -exports.ref = _Ref; diff --git a/lib/reference.js b/lib/reference.js new file mode 100644 index 000000000..94e8231d9 --- /dev/null +++ b/lib/reference.js @@ -0,0 +1,37 @@ +var git = require('../'); + +var Reference = function(rawReference) { + var self = {}; + + if(rawReference instanceof git.raw.Reference) { + self.reference = rawReference; + } else if(rawReference instanceof git.raw.Repo) { + self.repo = rawReference; + self.reference = new git.raw.Reference(rawReference); + } + + self.lookup = function(name, callback) { + self.reference.lookup(self.repo, name, function(error, reference) { + if (error) { + callback(git.error(error), self); + return; + } + self.reference = reference; + callback(null, self); + }); + }; + + self.oid = function(callback) { + self.reference.oid(function(error, rawOid) { + if (error) { + callback(git.error(error, self)); + return; + } + callback(null, git.oid(rawOid)); + }); + }; + + return self; +}; + +exports.reference = Reference; diff --git a/lib/repo.js b/lib/repo.js index 2420ba45b..b6541b427 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -14,25 +14,13 @@ exports.repo = function(directory, callback) { if (!callback || typeof callback !== 'function') { throw new Error('If directory is provided, callback function is required'); } - fs.exists(directory, function directoryExists(exists) { - if (!exists) { - callback(new Error('Directory must exist'), null); + self.repo.open(directory, function(error, rawRepo) { + if (error) { + callback(git.error(error), null); return; } - fs.realpath(directory, function realpathCallback(error, directory) { - if (error) { - callback(git.error(error), null); - return; - } - self.repo.open(directory, function(error, rawRepo) { - if (error) { - callback(git.error(error), null); - return; - } - self.repo = rawRepo; - callback(null, self); - }); - }); + self.repo = rawRepo; + callback(null, self); }); } @@ -43,25 +31,30 @@ exports.repo = function(directory, callback) { * @param {Function} */ self.branch = function(name, callback) { - git.ref(self.repo).lookup('refs/heads/' + name, function(error, ref) { + git.reference(self.repo).lookup('refs/heads/' + name, function referenceLookupCallback(error, reference) { if (error) { callback(git.error(error), null); return; } - - git.commit(self.repo).lookup(self.repo, ref.oid().oid, function(error, commit) { + reference.oid(function oidCallback(error, oid) { if (error) { callback(git.error(error), null); return; } - callback(null, commit); + self.commit(oid, function commitLookupCallback(error, commit) { + if (error) { + callback(git.error(error), null); + return; + } + callback(null, commit); + }); }); }); }; // Find a single commit - self.commit = function(sha, callback) { - git.commit().lookup(self.repo, sha, function(error, commit) { + self.commit = function(oid, callback) { + git.commit().lookup(self.repo, oid, function(error, commit) { callback(error, commit); }); }; diff --git a/lib/revwalk.js b/lib/revwalk.js index 9659828d7..8958f9e89 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -20,7 +20,7 @@ var _RevWalk = function( obj ) { self.walk = function(oid, callback) { if(!callback) { return; } - self.revwalk.push(oid, function(error) { + self.revwalk.push(oid.getRawOid(), function(error) { if (error) { callback.apply(this, [git.error(error)]); return; diff --git a/package.json b/package.json index 2b54c37a7..764267fb5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegit", "description": "Node.js libgit2 asynchronous native bindings", - "version": "0.0.74", + "version": "0.0.75", "homepage": "https://github.com/tbranyen/nodegit", "keywords": [ "libgit2", @@ -27,7 +27,7 @@ "lib": "./lib" }, "engines": { - "node": "~0.8" + "node": ">= 0.8" }, "dependencies": { "async": ">= 0.1.21", diff --git a/src/commit.cc b/src/commit.cc index 2d0f32142..7573a2e8f 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -274,7 +274,7 @@ Handle GitCommit::Lookup(const Arguments& args) { baton->repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); if (args[1]->IsObject()) { - baton->oid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->rawOid = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); } else { baton->sha = stringArgToString(args[1]->ToString()); } @@ -289,9 +289,9 @@ Handle GitCommit::Lookup(const Arguments& args) { void GitCommit::LookupWork(uv_work_t *req) { LookupBaton *baton = static_cast(req->data); - git_oid oid = baton->oid; + git_oid rawOid = baton->rawOid; if (!baton->sha.empty()) { - int returnCode = git_oid_fromstr(&oid, baton->sha.c_str()); + int returnCode = git_oid_fromstr(&rawOid, baton->sha.c_str()); if (returnCode != GIT_OK) { baton->error = giterr_last(); return; @@ -299,7 +299,7 @@ void GitCommit::LookupWork(uv_work_t *req) { } baton->rawCommit = NULL; - int returnCode = git_commit_lookup(&baton->rawCommit, baton->repo, &oid); + int returnCode = git_commit_lookup(&baton->rawCommit, baton->repo, &rawOid); if (returnCode != GIT_OK) { baton->error = giterr_last(); } diff --git a/src/reference.cc b/src/reference.cc index 0993635d9..e9c72b403 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -14,6 +14,9 @@ #include "../include/repo.h" #include "../include/reference.h" #include "../include/oid.h" +#include "../include/error.h" + +#include "../include/functions/string.h" using namespace v8; using namespace node; @@ -21,16 +24,16 @@ using namespace node; void GitReference::Initialize(Handle target) { HandleScope scope; - Local t = FunctionTemplate::New(New); + Local tpl = FunctionTemplate::New(New); - constructor_template = Persistent::New(t); - constructor_template->InstanceTemplate()->SetInternalFieldCount(1); - constructor_template->SetClassName(String::NewSymbol("Ref")); + tpl->InstanceTemplate()->SetInternalFieldCount(1); + tpl->SetClassName(String::NewSymbol("Reference")); - NODE_SET_PROTOTYPE_METHOD(constructor_template, "oid", Oid); - NODE_SET_PROTOTYPE_METHOD(constructor_template, "lookup", Lookup); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); + NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup); - target->Set(String::NewSymbol("Ref"), constructor_template->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Reference"), constructor_template); } git_reference* GitReference::GetValue() { @@ -41,14 +44,6 @@ void GitReference::SetValue(git_reference *ref) { this->ref = ref; } -int GitReference::Lookup(git_repository* repo, const char* name) { - return git_reference_lookup(&this->ref, repo, name); -} - -const git_oid* GitReference::Oid() { - return git_reference_target(this->ref); -} - Handle GitReference::New(const Arguments& args) { HandleScope scope; @@ -59,88 +54,153 @@ Handle GitReference::New(const Arguments& args) { return args.This(); } -Handle GitReference::Lookup(const Arguments& args) { +Handle GitReference::Oid(const Arguments& args) { HandleScope scope; - GitReference *ref = ObjectWrap::Unwrap(args.This()); - Local callback; - - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Repo is required and must be a Object."))); - } - - if(args.Length() == 1 || !args[1]->IsString()) { - return ThrowException(Exception::Error(String::New("Name is required and must be a String."))); - } - - if(args.Length() == 2 || !args[2]->IsFunction()) { + if(args.Length() == 0 || !args[0]->IsFunction()) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - callback = Local::Cast(args[2]); + OidBaton *baton = new OidBaton; + baton->request.data = baton; + baton->error = NULL; + baton->rawOid = NULL; + baton->rawRef = ObjectWrap::Unwrap(args.This())->GetValue(); + baton->callback = Persistent::New(Local::Cast(args[0])); - lookup_request *ar = new lookup_request(); - ar->ref = ref; - ar->repo = ObjectWrap::Unwrap(args[0]->ToObject()); + uv_queue_work(uv_default_loop(), &baton->request, OidWork, (uv_after_work_cb)OidAfterWork); - String::Utf8Value name(args[1]); - ar->name = *name; + return Undefined(); +} - ar->callback = Persistent::New(callback); +void GitReference::OidWork(uv_work_t* req) { + OidBaton *baton = static_cast(req->data); - ref->Ref(); + git_ref_t referenceType = git_reference_type(baton->rawRef); - uv_work_t *req = new uv_work_t; - req->data = ar; - uv_queue_work(uv_default_loop(), req, EIO_Lookup, (uv_after_work_cb)EIO_AfterLookup); + if (referenceType == GIT_REF_INVALID) { + printf("invalid\n"); + giterr_set_str(GITERR_INVALID, "Invalid reference type"); + baton->error = giterr_last(); + return; + } - return scope.Close( Undefined() ); + if (referenceType == GIT_REF_SYMBOLIC) { + printf("symbolic\n"); + int returnCode = git_reference_resolve(&baton->rawRef, baton->rawRef); + if (returnCode != GIT_OK) { + baton->error = giterr_last(); + return; + } + } + baton->rawOid = git_reference_target(baton->rawRef); } +void GitReference::OidAfterWork(uv_work_t* req) { + HandleScope scope; + OidBaton *baton = static_cast(req->data); + + if (baton->error) { + Local argv[1] = { + GitError::WrapError(baton->error) + }; + + TryCatch try_catch; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + } else { + + Handle oid = GitOid::constructor_template->NewInstance(); + GitOid *oidInstance = ObjectWrap::Unwrap(oid); + oidInstance->SetValue(*const_cast(baton->rawOid)); + + Handle argv[2] = { + Local::New(Null()), + oid + }; + + TryCatch try_catch; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + } -void GitReference::EIO_Lookup(uv_work_t *req) { - lookup_request *ar = static_cast(req->data); - - git_repository* repo = ar->repo->GetValue(); - - ar->err = ar->ref->Lookup(repo, ar->name.c_str()); - + delete req; } -void GitReference::EIO_AfterLookup(uv_work_t *req) { +Handle GitReference::Lookup(const Arguments& args) { HandleScope scope; - lookup_request *ar = static_cast(req->data); - ar->ref->Unref(); - - Local argv[1]; - argv[0] = Integer::New(ar->err); + if(args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repo is required and must be a Object."))); + } - TryCatch try_catch; + if(args.Length() == 1 || !args[1]->IsString()) { + return ThrowException(Exception::Error(String::New("Name is required and must be a String."))); + } - ar->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if(args.Length() == 2 || !args[2]->IsFunction()) { + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); + } - if(try_catch.HasCaught()) - FatalException(try_catch); + LookupBaton *baton = new LookupBaton; + baton->request.data = baton; + baton->ref = ObjectWrap::Unwrap(args.This()); + baton->ref->Ref(); + baton->error = NULL; + baton->rawRepo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->name = stringArgToString(args[1]->ToString()); + baton->callback = Persistent::New(Local::Cast(args[2])); - ar->callback.Dispose(); + uv_queue_work(uv_default_loop(), &baton->request, LookupWork, (uv_after_work_cb)LookupAfterWork); - delete ar; - delete req; + return Undefined(); } -Handle GitReference::Oid(const Arguments& args) { - HandleScope scope; - - GitReference *ref = ObjectWrap::Unwrap(args.This()); +void GitReference::LookupWork(uv_work_t *req) { + LookupBaton *baton = static_cast(req->data); - if(args.Length() == 0 || !args[0]->IsObject()) { - return ThrowException(Exception::Error(String::New("Oid is required and must be an Object."))); + baton->rawRef = NULL; + int returnCode = git_reference_lookup(&baton->rawRef, baton->rawRepo, baton->name.c_str()); + if (returnCode != GIT_OK) { + baton->error = giterr_last(); } +} - GitOid *oid = ObjectWrap::Unwrap(args[0]->ToObject()); - git_oid* in = const_cast(ref->Oid()); - oid->SetValue(*in); +void GitReference::LookupAfterWork(uv_work_t *req) { + HandleScope scope; + LookupBaton *baton = static_cast(req->data); + + if (baton->error) { + Local argv[1] = { + GitError::WrapError(baton->error) + }; + + TryCatch try_catch; + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + } else { + + baton->ref->SetValue(baton->rawRef); + + Handle argv[2] = { + Local::New(Null()), + baton->ref->handle_ + }; + + TryCatch try_catch; + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + } - return scope.Close( Undefined() ); + baton->ref->Unref(); + delete req; } -Persistent GitReference::constructor_template; + +Persistent GitReference::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index 42e05026f..b1d6d5db9 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -1,5 +1,5 @@ -/* - * Copyright 2011, Tim Branyen @tbranyen +/** + * Copyright (c) 2011, Tim Branyen @tbranyen * @author Michael Robinson @codeofinterest * * Dual licensed under the MIT and GPL licenses. @@ -68,7 +68,7 @@ Handle GitRepo::Open(const Arguments& args) { return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } - OpenBaton *baton = new OpenBaton(); + OpenBaton *baton = new OpenBaton; baton->request.data = baton; baton->error = NULL; baton->path = stringArgToString(args[0]->ToString());; @@ -157,8 +157,7 @@ Handle GitRepo::Init(const Arguments& args) { baton->repo = ObjectWrap::Unwrap(args.This()); baton->repo->Ref(); baton->rawRepo = baton->repo->GetValue(); - String::Utf8Value path(args[0]); - baton->path = *path; + baton->path = stringArgToString(args[0]->ToString());; baton->isBare = args[1]->ToBoolean()->Value(); baton->callback = Persistent::New(Local::Cast(args[2])); diff --git a/test/raw-blob.js b/test/raw-blob.js index c8ba41a71..50629b4a3 100644 --- a/test/raw-blob.js +++ b/test/raw-blob.js @@ -41,7 +41,7 @@ exports.constructor = function(test){ // Blob::Lookup exports.lookup = function(test) { var testOid = new git.Oid(), - testRef = new git.Ref(testRepo), + testRef = new git.Reference(testRepo), testBlob = new git.Blob(); test.expect(5); diff --git a/test/raw-reference.js b/test/raw-reference.js index 06afa0aaa..e20662f60 100644 --- a/test/raw-reference.js +++ b/test/raw-reference.js @@ -27,18 +27,19 @@ exports.constructor = function(test){ test.expect(3); // Test for function - helper.testFunction(test.equals, git.Ref, 'Ref'); + helper.testFunction(test.equals, git.Reference, 'Reference'); // Ensure we get an instance of Ref - test.ok(new git.Ref() instanceof git.Ref, 'Invocation returns an instance of Ref'); + test.ok(new git.Reference() instanceof git.Reference, 'Invocation returns an instance of Ref'); test.done(); }; // Ref::Lookup exports.lookup = function(test) { + var testRepo = new git.Repo(), - master = new git.Ref(); + master = new git.Reference(); test.expect(5);