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
21 changes: 19 additions & 2 deletions generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@
}
},
"git_branch_upstream": {
"isAsync": false
"isAsync": false,
"return" : {
"isErrorCode": true
}
}
}
},
Expand Down Expand Up @@ -1092,7 +1095,11 @@
"shouldAlloc": true,
"functions": {
"git_oid_cpy": {
"ignore": true
"args": {
"out": {
"isReturn": true
}
}
},
"git_oid_fmt": {
"ignore": true
Expand Down Expand Up @@ -1601,6 +1608,16 @@
"git_status_byindex": {
"isAsync": false
},
"git_status_file": {
"args": {
"status_flags": {
"isReturn": true
},
"return": {
"isErrorCode": true
}
}
},
"git_status_foreach": {
"isAsync": true,
"return": {
Expand Down
2 changes: 1 addition & 1 deletion generate/scripts/generateNativeCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function generateNativeCode() {
defaultValue: require("../templates/filters/default_value"),
fieldsInfo: require("../templates/filters/fields_info"),
hasReturnType: require("../templates/filters/has_return_type"),
hasReturns: require("../templates/filters/has_returns"),
hasReturnValue: require("../templates/filters/has_return_value"),
isDoublePointer: require("../templates/filters/is_double_pointer"),
isFixedLengthString: require("../templates/filters/is_fixed_length_string"),
isOid: require("../templates/filters/is_oid"),
Expand Down
9 changes: 9 additions & 0 deletions generate/templates/filters/has_return_value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function(fn) {
if (fn.return
&& !fn.return.isErrorCode
&& fn.return.cType != "void") {
return true
}

return false;
};
15 changes: 0 additions & 15 deletions generate/templates/filters/has_returns.js

This file was deleted.

4 changes: 2 additions & 2 deletions generate/templates/partials/sync_function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
if (ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->GetValue() != NULL) {
{% endif %}

{%if .|hasReturns %}
{%if .|hasReturnValue %}
{{ return.cType }} result = {%endif%}{{ cFunctionName }}(
{%each args|argsInfo as arg %}
{%if arg.isReturn %}
Expand All @@ -53,7 +53,7 @@ from_{{ arg.name }}
{%endeach%}
);

{%if return.isErrorCode %}
{%if .|hasReturnValue |and return.isErrorCode %}
if (result != GIT_OK) {
{%each args|argsInfo as arg %}
{%if arg.shouldAlloc %}
Expand Down
4 changes: 4 additions & 0 deletions lib/oid.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Object.defineProperties(Oid.prototype, {
}
});

Oid.prototype.copy = function() {
return this.cpy(); // seriously???
};

Oid.prototype.inspect = function() {
return "[Oid " + this.allocfmt() + "]";
};
9 changes: 8 additions & 1 deletion lib/stash.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@ var Stash = NodeGit.Stash;
// Override Stash.foreach to eliminate the need to pass null payload
var foreach = Stash.foreach;
Stash.foreach = function(repo, callback) {
return foreach(repo, callback, null);
function wrappedCallback(index, message, oid) {
// We need to copy the OID since libgit2 types are getting cleaned up
// incorrectly right now in callbacks

return callback(index, message, oid.copy());
}

return foreach(repo, wrappedCallback, null);
};