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
14 changes: 14 additions & 0 deletions generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -4187,6 +4187,16 @@
"singletonCppClassName": "GitRepository"
},
"functions": {
"git_tree_create_updated": {
"args": {
"updates": {
"cType": "git_tree_update *",
"cppClassName": "Array",
"jsClassName": "Array",
"arrayElementCppClassName": "GitTreeUpdate"
}
}
},
"git_tree_entry_byid": {
"return": {
"ownedByThis": true
Expand Down Expand Up @@ -4361,6 +4371,10 @@
"../include/git_buf_converter.h"
]
},
"tree_update": {
"hasConstructor": true,
"ignoreInit": true
},
"writestream": {
"cType": "git_writestream",
"needsForwardDeclaration": false,
Expand Down
4 changes: 2 additions & 2 deletions generate/templates/partials/convert_from_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
{%elsif cppClassName == 'Array'%}

v8::Local<v8::Array> tmp_{{ name }} = v8::Local<v8::Array>::Cast(info[{{ jsArg }}]);
from_{{ name }} = ({{ cType }})malloc(tmp_{{ name }}->Length() * sizeof({{ cType|replace '**' '*' }}));
from_{{ name }} = ({{ cType }})malloc(tmp_{{ name }}->Length() * sizeof({{ cType|unPointer }}));
for (unsigned int i = 0; i < tmp_{{ name }}->Length(); i++) {
{%--
// FIXME: should recursively call convertFromv8.
--%}
from_{{ name }}[i] = Nan::ObjectWrap::Unwrap<{{ arrayElementCppClassName }}>(Nan::To<v8::Object>(Nan::Get(tmp_{{ name }}, Nan::New(static_cast<double>(i))).ToLocalChecked()).ToLocalChecked())->GetValue();
from_{{ name }}[i] = {%if not cType|isDoublePointer %}*{%endif%}Nan::ObjectWrap::Unwrap<{{ arrayElementCppClassName }}>(Nan::To<v8::Object>(Nan::Get(tmp_{{ name }}, Nan::New(static_cast<double>(i))).ToLocalChecked()).ToLocalChecked())->GetValue();
}
{%elsif cppClassName == 'Function'%}
{%elsif cppClassName == 'Buffer'%}
Expand Down
18 changes: 18 additions & 0 deletions test/tests/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ describe("Tree", function() {
}).done(done);
});

it("updates a tree", function () {
var repo = this.existingRepo;
var update = new NodeGit.TreeUpdate();
update.action = NodeGit.Tree.UPDATE.REMOVE;
update.path = "README.md";
return this.commit.getTree().then(function(tree) {
return tree.createUpdated(repo, 1, [update]);
})
.then(function(treeOid) {
return repo.getTree(treeOid);
})
.then(function(updatedTree) {
assert.throws(function () {
updatedTree.entryByName("README.md");
});
});
});

it("walks its entries and returns the same entries on both progress and end",
function() {
var repo = this.repository;
Expand Down