Skip to content

Commit 2ad2adc

Browse files
committed
Merge pull request #535 from nodegit/update-some-methods
Fix some things missed by the generating scripts
2 parents c86625b + 6995bf4 commit 2ad2adc

File tree

7 files changed

+43
-21
lines changed

7 files changed

+43
-21
lines changed

generate/input/descriptor.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@
173173
}
174174
},
175175
"git_branch_upstream": {
176-
"isAsync": false
176+
"isAsync": false,
177+
"return" : {
178+
"isErrorCode": true
179+
}
177180
}
178181
}
179182
},
@@ -1092,7 +1095,11 @@
10921095
"shouldAlloc": true,
10931096
"functions": {
10941097
"git_oid_cpy": {
1095-
"ignore": true
1098+
"args": {
1099+
"out": {
1100+
"isReturn": true
1101+
}
1102+
}
10961103
},
10971104
"git_oid_fmt": {
10981105
"ignore": true
@@ -1601,6 +1608,16 @@
16011608
"git_status_byindex": {
16021609
"isAsync": false
16031610
},
1611+
"git_status_file": {
1612+
"args": {
1613+
"status_flags": {
1614+
"isReturn": true
1615+
},
1616+
"return": {
1617+
"isErrorCode": true
1618+
}
1619+
}
1620+
},
16041621
"git_status_foreach": {
16051622
"isAsync": true,
16061623
"return": {

generate/scripts/generateNativeCode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = function generateNativeCode() {
5656
defaultValue: require("../templates/filters/default_value"),
5757
fieldsInfo: require("../templates/filters/fields_info"),
5858
hasReturnType: require("../templates/filters/has_return_type"),
59-
hasReturns: require("../templates/filters/has_returns"),
59+
hasReturnValue: require("../templates/filters/has_return_value"),
6060
isDoublePointer: require("../templates/filters/is_double_pointer"),
6161
isFixedLengthString: require("../templates/filters/is_fixed_length_string"),
6262
isOid: require("../templates/filters/is_oid"),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = function(fn) {
2+
if (fn.return
3+
&& !fn.return.isErrorCode
4+
&& fn.return.cType != "void") {
5+
return true
6+
}
7+
8+
return false;
9+
};

generate/templates/filters/has_returns.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

generate/templates/partials/sync_function.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
3636
if (ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->GetValue() != NULL) {
3737
{% endif %}
3838

39-
{%if .|hasReturns %}
39+
{%if .|hasReturnValue %}
4040
{{ return.cType }} result = {%endif%}{{ cFunctionName }}(
4141
{%each args|argsInfo as arg %}
4242
{%if arg.isReturn %}
@@ -53,7 +53,7 @@ from_{{ arg.name }}
5353
{%endeach%}
5454
);
5555

56-
{%if return.isErrorCode %}
56+
{%if .|hasReturnValue |and return.isErrorCode %}
5757
if (result != GIT_OK) {
5858
{%each args|argsInfo as arg %}
5959
{%if arg.shouldAlloc %}

lib/oid.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Object.defineProperties(Oid.prototype, {
1414
}
1515
});
1616

17+
Oid.prototype.copy = function() {
18+
return this.cpy(); // seriously???
19+
};
20+
1721
Oid.prototype.inspect = function() {
1822
return "[Oid " + this.allocfmt() + "]";
1923
};

lib/stash.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@ var Stash = NodeGit.Stash;
55
// Override Stash.foreach to eliminate the need to pass null payload
66
var foreach = Stash.foreach;
77
Stash.foreach = function(repo, callback) {
8-
return foreach(repo, callback, null);
8+
function wrappedCallback(index, message, oid) {
9+
// We need to copy the OID since libgit2 types are getting cleaned up
10+
// incorrectly right now in callbacks
11+
12+
return callback(index, message, oid.copy());
13+
}
14+
15+
return foreach(repo, wrappedCallback, null);
916
};

0 commit comments

Comments
 (0)