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
15 changes: 14 additions & 1 deletion generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,20 @@
"graph": {
"functions": {
"git_graph_ahead_behind": {
"ignore": true
"args": {
"ahead": {
"shouldAlloc": true,
"isReturn": true
},
"behind": {
"shouldAlloc": true,
"isReturn": true
}
},
"isAsync": true,
"return": {
"isErrorCode": true
}
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions generate/templates/filters/returns_info.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var isPointer = require("./is_pointer");

module.exports = function(fn, argReturnsOnly, isAsync) {
var result = [];
var args = fn.args || [];
Expand All @@ -11,6 +13,10 @@ module.exports = function(fn, argReturnsOnly, isAsync) {

return_info.parsedName = isAsync ? "baton->" + return_info.name : return_info.name;
return_info.isCppClassIntType = ~['Uint32', 'Int32'].indexOf(return_info.cppClassName);
return_info.needsDereference
= isAsync &&
return_info.cppClassName == "Number" &&
isPointer(return_info.cType);
return_info.parsedClassName = (return_info.cppClassName || '').toLowerCase() + "_t";
return_info.returnNameOrName = return_info.returnName || return_info.name;
return_info.jsOrCppClassName = return_info.jsClassName || return_info.cppClassName;
Expand Down
2 changes: 1 addition & 1 deletion generate/templates/partials/convert_to_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{% if isCppClassIntType %}
to = NanNew<{{ cppClassName }}>(({{ parsedClassName }}){{= parsedName =}});
{% else %}
to = NanNew<{{ cppClassName }}>({{= parsedName =}});
to = NanNew<{{ cppClassName }}>({% if needsDereference %}*{% endif %}{{= parsedName =}});
{% endif %}

{% elsif cppClassName == 'External' %}
Expand Down
31 changes: 31 additions & 0 deletions test/tests/graph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);

describe("Graph", function() {
var NodeGit = require("../../");
var Repository = NodeGit.Repository;
var Graph = NodeGit.Graph;

var reposPath = local("../repos/workdir");

beforeEach(function() {
var test = this;

return Repository.open(reposPath)
.then(function(repository) {
test.repository = repository;
});
});

it("can get commits ahead/behind for 2 different commits", function() {
return Graph.aheadBehind(
this.repository,
"32789a79e71fbc9e04d3eff7425e1771eb595150",
"1729c73906bb8467f4095c2f4044083016b4dfde")
.then(function(result) {
assert.equal(result.ahead, 1);
assert.equal(result.behind, 1);
});
});
});