diff --git a/.npmignore b/.npmignore
index 1980fa872..5b5b9304e 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,6 +1,4 @@
-docs/
-example/
-test/
-util/
-vendor/nodeunit
-vendor/rimraf
+/doc/
+/example/
+/node_modules/
+/test/
diff --git a/.travis.yml b/.travis.yml
index 0604aaedf..8be0a1110 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
language: node_js
node_js:
- - 0.8
- "0.10"
- 0.11
git:
diff --git a/README.md b/README.md
index ae7ba817b..c2e03d931 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ NodeGit
Status](https://travis-ci.org/tbranyen/nodegit.png)](https://travis-ci.org/nodegit/nodegit)
-**Stable: 0.1.3**
+**Stable: 0.1.4**
Maintained by Tim Branyen [@tbranyen](http://twitter.com/tbranyen), Michael
Robinson [@codeofinterest](http://twitter.com/codeofinterest), and Nick Kallen
@@ -18,18 +18,23 @@ contributors](https://github.com/tbranyen/nodegit/contributors)!
http://www.nodegit.org/nodegit/
-## Building and Installing. ##
+## Getting started. ##
-Minimum dependencies:
-
-* [Python 2](https://www.python.org/)
-* [CMake >= 2.8](http://www.cmake.org/)
+NodeGit will work on most systems out-of-the-box without any native
+dependencies.
``` bash
npm install nodegit
```
-### Building manually: ###
+If you encounter problems while installing, you should try the Building from
+source instructions below.
+
+## Building from source. ##
+
+Minimum dependencies:
+
+- [Python 2](https://www.python.org/)
If you wish to help contribute to nodegit it is useful to build locally.
@@ -49,31 +54,26 @@ correctly.
### Installing dependencies: ###
-#### OS X ####
+#### Mac OS X ####
-Using Brew:
-
-``` bash
-brew install cmake libzip
-```
+- [Install XCode Command Line Tools](http://railsapps.github.io/xcode-command-line-tools.html)
#### Linux ####
Using APT in Ubuntu:
``` bash
-sudo apt-get install cmake libzip-dev build-essential
+sudo apt-get install build-essential
```
Using Pacman in Arch Linux:
``` bash
-sudo pacman -S cmake libzip base-devel
+sudo pacman -S base-devel
```
#### Windows ####
-- [Download and install CMake](http://www.cmake.org/cmake/resources/software.html).
- [Download and install Python](https://www.python.org/download/windows).
- [Download and install VS Express](http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop).
@@ -107,13 +107,13 @@ clone("https://github.com/nodegit/nodegit", "tmp", null, function(err, repo) {
// Look up this known commit.
repo.getCommit(sha, function(err, commit) {
if (err) {
- throw error;
+ throw err;
}
// Look up a specific file within that commit.
commit.getEntry("README.md", function(err, entry) {
if (err) {
- throw error;
+ throw err;
}
// Get the blob contents from the file.
diff --git a/appveyor.yml b/appveyor.yml
index 5dfc10162..8c99db391 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -14,7 +14,6 @@ environment:
matrix:
- nodejs_version: 0.11
- nodejs_version: 0.10
- - nodejs_version: 0.8
matrix:
allow_failures:
diff --git a/binding.gyp b/binding.gyp
index 6233c2826..104b7a9d3 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -3,6 +3,10 @@
{
"target_name": "nodegit",
+ "dependencies": [
+ "libgit2"
+ ],
+
"sources": [
"src/base.cc",
"src/blob.cc",
@@ -46,35 +50,374 @@
],
"cflags": [
- "-Wall"
- ],
-
- "ldflags": [
- "-Wl,-rpath,\$$ORIGIN/../../vendor/libgit2/build"
+ "-Wall",
],
"conditions": [
- [
- "OS=='win'", {
- "libraries": [
- "-l../vendor/libgit2/build/Debug/git2.lib"
- ],
- }, { # 'OS!="win"'
- "libraries": [
- "-L
*/
-Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arguments& args) {
- HandleScope scope;
+NAN_METHOD(<%- cppClassName %>::<%- functionInfo.cppFunctionName %>) {
+ NanScope();
<% var jsArg; -%>
<% include guardArguments.cc.ejs -%>
if (args.Length() == <%- jsArg %> || !args[<%- jsArg %>]->IsFunction()) {
- return ThrowException(Exception::Error(String::New("Callback is required and must be a Function.")));
+ return NanThrowError("Callback is required and must be a Function.");
}
<%- functionInfo.cppFunctionName %>Baton* baton = new <%- functionInfo.cppFunctionName %>Baton;
baton->error_code = GIT_OK;
baton->error = NULL;
- baton->request.data = baton;
<%
for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) {
var arg = functionInfo.args[cArg];
-%>
<% if (!arg.isReturn) { -%>
<% if (arg.isSelf) { -%>
- baton-><%- arg.name %>Reference = Persistent::New(args.This());
baton-><%- arg.name %> = ObjectWrap::Unwrap<<%- cppClassName %>>(args.This())->GetValue();
<% } else { -%>
- baton-><%- arg.name %>Reference = Persistent::New(args[<%- jsArg %>]);
<% include convertFromV8.cc.ejs -%>
<% if (!arg.isPayload) { -%>
baton-><%- arg.name %> = from_<%- arg.name %>;
@@ -35,19 +32,32 @@ Handle <%- cppClassName %>::<%- functionInfo.cppFunctionName %>(const Arg
<% } else { -%>
<% if (arg.shouldAlloc) { -%>
baton-><%- arg.name %> = (<%- arg.cType %>)malloc(sizeof(<%- arg.cType.replace('*', '') %>));
-<% } else { -%>
<% } -%>
<% } -%>
<% } -%>
- baton->callback = Persistent::New(Local::Cast(args[<%- jsArg %>]));
- uv_queue_work(uv_default_loop(), &baton->request, <%- functionInfo.cppFunctionName %>Work, (uv_after_work_cb)<%- functionInfo.cppFunctionName %>AfterWork);
+ NanCallback *callback = new NanCallback(Local::Cast(args[<%- jsArg %>]));
+ <%- functionInfo.cppFunctionName %>Worker *worker = new <%- functionInfo.cppFunctionName %>Worker(baton, callback);
+<%
+ for (var cArg = 0, jsArg = 0; cArg < functionInfo.args.length; cArg++) {
+ var arg = functionInfo.args[cArg];
+-%>
+<% if (!arg.isReturn) { -%>
+<% if (arg.isSelf) { -%>
+ worker->SaveToPersistent("<%- arg.name %>", args.This());
+<% } else { -%>
+ if (!args[<%- jsArg %>]->IsUndefined() && !args[<%- jsArg %>]->IsNull())
+ worker->SaveToPersistent("<%- arg.name %>", args[<%- jsArg %>]->ToObject());
+<% } -%>
+<% if (!(arg.isReturn || arg.isSelf || arg.isPayload)) jsArg++; -%>
+<% } -%>
+<% } -%>
- return Undefined();
+ NanAsyncQueueWorker(worker);
+ NanReturnUndefined();
}
-void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req) {
- <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data);
+void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Worker::Execute() {
<% if (functionInfo.return.cType != "void" || functionInfo.return.isErrorCode) { %><%- functionInfo.return.cType %> result = <% } %><%- functionInfo.cFunctionName %>(
<%
for (var i = 0; i < functionInfo.args.length; i++) {
@@ -66,46 +76,43 @@ void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Work(uv_work_t *req
<% } -%>
}
-void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>AfterWork(uv_work_t *req) {
- HandleScope scope;
- <%- functionInfo.cppFunctionName %>Baton *baton = static_cast<<%- functionInfo.cppFunctionName %>Baton *>(req->data);
-
+void <%- cppClassName %>::<%- functionInfo.cppFunctionName %>Worker::HandleOKCallback() {
TryCatch try_catch;
if (baton->error_code == GIT_OK) {
<% if (!returns.length) { -%>
- Handle result = Local::New(Undefined());
+ Handle result = NanUndefined();
<% } else if (returns.length == 1) { -%>
<% var to = {}; to.__proto__ = returns[0]; to.name = "baton->" + to.name; -%>
Handle to;
<% include convertToV8.cc.ejs -%>
Handle result = to;
<% } else { -%>
- Handle