Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ doc
!doc/Theme.css
example/stress/test
node_modules
.DS_Store
4 changes: 2 additions & 2 deletions example/convenience-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ git.repo( '../.git', function( err, repo ) {

var history = commit.history();
history.on( 'commit', function() {
//console.log(arguments);
// console.log(arguments);
});

history.on( 'end', function( commits ) {
// Read first commit tree
var tree = commits[0].tree();

// Synchronous
tree.walk(function( i, entry ) {
tree.walk().on('entry', function( i, entry ) {
console.log( entry.content );
return false;
});
Expand Down
13 changes: 4 additions & 9 deletions include/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,17 @@ class GitBlob : public ObjectWrap {
* Function: EIO_Lookup
*
* Parameters:
* req - an eio_req pointer
* req - an uv_work_t pointer
*
* Returns:
* completion code integer
*/
static void EIO_Lookup(eio_req* req);
static void EIO_Lookup(uv_work_t* req);
/**
* Function: EIO_AfterLookup
*
* Parameters:
* req - an eio_req pointer
*
* Returns:
* completion code integer
* req - an uv_work_t pointer
*/
static int EIO_AfterLookup(eio_req* req);
static void EIO_AfterLookup(uv_work_t* req);
/**
* Function: RawContent
*
Expand Down
8 changes: 4 additions & 4 deletions include/commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class GitCommit : public ObjectWrap {
static Handle<Value> New(const Arguments& args);

static Handle<Value> Lookup(const Arguments& args);
static void EIO_Lookup(eio_req *req);
static int EIO_AfterLookup(eio_req *req);
static void EIO_Lookup(uv_work_t *req);
static void EIO_AfterLookup(uv_work_t *req);

static Handle<Value> Close(const Arguments& args);
static Handle<Value> Id(const Arguments& args);
Expand All @@ -71,8 +71,8 @@ class GitCommit : public ObjectWrap {
static Handle<Value> Author(const Arguments& args);

static Handle<Value> Tree(const Arguments& args);
static int EIO_Tree(eio_req* req);
static int EIO_AfterTree(eio_req* req);
static void EIO_Tree(uv_work_t* req);
static void EIO_AfterTree(uv_work_t* req);

static Handle<Value> ParentCount(const Arguments& args);
static Handle<Value> Parent(const Arguments& args);
Expand Down
4 changes: 2 additions & 2 deletions include/reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class GitReference : public ObjectWrap {
static Handle<Value> New(const Arguments& args);

static Handle<Value> Lookup(const Arguments& args);
static void EIO_Lookup(eio_req* req);
static int EIO_AfterLookup(eio_req* req);
static void EIO_Lookup(uv_work_t* req);
static void EIO_AfterLookup(uv_work_t* req);

static Handle<Value> Oid(const Arguments& args);

Expand Down
12 changes: 6 additions & 6 deletions include/repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ class GitRepo : public ObjectWrap {
static Handle<Value> New(const Arguments& args);

static Handle<Value> Open(const Arguments& args);
static void EIO_Open(eio_req* req);
static int EIO_AfterOpen(eio_req* req);
static void EIO_Open(uv_work_t* req);
static void EIO_AfterOpen(uv_work_t* req);

static Handle<Value> Lookup(const Arguments& args);
static int EIO_Lookup(eio_req* req);
static int EIO_AfterLookup(eio_req* req);
static void EIO_Lookup(uv_work_t* req);
static void EIO_AfterLookup(uv_work_t* req);

static Handle<Value> Free(const Arguments& args);

static Handle<Value> Init(const Arguments& args);
static void EIO_Init(eio_req* req);
static int EIO_AfterInit(eio_req* req);
static void EIO_Init(uv_work_t* req);
static void EIO_AfterInit(uv_work_t* req);

private:
git_repository* repo;
Expand Down
4 changes: 2 additions & 2 deletions include/revwalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class GitRevWalk : public ObjectWrap {
static Handle<Value> Hide(const Arguments& args);

static Handle<Value> Next(const Arguments& args);
static void EIO_Next(eio_req* req);
static int EIO_AfterNext(eio_req* req);
static void EIO_Next(uv_work_t* req);
static void EIO_AfterNext(uv_work_t* req);

static Handle<Value> Sorting(const Arguments& args);
static Handle<Value> Free(const Arguments& args);
Expand Down
12 changes: 6 additions & 6 deletions include/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ class GitTree : public ObjectWrap {
static Handle<Value> New(const Arguments& args);

static Handle<Value> Lookup(const Arguments& args);
static int EIO_Lookup(eio_req *req);
static int EIO_AfterLookup(eio_req *req);
static void EIO_Lookup(uv_work_t *req);
static void EIO_AfterLookup(uv_work_t *req);
static Handle<Value> EntryCount(const Arguments& args);
static Handle<Value> EntryByIndex(const Arguments& args);
static void EIO_EntryByIndex(eio_req *req);
static int EIO_AfterEntryByIndex(eio_req *req);
static void EIO_EntryByIndex(uv_work_t *req);
static void EIO_AfterEntryByIndex(uv_work_t *req);
static Handle<Value> EntryByName(const Arguments& args);
static void EIO_EntryByName(eio_req *req);
static int EIO_AfterEntryByName(eio_req *req);
static void EIO_EntryByName(uv_work_t *req);
static void EIO_AfterEntryByName(uv_work_t *req);
static Handle<Value> SortEntries(const Arguments& args);
static Handle<Value> ClearEntries(const Arguments& args);

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"version": "0.0.6",
"homepage": "https://github.com/tbranyen/nodegit",
"author": "Tim Branyen <tim@tabdeveloper.com> (http://twitter.com/tbranyen)",
"contributors": [
{
"name": "Michael Robinson",
"email": "mike@pagesofinterest.net"
}
],
"main": "./lib/index.js",
"repository": {
"type": "git",
Expand Down
19 changes: 9 additions & 10 deletions src/blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void GitBlob::Initialize (Handle<v8::Object> target) {
HandleScope scope;

Local<FunctionTemplate> t = FunctionTemplate::New(New);

constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("Blob"));
Expand Down Expand Up @@ -105,23 +105,24 @@ Handle<Value> GitBlob::Lookup(const Arguments& args) {

blob->Ref();

eio_custom(EIO_Lookup, EIO_PRI_DEFAULT, EIO_AfterLookup, ar);
ev_ref(EV_DEFAULT_UC);
uv_work_t *req = new uv_work_t;
req->data = ar;
uv_queue_work(uv_default_loop(), req, EIO_Lookup, EIO_AfterLookup);

return scope.Close( Undefined() );
}

void GitBlob::EIO_Lookup(eio_req* req) {
void GitBlob::EIO_Lookup(uv_work_t* req) {
lookup_request* ar = static_cast<lookup_request* >(req->data);

git_oid oid = ar->oid->GetValue();
ar->err = ar->blob->Lookup(ar->repo->GetValue(), &oid);

}

int GitBlob::EIO_AfterLookup(eio_req* req) {
void GitBlob::EIO_AfterLookup(uv_work_t* req) {
lookup_request* ar = static_cast<lookup_request* >(req->data);
ev_unref(EV_DEFAULT_UC);
delete req;
ar->blob->Unref();

Local<Value> argv[1];
Expand All @@ -133,12 +134,10 @@ int GitBlob::EIO_AfterLookup(eio_req* req) {

if(try_catch.HasCaught())
FatalException(try_catch);

ar->callback.Dispose();

delete ar;

return 0;
}

Handle<Value> GitBlob::RawContent(const Arguments& args) {
Expand All @@ -151,7 +150,7 @@ Handle<Value> GitBlob::RawContent(const Arguments& args) {

int bufferLength = rawSize;
Buffer* buffer = Buffer::New(const_cast<char *>(contents.c_str()), bufferLength);

Local<Object> fastBuffer;
MAKE_FAST_BUFFER(buffer, fastBuffer);

Expand Down
34 changes: 17 additions & 17 deletions src/commit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void GitCommit::Initialize(Handle<Object> target) {
HandleScope scope;

Local<FunctionTemplate> t = FunctionTemplate::New(New);

constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("Commit"));
Expand Down Expand Up @@ -140,25 +140,27 @@ Handle<Value> GitCommit::Lookup(const Arguments& args) {

commit->Ref();

eio_custom(EIO_Lookup, EIO_PRI_DEFAULT, EIO_AfterLookup, ar);
ev_ref(EV_DEFAULT_UC);
uv_work_t *req = new uv_work_t;
req->data = ar;
uv_queue_work(uv_default_loop(), req, EIO_Lookup, EIO_AfterLookup);

return scope.Close( Undefined() );
}

void GitCommit::EIO_Lookup(eio_req *req) {
void GitCommit::EIO_Lookup(uv_work_t *req) {
lookup_request *ar = static_cast<lookup_request *>(req->data);

git_oid oid = ar->oid->GetValue();
ar->err = ar->commit->Lookup(ar->repo->GetValue(), &oid);

}

int GitCommit::EIO_AfterLookup(eio_req *req) {
void GitCommit::EIO_AfterLookup(uv_work_t *req) {
HandleScope scope;

lookup_request *ar = static_cast<lookup_request *>(req->data);
ev_unref(EV_DEFAULT_UC);
delete req;

ar->commit->Unref();

Handle<Value> argv[1];
Expand All @@ -171,20 +173,18 @@ int GitCommit::EIO_AfterLookup(eio_req *req) {
if(try_catch.HasCaught()) {
FatalException(try_catch);
}

ar->callback.Dispose();

delete ar;

return 0;
}

Handle<Value> GitCommit::Close(const Arguments& args) {
HandleScope scope;

GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());
commit->Close();

return scope.Close( Undefined() );
}

Expand All @@ -200,29 +200,29 @@ Handle<Value> GitCommit::Id(const Arguments& args) {
GitOid *oid = ObjectWrap::Unwrap<GitOid>(args[0]->ToObject());

oid->SetValue(*const_cast<git_oid *>(commit->Id()));

return scope.Close( Undefined() );
}

Handle<Value> GitCommit::MessageShort(const Arguments& args) {
HandleScope scope;

GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());

return scope.Close( String::New(commit->MessageShort()) );
}

Handle<Value> GitCommit::Message(const Arguments& args) {
HandleScope scope;

GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());

return scope.Close( String::New(commit->Message()) );
}

Handle<Value> GitCommit::Time(const Arguments& args) {
HandleScope scope;

GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());

return scope.Close( Integer::New(commit->Time()) );
Expand All @@ -232,7 +232,7 @@ Handle<Value> GitCommit::TimeOffset(const Arguments& args) {
HandleScope scope;

GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args.This());

return scope.Close( Integer::New(commit->TimeOffset()) );
}

Expand All @@ -248,7 +248,7 @@ Handle<Value> GitCommit::Committer(const Arguments& args) {
GitSig *sig = ObjectWrap::Unwrap<GitSig>(args[0]->ToObject());

sig->SetValue(const_cast<git_signature *>(commit->Committer()));

return scope.Close( Undefined() );
}

Expand All @@ -264,7 +264,7 @@ Handle<Value> GitCommit::Author(const Arguments& args) {
GitSig *sig = ObjectWrap::Unwrap<GitSig>(args[0]->ToObject());

sig->SetValue(const_cast<git_signature *>(commit->Author()));

return scope.Close( Undefined() );
}

Expand Down
17 changes: 8 additions & 9 deletions src/reference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void GitReference::Initialize(Handle<Object> target) {
HandleScope scope;

Local<FunctionTemplate> t = FunctionTemplate::New(New);

constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("Ref"));
Expand Down Expand Up @@ -87,13 +87,14 @@ Handle<Value> GitReference::Lookup(const Arguments& args) {

ref->Ref();

eio_custom(EIO_Lookup, EIO_PRI_DEFAULT, EIO_AfterLookup, ar);
ev_ref(EV_DEFAULT_UC);
uv_work_t *req = new uv_work_t;
req->data = ar;
uv_queue_work(uv_default_loop(), req, EIO_Lookup, EIO_AfterLookup);

return scope.Close( Undefined() );
}

void GitReference::EIO_Lookup(eio_req *req) {
void GitReference::EIO_Lookup(uv_work_t *req) {
lookup_request *ar = static_cast<lookup_request *>(req->data);

git_repository* repo = ar->repo->GetValue();
Expand All @@ -102,11 +103,11 @@ void GitReference::EIO_Lookup(eio_req *req) {

}

int GitReference::EIO_AfterLookup(eio_req *req) {
void GitReference::EIO_AfterLookup(uv_work_t *req) {
HandleScope scope;

lookup_request *ar = static_cast<lookup_request *>(req->data);
ev_unref(EV_DEFAULT_UC);
delete req;
ar->ref->Unref();

Local<Value> argv[1];
Expand All @@ -118,12 +119,10 @@ int GitReference::EIO_AfterLookup(eio_req *req) {

if(try_catch.HasCaught())
FatalException(try_catch);

ar->callback.Dispose();

delete ar;

return 0;
}

Handle<Value> GitReference::Oid(const Arguments& args) {
Expand Down
Loading