From 62f5be606b11cca87a856a3a6164990be5aa6ffd Mon Sep 17 00:00:00 2001 From: Kurt Berglund Date: Wed, 26 Jul 2017 12:28:37 -0700 Subject: [PATCH 01/11] Change tree_entry to not be selfFreeing The libgit2 use cases all are instances where the git_tree_entry is owned by the object that returned it. As such this marks the tree_entry as not self freeing. And also updates functions returning one of these to set ownedByThis. This will keep the owning object alive should someone have a reference to a tree_entry. The git_treebuilder_insert method needed to be marked as not async in order to have access to the owning object. This seems like a case where the generator could be improved should this method need to be async. --- generate/input/descriptor.json | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index d33298c30..256987e8c 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -2562,6 +2562,19 @@ "git_treebuilder_filter": { "ignore": true }, + "git_treebuilder_get": { + "return": { + "ownedByThis": true + } + }, + "git_treebuilder_insert": { + "isAsync": false, + "args": { + "out": { + "ownedByThis": true + } + } + }, "git_treebuilder_write": { "args": { "id": { @@ -2582,7 +2595,7 @@ } }, "tree_entry": { - "selfFreeing": true, + "selfFreeing": false, "dupFunction": "git_tree_entry_dup", "freeFunctionName": "git_tree_entry_free", "functions": { From fb26b08a7ee30f9347c5b6de767c128e8ffe4933 Mon Sep 17 00:00:00 2001 From: Kurt Berglund Date: Wed, 26 Jul 2017 14:04:05 -0700 Subject: [PATCH 02/11] Remove leak test from tree_entry since it's no longer selfFreeing --- test/tests/tree_entry.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index 13093fdaa..16bb6b3fd 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -2,8 +2,6 @@ var assert = require("assert"); var path = require("path"); var local = path.join.bind(path, __dirname); -var leakTest = require("../utils/leak_test"); - describe("TreeEntry", function() { var NodeGit = require("../../"); var Repository = NodeGit.Repository; @@ -177,15 +175,4 @@ describe("TreeEntry", function() { assert.equal(object.isTree(), true); }); }); - - it("does not leak", function() { - var test = this; - - return leakTest(NodeGit.TreeEntry, function() { - return test.commit.getTree() - .then(function(tree) { - return tree.entryByPath("example"); - }); - }); - }); }); From f1408478c89cf5986947d08ce1575c40267bbf59 Mon Sep 17 00:00:00 2001 From: kurtb Date: Tue, 15 Aug 2017 18:03:10 -0700 Subject: [PATCH 03/11] Pull request feedback Fix up ownership on all tree_entry related calls --- generate/input/descriptor.json | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index 256987e8c..bccbbb841 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -2529,19 +2529,22 @@ "functions": { "git_tree_entry_byid": { "return": { - "ownedByThis": true + "ownedByThis": true, + "selfFreeing": false } }, "git_tree_entry_byindex": { "jsFunctionName": "_entryByIndex", "return": { - "ownedByThis": true + "ownedByThis": true, + "selfFreeing": false } }, "git_tree_entry_byname": { "jsFunctionName": "_entryByName", "return": { - "ownedByThis": true + "ownedByThis": true, + "selfFreeing": false } }, "git_tree_entrycount": { @@ -2564,6 +2567,7 @@ }, "git_treebuilder_get": { "return": { + "selfFreeing": false, "ownedByThis": true } }, @@ -2571,6 +2575,7 @@ "isAsync": false, "args": { "out": { + "selfFreeing": false, "ownedByThis": true } } @@ -2595,7 +2600,7 @@ } }, "tree_entry": { - "selfFreeing": false, + "selfFreeing": true, "dupFunction": "git_tree_entry_dup", "freeFunctionName": "git_tree_entry_free", "functions": { From 67fc71da5ec9c5c2689f8825a707dbacab5e9cff Mon Sep 17 00:00:00 2001 From: Kurt Berglund Date: Wed, 16 Aug 2017 15:52:39 -0700 Subject: [PATCH 04/11] Test for treebuilder insert memory management --- test/tests/tree_entry.js | 13 +++++++++++++ test/tests/treebuilder.js | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index 16bb6b3fd..13093fdaa 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -2,6 +2,8 @@ var assert = require("assert"); var path = require("path"); var local = path.join.bind(path, __dirname); +var leakTest = require("../utils/leak_test"); + describe("TreeEntry", function() { var NodeGit = require("../../"); var Repository = NodeGit.Repository; @@ -175,4 +177,15 @@ describe("TreeEntry", function() { assert.equal(object.isTree(), true); }); }); + + it("does not leak", function() { + var test = this; + + return leakTest(NodeGit.TreeEntry, function() { + return test.commit.getTree() + .then(function(tree) { + return tree.entryByPath("example"); + }); + }); + }); }); diff --git a/test/tests/treebuilder.js b/test/tests/treebuilder.js index 5e1ce6263..c7ef01f43 100644 --- a/test/tests/treebuilder.js +++ b/test/tests/treebuilder.js @@ -5,10 +5,14 @@ var promisify = require("promisify-node"); var readDir = promisify(fs.readdir); var local = path.join.bind(path, __dirname); +var leakTest = require("../utils/leak_test"); + describe("TreeBuilder", function(){ var Git = require("../../"); var reposPath = local("../repos/workdir"); + var oid = "111dd657329797f6165f52f5085f61ac976dcf04"; + //setup test repo each test beforeEach(function() { var test = this; @@ -76,4 +80,19 @@ describe("TreeBuilder", function(){ return Git.Tree.lookup(test.repo, newTreeEntry.oid()); }); }); + + it("does not leak inserts", function() { + var test = this; + + // The underlying C++ git_tree_entry is owned by the treebuilder that + // creates it. But since git_tree_entry is duplicable the generator will + // duplicate it and mark it as self freeing. + // Validate this with the leakTest. + return leakTest(Git.TreeEntry, function() { + return Git.Treebuilder.create(test.repo, null) + .then(function(builder) { + return builder.insert("test", oid, Git.TreeEntry.FILEMODE.BLOB); + }); + }); + }); }); From 20d40d6587cc3ff064201806cd676190dcf451f2 Mon Sep 17 00:00:00 2001 From: Tyler Wanek Date: Wed, 16 Aug 2017 17:58:03 -0700 Subject: [PATCH 05/11] Bump to 0.20.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 268d00f86..9d02e56ad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegit", "description": "Node.js libgit2 asynchronous native bindings", - "version": "0.20.0", + "version": "0.20.1", "homepage": "http://nodegit.org", "keywords": [ "libgit2", From b9831415618b84e25ed053a86bbadcd5ae86da78 Mon Sep 17 00:00:00 2001 From: Tyler Wanek Date: Mon, 11 Sep 2017 16:50:09 -0700 Subject: [PATCH 06/11] 8.4.0 currently breaks builds, locking to 8.3.0 temporarily --- .travis.yml | 4 ++-- appveyor.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b317c86e..8d159873a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ sudo: false env: matrix: - - export NODE_VERSION="stable" TARGET_ARCH="x64" + - export NODE_VERSION="8.3.0" TARGET_ARCH="x64" - export NODE_VERSION="7.4" TARGET_ARCH="x64" - export NODE_VERSION="6.5" TARGET_ARCH="x64" @@ -21,7 +21,7 @@ matrix: fast_finish: true include: - os: linux - env: export NODE_VERSION="stable" TARGET_ARCH="ia32" + env: export NODE_VERSION="8.3.0" TARGET_ARCH="ia32" - os: linux env: export NODE_VERSION="7.4" TARGET_ARCH="ia32" - os: linux diff --git a/appveyor.yml b/appveyor.yml index c25c50ebb..7d4463df7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,7 +27,7 @@ environment: GYP_MSVS_VERSION: 2013 matrix: # Node.js - - nodejs_version: "stable" + - nodejs_version: "8.3.0" - nodejs_version: "7" - nodejs_version: "6" From 572f573a9a7d13b263e4d72d83ab8a45adc3635f Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Wed, 23 Aug 2017 19:07:43 -0700 Subject: [PATCH 07/11] Fixed filter tests to work with massive buffer --- generate/input/descriptor.json | 3 +- generate/templates/partials/convert_to_v8.cc | 4 + test/tests/filter.js | 80 +++++++++++++++++++- 3 files changed, 82 insertions(+), 5 deletions(-) diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index 0f271c290..92396ace3 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -326,7 +326,8 @@ "buffer": { "isReturn": true, "isSelf": false, - "shouldAlloc": true + "shouldAlloc": true, + "doNotConvert": true }, "data": { "cppClassName": "Buffer", diff --git a/generate/templates/partials/convert_to_v8.cc b/generate/templates/partials/convert_to_v8.cc index bfe268f3e..3d3bdf834 100644 --- a/generate/templates/partials/convert_to_v8.cc +++ b/generate/templates/partials/convert_to_v8.cc @@ -43,12 +43,16 @@ to = tmpArray; {% elsif cppClassName == 'GitBuf' %} + {% if doNotConvert %} + to = Nan::Null(); + {% else %} if ({{= parsedName =}}) { to = Nan::New({{= parsedName =}}->ptr, {{= parsedName = }}->size).ToLocalChecked(); } else { to = Nan::Null(); } + {% endif %} {% else %} {% if copy %} if ({{= parsedName =}} != NULL) { diff --git a/test/tests/filter.js b/test/tests/filter.js index 1db1c9ecb..748f4a95e 100644 --- a/test/tests/filter.js +++ b/test/tests/filter.js @@ -389,6 +389,19 @@ describe("Filter", function() { }); describe("Apply", function() { + before(function() { + var test = this; + return fse.readFile(readmePath, "utf8") + .then((function(content) { + test.originalReadmeContent = content; + })); + }); + + afterEach(function() { + this.timeout(15000); + return fse.writeFile(readmePath, this.originalReadmeContent); + }); + var message = "some new fancy filter"; var length = message.length; var tempBuffer = new Buffer(message, "utf-8"); @@ -509,7 +522,7 @@ describe("Filter", function() { return Registry.register(filterName, { apply: function(to, from, source) { return to.set(tempBuffer, length) - .then(function(buf) { + .then(function() { return NodeGit.Error.CODE.OK; }); }, @@ -544,13 +557,72 @@ describe("Filter", function() { }); }); + it("applies the massive filter data on checkout", function() { + this.timeout(350000); + var test = this; + var largeBuffer = Buffer.alloc(300000000, "a"); + + return Registry.register(filterName, { + apply: function(to, from, source) { + return to.set(largeBuffer, 300000000) + .then(function() { + return NodeGit.Error.CODE.OK; + }); + }, + check: function(src, attr) { + return NodeGit.Error.CODE.OK; + } + }, 0) + .then(function(result) { + assert.strictEqual(result, 0); + }) + .then(function() { + var fd = fse.openSync(readmePath, "r"); + var readBuf = Buffer.alloc(300000000); + var readLength = fse.readSync( + fd, + readBuf, + 0, + 300000000, + 0 + ); + fse.closeSync(fd); + + assert.notStrictEqual(readLength, 300000000); + fse.writeFileSync(readmePath, "whoa", "utf8"); + + var opts = { + checkoutStrategy: Checkout.STRATEGY.FORCE, + paths: ["README.md"] + }; + return Checkout.head(test.repository, opts); + }) + .then(function() { + var fd = fse.openSync(readmePath, "r"); + var readBuf = Buffer.alloc(300000000); + var readLength = fse.readSync( + fd, + readBuf, + 0, + 300000000, + 0 + ); + fse.closeSync(fd); + + assert.strictEqual( + readLength, + 300000000 + ); + }); + }); + it("applies the filter data on checkout with gc", function() { var test = this; return Registry.register(filterName, { apply: function(to, from, source) { return to.set(tempBuffer, length) - .then(function(buf) { + .then(function() { return NodeGit.Error.CODE.OK; }); }, @@ -592,7 +664,7 @@ describe("Filter", function() { return Registry.register(filterName, { apply: function(to, from, source) { return to.set(tempBuffer, length) - .then(function(buf) { + .then(function() { return NodeGit.Error.CODE.OK; }); }, @@ -649,7 +721,7 @@ describe("Filter", function() { return Registry.register(filterName, { apply: function(to, from, source) { return to.set(tempBuffer, length) - .then(function(buf) { + .then(function() { return NodeGit.Error.CODE.OK; }); }, From a7f61ee1f4b90729f9fda7a804a03365fce41e1a Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Wed, 23 Aug 2017 19:27:02 -0700 Subject: [PATCH 08/11] Added variable for size and allocUnsafe for large allocations --- test/tests/filter.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/tests/filter.js b/test/tests/filter.js index 748f4a95e..b2017af02 100644 --- a/test/tests/filter.js +++ b/test/tests/filter.js @@ -405,6 +405,7 @@ describe("Filter", function() { var message = "some new fancy filter"; var length = message.length; var tempBuffer = new Buffer(message, "utf-8"); + var largeBufferSize = 300000000; it("should not apply when check returns GIT_PASSTHROUGH", function(){ var test = this; @@ -560,11 +561,11 @@ describe("Filter", function() { it("applies the massive filter data on checkout", function() { this.timeout(350000); var test = this; - var largeBuffer = Buffer.alloc(300000000, "a"); + var largeBuffer = Buffer.alloc(largeBufferSize, "a"); return Registry.register(filterName, { apply: function(to, from, source) { - return to.set(largeBuffer, 300000000) + return to.set(largeBuffer, largeBufferSize) .then(function() { return NodeGit.Error.CODE.OK; }); @@ -578,17 +579,17 @@ describe("Filter", function() { }) .then(function() { var fd = fse.openSync(readmePath, "r"); - var readBuf = Buffer.alloc(300000000); + var readBuf = Buffer.allocUnsafe(largeBufferSize); var readLength = fse.readSync( fd, readBuf, 0, - 300000000, + largeBufferSize, 0 ); fse.closeSync(fd); - assert.notStrictEqual(readLength, 300000000); + assert.notStrictEqual(readLength, largeBufferSize); fse.writeFileSync(readmePath, "whoa", "utf8"); var opts = { @@ -599,19 +600,19 @@ describe("Filter", function() { }) .then(function() { var fd = fse.openSync(readmePath, "r"); - var readBuf = Buffer.alloc(300000000); + var readBuf = Buffer.allocUnsafe(300000000); var readLength = fse.readSync( fd, readBuf, 0, - 300000000, + largeBufferSize, 0 ); fse.closeSync(fd); assert.strictEqual( readLength, - 300000000 + largeBufferSize ); }); }); From 1cb96b490bdd16c12419cf6930164ea8c814aa65 Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Wed, 6 Sep 2017 15:42:49 -0700 Subject: [PATCH 09/11] Updated methods to be shouldAlloc when an allocated buffer is needed --- generate/input/descriptor.json | 88 ++++++++++++++++--- generate/templates/partials/async_function.cc | 14 +-- test/tests/filter.js | 4 +- 3 files changed, 83 insertions(+), 23 deletions(-) diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index 92396ace3..c7ceafe73 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -173,7 +173,8 @@ "out": { "isReturn": true, "cppClassName": "GitBuf", - "jsClassName": "Buffer" + "jsClassName": "Buffer", + "shouldAlloc": true }, "blob": { "cppClassName": "GitBlob", @@ -259,7 +260,8 @@ "isReturn": true, "cppClassName": "GitBuf", "jsClassName": "Buffer", - "cType": "git_buf *" + "cType": "git_buf *", + "shouldAlloc": true }, "repo": { "cppClassName": "GitRepository", @@ -307,9 +309,9 @@ "jsFunctionName": "grow", "args": { "buffer": { - "isReturn": true, - "isSelf": false, - "shouldAlloc": true + "isReturn": false, + "isSelf": true, + "shouldAlloc": false } }, "return": { @@ -324,10 +326,9 @@ "jsFunctionName": "set", "args": { "buffer": { - "isReturn": true, - "isSelf": false, - "shouldAlloc": true, - "doNotConvert": true + "isReturn": false, + "isSelf": true, + "shouldAlloc": false }, "data": { "cppClassName": "Buffer", @@ -538,6 +539,19 @@ "return": { "ownedByThis": true } + }, + "git_commit_header_field": { + "isAsync": true, + "args": { + "out": { + "isReturn": true, + "isSelf": false, + "shouldAlloc": true + } + }, + "return": { + "isErrorCode": true + } } } }, @@ -602,6 +616,12 @@ }, "git_config_get_string_buf": { "isAsync": true, + "args": { + "out": { + "isReturn": true, + "shouldAlloc": true + } + }, "return": { "isErrorCode": true } @@ -674,6 +694,19 @@ "return": { "isErrorCode": true } + }, + "git_config_find_programdata": { + "isAsync": true, + "return": { + "isErrorCode": true + }, + "args": { + "out": { + "isReturn": true, + "isSelf": false, + "shouldAlloc": true + } + } } }, "dependencies": [ @@ -883,6 +916,19 @@ "git_diff_status_char": { "ignore": true }, + "git_diff_to_buf": { + "isAsync": true, + "return": { + "isErrorCode": true + }, + "args": { + "out": { + "isReturn": true, + "isSelf": false, + "shouldAlloc": true + } + } + }, "git_diff_tree_to_index": { "args": { "old_tree": { @@ -1969,7 +2015,9 @@ "isAsync": true, "args": { "out": { - "isReturn": true + "isReturn": true, + "shouldAlloc": true, + "isSelf": false }, "remote": { "isSelf": true @@ -2116,6 +2164,13 @@ "isAsync": true, "return": { "isErrorCode": true + }, + "args": { + "out": { + "isReturn": true, + "isSelf": false, + "shouldAlloc": true + } } }, "git_repository_init_init_options": { @@ -2479,6 +2534,19 @@ "isErrorCode": true } }, + "git_submodule_resolve_url": { + "isAsync": true, + "args": { + "out": { + "isReturn": true, + "shouldAlloc": true, + "isSelf": false + } + }, + "return": { + "isErrorCode": true + } + }, "git_submodule_update": { "isAsync": true, "args": { diff --git a/generate/templates/partials/async_function.cc b/generate/templates/partials/async_function.cc index 20813136d..191b8f20f 100644 --- a/generate/templates/partials/async_function.cc +++ b/generate/templates/partials/async_function.cc @@ -15,15 +15,6 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) { {%if arg.globalPayload %} {{ cppFunctionName }}_globalPayload* globalPayload = new {{ cppFunctionName }}_globalPayload; {%endif%} - {%if arg.cppClassName == "GitBuf" %} - {%if cppFunctionName == "Set"%} - baton->{{arg.name}} = Nan::ObjectWrap::Unwrap<{{ arg.cppClassName }}>(info.This())->GetValue(); - {%else%} - baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }})); - baton->{{arg.name}}->ptr = NULL; - baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0; - {%endif%} - {%endif%} {%endeach%} {%each args|argsInfo as arg %} @@ -61,9 +52,10 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) { {%endif%} {%endif%} {%elsif arg.shouldAlloc %} + baton->{{arg.name}} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }})); {%if arg.cppClassName == "GitBuf" %} - {%else%} - baton->{{ arg.name }} = ({{ arg.cType }})malloc(sizeof({{ arg.cType|replace '*' '' }})); + baton->{{arg.name}}->ptr = NULL; + baton->{{arg.name}}->size = baton->{{arg.name}}->asize = 0; {%endif%} {%endif%} {%endeach%} diff --git a/test/tests/filter.js b/test/tests/filter.js index b2017af02..b8e013464 100644 --- a/test/tests/filter.js +++ b/test/tests/filter.js @@ -405,7 +405,7 @@ describe("Filter", function() { var message = "some new fancy filter"; var length = message.length; var tempBuffer = new Buffer(message, "utf-8"); - var largeBufferSize = 300000000; + var largeBufferSize = 500000000; it("should not apply when check returns GIT_PASSTHROUGH", function(){ var test = this; @@ -600,7 +600,7 @@ describe("Filter", function() { }) .then(function() { var fd = fse.openSync(readmePath, "r"); - var readBuf = Buffer.allocUnsafe(300000000); + var readBuf = Buffer.allocUnsafe(largeBufferSize); var readLength = fse.readSync( fd, readBuf, From 658f5b7af814d57069fc16ebfa623b3d3dbe7daf Mon Sep 17 00:00:00 2001 From: Tyler Wanek Date: Wed, 13 Sep 2017 08:19:06 -0700 Subject: [PATCH 10/11] 32 bit CI does not like 500 meg buffers. --- test/tests/filter.js | 104 ++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/test/tests/filter.js b/test/tests/filter.js index b8e013464..021de6426 100644 --- a/test/tests/filter.js +++ b/test/tests/filter.js @@ -83,7 +83,7 @@ describe("Filter", function() { .then(function(emptyRepo) { test.emptyRepo = emptyRepo; return fse.writeFile( - path.join(reposPath, ".gitattributes"), + path.join(reposPath, ".gitattributes"), "*.md filter=" + filterName + " -text", { encoding: "utf-8" } ); @@ -153,7 +153,7 @@ describe("Filter", function() { it("cannot unregister the filter twice", function() { return Registry.unregister(filterName) - .then(function(result) { + .then(function(result) { assert.strictEqual(result, NodeGit.Error.CODE.OK); return Registry.unregister(filterName); }) @@ -185,7 +185,7 @@ describe("Filter", function() { }) .then(function() { return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout" ); }) @@ -219,7 +219,7 @@ describe("Filter", function() { global.gc(); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout" ); }) @@ -253,7 +253,7 @@ describe("Filter", function() { }) .then(function() { return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout" ); }) @@ -289,7 +289,7 @@ describe("Filter", function() { .then(function(result) { assert.strictEqual(result, NodeGit.Error.CODE.OK); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout", { encoding: "utf-8" } ); @@ -309,7 +309,7 @@ describe("Filter", function() { assert.strictEqual(shutdown, true); }); }); - + it("filter successfully shuts down on garbage collect", function() { var test = this; var shutdown = false; @@ -325,7 +325,7 @@ describe("Filter", function() { .then(function(result) { assert.strictEqual(result, NodeGit.Error.CODE.OK); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout", { encoding: "utf-8" } ); @@ -363,7 +363,7 @@ describe("Filter", function() { .then(function(result) { assert.strictEqual(result, NodeGit.Error.CODE.OK); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout", { encoding: "utf-8" } ); @@ -389,7 +389,7 @@ describe("Filter", function() { }); describe("Apply", function() { - before(function() { + before(function() { var test = this; return fse.readFile(readmePath, "utf8") .then((function(content) { @@ -410,7 +410,7 @@ describe("Filter", function() { it("should not apply when check returns GIT_PASSTHROUGH", function(){ var test = this; var applied = false; - + return Registry.register(filterName, { apply: function() { applied = true; @@ -422,7 +422,7 @@ describe("Filter", function() { .then(function(result) { assert.strictEqual(result, NodeGit.Error.CODE.OK); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout", { encoding: "utf-8" } ); @@ -454,8 +454,8 @@ describe("Filter", function() { .then(function(result) { assert.strictEqual(result, NodeGit.Error.CODE.OK); return fse.writeFile( - packageJsonPath, - "Changing content to trigger checkout", + packageJsonPath, + "Changing content to trigger checkout", { encoding: "utf-8" } ); }) @@ -490,13 +490,13 @@ describe("Filter", function() { }) .then(function() { var readmeContent = fse.readFileSync( - packageJsonPath, + packageJsonPath, "utf-8" ); assert.notStrictEqual(readmeContent, message); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout" ); }) @@ -509,7 +509,7 @@ describe("Filter", function() { }) .then(function() { var postInitializeReadmeContents = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); @@ -536,7 +536,7 @@ describe("Filter", function() { }) .then(function() { var readmeContent = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); assert.notStrictEqual(readmeContent, message); @@ -550,7 +550,7 @@ describe("Filter", function() { }) .then(function() { var postInitializeReadmeContents = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); @@ -558,22 +558,25 @@ describe("Filter", function() { }); }); - it("applies the massive filter data on checkout", function() { - this.timeout(350000); - var test = this; - var largeBuffer = Buffer.alloc(largeBufferSize, "a"); - - return Registry.register(filterName, { - apply: function(to, from, source) { - return to.set(largeBuffer, largeBufferSize) + // this test is useless on 32 bit CI, because we cannot construct + // a buffer big enough to test anything of significance :)... + if (process.arch === "x64") { + it("applies the massive filter data on checkout", function() { + this.timeout(350000); + var test = this; + var largeBuffer = Buffer.alloc(largeBufferSize, "a"); + + return Registry.register(filterName, { + apply: function(to, from, source) { + return to.set(largeBuffer, largeBufferSize) .then(function() { return NodeGit.Error.CODE.OK; }); - }, - check: function(src, attr) { - return NodeGit.Error.CODE.OK; - } - }, 0) + }, + check: function(src, attr) { + return NodeGit.Error.CODE.OK; + } + }, 0) .then(function(result) { assert.strictEqual(result, 0); }) @@ -615,7 +618,8 @@ describe("Filter", function() { largeBufferSize ); }); - }); + }); + } it("applies the filter data on checkout with gc", function() { var test = this; @@ -636,7 +640,7 @@ describe("Filter", function() { }) .then(function() { var readmeContent = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); assert.notStrictEqual(readmeContent, message); @@ -651,7 +655,7 @@ describe("Filter", function() { }) .then(function() { var postInitializeReadmeContents = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); @@ -670,7 +674,7 @@ describe("Filter", function() { }); }, check: function(src, attr) { - return src.path() === "README.md" ? + return src.path() === "README.md" ? 0 : NodeGit.Error.CODE.PASSTHROUGH; }, cleanup: function() {} @@ -680,14 +684,14 @@ describe("Filter", function() { }) .then(function() { var readmeContent = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); assert.notStrictEqual(readmeContent, "testing commit contents"); }) .then(function() { - return commitFile(test.repository, "README.md", - "testing commit contents", + return commitFile(test.repository, "README.md", + "testing commit contents", "test commit" ); }) @@ -696,7 +700,7 @@ describe("Filter", function() { }) .then(function(commit) { var postInitializeReadmeContents = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); @@ -738,14 +742,14 @@ describe("Filter", function() { }) .then(function() { var readmeContent = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); assert.notStrictEqual(readmeContent, "testing commit contents"); }) .then(function() { - return commitFile(test.repository, "README.md", - "testing commit contents", + return commitFile(test.repository, "README.md", + "testing commit contents", "test commit" ); }) @@ -755,7 +759,7 @@ describe("Filter", function() { }) .then(function(commit) { var postInitializeReadmeContents = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); @@ -806,7 +810,7 @@ describe("Filter", function() { assert.notEqual(packageContent, ""); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout", { encoding: "utf-8" } ); @@ -845,14 +849,14 @@ describe("Filter", function() { }) .then(function() { var packageContent = fse.readFileSync( - packageJsonPath, + packageJsonPath, "utf-8" ); assert.notEqual(packageContent, ""); global.gc(); return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout", { encoding: "utf-8" } ); @@ -892,11 +896,11 @@ describe("Filter", function() { }) .then(function() { var packageContent = fse.readFileSync( - packageJsonPath, + packageJsonPath, "utf-8" ); var readmeContent = fse.readFileSync( - readmePath, + readmePath, "utf-8" ); @@ -905,7 +909,7 @@ describe("Filter", function() { }) .then(function() { return fse.writeFile( - packageJsonPath, + packageJsonPath, "Changing content to trigger checkout", { encoding: "utf-8" } ); From bf1ff40c33ba432d39f5dd12716cb0f2f8a3d8e7 Mon Sep 17 00:00:00 2001 From: Tyler Wanek Date: Wed, 13 Sep 2017 14:28:26 -0700 Subject: [PATCH 11/11] Bump to 0.20.2 --- CHANGELOG.md | 8 ++++++++ README.md | 1 - package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d8fdc98a..b01501353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## v0.20.2 [(2017-08-16)](https://github.com/nodegit/nodegit/releases/tag/v0.20.2) + +[Full Changelog](https://github.com/nodegit/nodegit/compare/v0.20.0...v0.20.2) + +#### Summary of changes outside of libgit2 bump: + - [Fixed an issue where large buffer allocations in filters (> 256MB) causes a segfault #1368](https://github.com/nodegit/nodegit/pull/1368) + - [Fix git_tree_entry double free #1332](https://github.com/nodegit/nodegit/pull/1332) + ## v0.20.0 [(2017-08-16)](https://github.com/nodegit/nodegit/releases/tag/v0.20.0) [Full Changelog](https://github.com/nodegit/nodegit/compare/v0.19.0...v0.20.0) diff --git a/README.md b/README.md index 3a9ee8b80..52f2a26f8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ NodeGit -**Stable (libgit2#master): 0.20.0** **Stable (libgit2@v0.26.0): 0.26.0** ## Have a problem? Come chat with us! ## diff --git a/package.json b/package.json index 9d02e56ad..85a78848a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegit", "description": "Node.js libgit2 asynchronous native bindings", - "version": "0.20.1", + "version": "0.20.2", "homepage": "http://nodegit.org", "keywords": [ "libgit2",