Commit 609332f9 authored by Roy Marples's avatar Roy Marples

Merge remote-tracking branch 'upstream/master' into fix-clang

parents e5a75157 c737c25c
......@@ -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
......
# Change Log
## <a name="v0-20-0" href="#v0-20-0">v0.20.0</a> [(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)
#### Summary of changes outside of libgit2 bump:
- [BREAKING: Added blob methods and converted to async #1327](https://github.com/nodegit/nodegit/pull/1327)
- [BREAKING: Convert sync methods to async methods #1348](https://github.com/nodegit/nodegit/pull/1348)
- [Exposed libgit2 git_branch_remote_name method #1340](https://github.com/nodegit/nodegit/pull/1340)
- [Adding git_filter support in nodegit #1331](https://github.com/nodegit/nodegit/pull/1331)
- [Add CI build config for node stable version #1337](https://github.com/nodegit/nodegit/pull/1337)
- [removed node v4 tests #1330](https://github.com/nodegit/nodegit/pull/1330)
#### Included merged libgti2 PRs:
- [Include fixups #4288](https://github.com/libgit2/libgit2/pull/4288)
- [Docs: Fix inline comments for git_diff_hunk #4330](https://github.com/libgit2/libgit2/pull/4330)
- [oid: use memcmp in git_oid__hashcmp #4328](https://github.com/libgit2/libgit2/pull/4328)
- [sha1_lookup: drop sha1_entry_pos function #4327](https://github.com/libgit2/libgit2/pull/4327)
- [sha1_position: convert do-while to while #4326](https://github.com/libgit2/libgit2/pull/4326)
- [patch_generate: represent buffers as void pointers #4304](https://github.com/libgit2/libgit2/pull/4304)
- [Remove unused 'sys/remote.h' header #4323](https://github.com/libgit2/libgit2/pull/4323)
- [tests: rebase::submodule: verify initialization method calls #4320](https://github.com/libgit2/libgit2/pull/4320)
- [tests: rewrite rebase-submodule .gitmodule file #4275](https://github.com/libgit2/libgit2/pull/4275)
- [tsort: remove idempotent conditional assignment #4314](https://github.com/libgit2/libgit2/pull/4314)
- [Build with patched libcurl #4317](https://github.com/libgit2/libgit2/pull/4317)
- [win32: provide fast-path for retrying filesystem operations #4311](https://github.com/libgit2/libgit2/pull/4311)
- [Configuration file fixes with includes #4250](https://github.com/libgit2/libgit2/pull/4250)
- [Patch ID calculation #4272](https://github.com/libgit2/libgit2/pull/4272)
- [signature: don't leave a dangling pointer to the strings on parse failure #4306](https://github.com/libgit2/libgit2/pull/4306)
- [git_reset_*: pass parameters as const pointers #4287](https://github.com/libgit2/libgit2/pull/4287)
- [tests: config: fix missing declaration causing error #4291](https://github.com/libgit2/libgit2/pull/4291)
- [Convert port with htons() in p_getaddrinfo() #4280](https://github.com/libgit2/libgit2/pull/4280)
- [Out of tree builds #4235](https://github.com/libgit2/libgit2/pull/4235)
- [cmake: Permit disabling external http-parser #4278](https://github.com/libgit2/libgit2/pull/4278)
- [merge: fix potential free of uninitialized memory #4277](https://github.com/libgit2/libgit2/pull/4277)
- [merge: perform exact rename detection in linear time #4202](https://github.com/libgit2/libgit2/pull/4202)
- [travis: upgrade container to Ubuntu 14.04 #4211](https://github.com/libgit2/libgit2/pull/4211)
- [Fix template dir empty string #4273](https://github.com/libgit2/libgit2/pull/4273)
- [adding GIT_FILTER_VERSION to GIT_FILTER_INIT as part of convention #4267](https://github.com/libgit2/libgit2/pull/4267)
- [travis: replace use of deprecated homebrew/dupes tap #4268](https://github.com/libgit2/libgit2/pull/4268)
- [Test improvements #4269](https://github.com/libgit2/libgit2/pull/4269)
- [Read prefix tests #4265](https://github.com/libgit2/libgit2/pull/4265)
- [Allow creation of a configuration object in an in-memory repository #4263](https://github.com/libgit2/libgit2/pull/4263)
- [travis: install openssl explicitly #4266](https://github.com/libgit2/libgit2/pull/4266)
- [smart_protocol: fix parsing of server ACK responses #4261](https://github.com/libgit2/libgit2/pull/4261)
- [odb_read_prefix: reset error in backends loop #4264](https://github.com/libgit2/libgit2/pull/4264)
- [Update version number to 0.26 #4262](https://github.com/libgit2/libgit2/pull/4262)
- [CHANGELOG: add various changes introduced since v0.25 #4254](https://github.com/libgit2/libgit2/pull/4254)
- [Ensure packfiles with different contents have different names #4088](https://github.com/libgit2/libgit2/pull/4088)
- [Update to forced checkout and untracked files #4260](https://github.com/libgit2/libgit2/pull/4260)
- [settings: rename `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION` #4259](https://github.com/libgit2/libgit2/pull/4259)
- [Buffer growing cleanups #4255](https://github.com/libgit2/libgit2/pull/4255)
- [Coverity fixes #4253](https://github.com/libgit2/libgit2/pull/4253)
- [SHA1DC update #4258](https://github.com/libgit2/libgit2/pull/4258)
- [Fix path computations for compressed index entries #4236](https://github.com/libgit2/libgit2/pull/4236)
- [(Temporarily) disable UNC tests #4256](https://github.com/libgit2/libgit2/pull/4256)
- [fix build with libressl #4251](https://github.com/libgit2/libgit2/pull/4251)
- [Fix issue with directory glob ignore in subdirectories #4239](https://github.com/libgit2/libgit2/pull/4239)
- [Submodule working directory #4243](https://github.com/libgit2/libgit2/pull/4243)
- [Introduce home directory expansion function for config files, attribute files #4179](https://github.com/libgit2/libgit2/pull/4179)
- [Fix proxy auto detect not utilizing callbacks #4097](https://github.com/libgit2/libgit2/pull/4097)
- [git_repository_set_head: use tag name in reflog #4174](https://github.com/libgit2/libgit2/pull/4174)
- [revparse: support open-ended ranges #4231](https://github.com/libgit2/libgit2/pull/4231)
- [Fix GCC warnings #4240](https://github.com/libgit2/libgit2/pull/4240)
- [Update README: VS -> VSTS #4238](https://github.com/libgit2/libgit2/pull/4238)
- [tests: repo: fix repo discovery tests on overlayfs #4232](https://github.com/libgit2/libgit2/pull/4232)
- [libssh2 shutdown #4229](https://github.com/libgit2/libgit2/pull/4229)
- [WIP: squash some memleaks #4226](https://github.com/libgit2/libgit2/pull/4226)
- [Verify object hashes #4197](https://github.com/libgit2/libgit2/pull/4197)
- [transport: provide a getter for the proxy options #4206](https://github.com/libgit2/libgit2/pull/4206)
- [Debian HTTPS feature test failure #4216](https://github.com/libgit2/libgit2/pull/4216)
- [Do not free config when creating remote #4224](https://github.com/libgit2/libgit2/pull/4224)
- [socket_stream: continue to next addrinfo on socket creation failure #4219](https://github.com/libgit2/libgit2/pull/4219)
- [Honor read-only flag when writing to config backends #4217](https://github.com/libgit2/libgit2/pull/4217)
- [diff_parse: free object instead of its pointer #4215](https://github.com/libgit2/libgit2/pull/4215)
#### Included non-merged libgit2 PRs:
- [Parallelize checkout_create_the_new for ntfs perf gains #4205](https://github.com/libgit2/libgit2/pull/4205)
- [negotiate always fails via libcurl #4126](https://github.com/libgit2/libgit2/pull/4126)
## <a name="v0-19-0" href="#v0-19-0">v0.19.0</a> [(2017-04-20)](https://github.com/nodegit/nodegit/releases/tag/v0.19.0)
[Full Changelog](https://github.com/nodegit/nodegit/compare/v0.18.0...v0.19.0)
......@@ -81,7 +162,7 @@
- `ontoSha` The sha that we rebased onto
- `originalHeadName` The name of the branch that we rebased
- `originalHeadSha` The sha of the branch that was rebased
- `rewitten` which is an array of sha pairs that contain which contain what the commit sha was before the rebase and what the commit sha is after the rebase
- `rewitten` which is an array of sha pairs that contain which contain what the commit sha was before the rebase and what the commit sha is after the rebase
### Summary of Changes from bumping libgit2 to 43275f5
......@@ -140,7 +221,7 @@
In this release we had added support for Node v7 and latest Electron. We have removed support for Node v0.12 and v5.
We are also deprecating nw.js support since it is currently broken, no one in the current team uses it and we would not be able to currently support nw.js in an effective manner with a good user experience.
We are also deprecating nw.js support since it is currently broken, no one in the current team uses it and we would not be able to currently support nw.js in an effective manner with a good user experience.
### Now building against shared libcurl lib
......
......@@ -31,8 +31,8 @@ NodeGit
</tbody>
</table>
**Stable (libgit2#master): 0.19.0**
**Stable (libgit2@0.24): 0.14.1**
**Stable (libgit2#master): 0.20.0**
**Stable (libgit2@v0.26.0): 0.26.0**
## Have a problem? Come chat with us! ##
......
......@@ -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"
......
......@@ -130,7 +130,7 @@
"selfFreeing": true,
"functions": {
"git_blob_create_frombuffer": {
"isAsync": false,
"isAsync": true,
"args": {
"id": {
"isReturn": true
......@@ -141,11 +141,59 @@
}
}
},
"git_blob_create_fromworkdir": {
"isAsync": true,
"args": {
"id": {
"isReturn": true
}
},
"return": {
"isErrorCode": true
}
},
"git_blob_create_fromdisk": {
"isAsync": true,
"args": {
"id": {
"isReturn": true
}
},
"return": {
"isErrorCode": true
}
},
"git_blob_create_fromchunks": {
"ignore": true
},
"git_blob_filtered_content": {
"ignore": true
"isAsync": true,
"isPrototypeMethod": false,
"args": {
"out": {
"isReturn": true,
"cppClassName": "GitBuf",
"jsClassName": "Buffer"
},
"blob": {
"cppClassName": "GitBlob",
"jsClassName": "Blob",
"isSelf": false
},
"as_path": {
"cppClassName": "String",
"jsClassName": "String",
"cType": "const char *"
},
"check_for_binary_data": {
"cppClassName": "Number",
"jsClassName": "Number",
"cType": "int"
}
},
"return": {
"isErrorCode": true
}
},
"git_blob_id": {
"return": {
......@@ -402,6 +450,7 @@
"selfFreeing": true,
"functions": {
"git_commit_amend": {
"isAsync": true,
"args": {
"author": {
"isOptional": true
......@@ -1268,13 +1317,35 @@
"merge": {
"functions": {
"git_merge": {
"isAsync": true,
"args": {
"repo": {
"cppClassName": "GitRepository",
"cType": "git_repository *",
"jsClassName": "Repo"
},
"their_heads": {
"cType": "const git_annotated_commit **",
"cppClassName": "Array",
"jsClassName": "Array",
"arrayElementCppClassName": "GitAnnotatedCommit"
},
"their_heads_len": {
"cType": "size_t",
"cppClassName": "Number",
"jsClassName": "Number"
},
"merge_opts": {
"cType": "git_merge_options *",
"cppClassName": "GitMergeOptions"
},
"checkout_opts": {
"cType": "git_checkout_options *",
"cppClassName": "GitCheckoutOptions"
}
},
"return": {
"isErrorCode": true
}
},
"git_merge_analysis": {
......@@ -1659,8 +1730,12 @@
"rebase": {
"functions": {
"git_rebase_commit": {
"isAsync": true,
"args": {
"id": {
"cType": "git_oid *",
"cppClassName": "GitOid",
"jsClassName": "Oid",
"isReturn": true,
"shouldAlloc": true
},
......@@ -1673,6 +1748,9 @@
"message": {
"isOptional": true
}
},
"return": {
"isErrorCode": true
}
},
"git_rebase_finish": {
......@@ -1700,6 +1778,22 @@
"isOptional": true
}
}
},
"git_rebase_abort": {
"isAsync": true,
"args": {
"rebase": {
"cType": "git_rebase *",
"cppClassName": "GitRebase",
"jsClassName": "Rebase",
"isOptional": false,
"isSelf": true,
"isReturn": false
}
},
"return": {
"isErrorCode": true
}
}
}
},
......@@ -1798,6 +1892,17 @@
"needsForwardDeclaration": false,
"ignore": true
},
"reflog": {
"functions": {
"git_reflog_write": {
"isAsync": true,
"isSelf": true,
"return": {
"isErrorCode": true
}
}
}
},
"reflog_entry": {
"functions": {
"git_reflog_entry_id_new": {
......@@ -2241,9 +2346,11 @@
"isAsync": false
},
"git_status_file": {
"isAsync": true,
"args": {
"status_flags": {
"isReturn": true
"isReturn": true,
"shouldAlloc": true
},
"return": {
"isErrorCode": true
......@@ -2551,19 +2658,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": {
......@@ -2584,6 +2694,21 @@
"git_treebuilder_filter": {
"ignore": true
},
"git_treebuilder_get": {
"return": {
"selfFreeing": false,
"ownedByThis": true
}
},
"git_treebuilder_insert": {
"isAsync": false,
"args": {
"out": {
"selfFreeing": false,
"ownedByThis": true
}
}
},
"git_treebuilder_write": {
"args": {
"id": {
......
......@@ -5,6 +5,8 @@ var shallowClone = NodeGit.Utils.shallowClone;
var _init = Rebase.init;
var _open = Rebase.open;
var _abort = Rebase.prototype.abort;
var _commit = Rebase.prototype.commit;
/**
* Initializes a rebase
* @async
......@@ -83,3 +85,12 @@ Rebase.open = function(repository, options) {
);
return _open(repository, options);
};
Rebase.prototype.commit = function(author, committer, encoding, message) {
return _commit.call(this, author, committer, encoding, message);
};
Rebase.prototype.abort = function() {
return _abort.call(this);
};
......@@ -150,15 +150,15 @@ function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) {
});
})
.then(function(diff) {
if (!(NodeGit.Status.file(repo, filePath) &
NodeGit.Status.STATUS.WT_MODIFIED) &&
!(NodeGit.Status.file(repo, filePath) &
NodeGit.Status.STATUS.INDEX_MODIFIED)) {
return Promise.reject
("Selected staging is only available on modified files.");
}
return diff.patches();
return NodeGit.Status.file(repo, filePath)
.then(function(status) {
if (!(status & NodeGit.Status.STATUS.WT_MODIFIED) &&
!(status & NodeGit.Status.STATUS.INDEX_MODIFIED)) {
return Promise.reject
("Selected staging is only available on modified files.");
}
return diff.patches();
});
})
.then(function(patches) {
var pathPatch = patches.filter(function(patch) {
......@@ -217,23 +217,26 @@ function performRebase(
function getPromise() {
return rebase.next()
.then(function() {
return repository.refreshIndex()
.then(function(index) {
if (index.hasConflicts()) {
throw index;
}
return repository.refreshIndex();
})
.then(function(index) {
if (index.hasConflicts()) {
throw index;
}
rebase.commit(null, signature);
return rebase.commit(null, signature);
})
.then(function() {
return performRebase(
repository,
rebase,
signature,
beforeNextFn,
beforeFinishFn
);
});
}, function(error) {
return performRebase(
repository,
rebase,
signature,
beforeNextFn,
beforeFinishFn
);
})
.catch(function(error) {
if (error && error.errno === NodeGit.Error.CODE.ITEROVER) {
const calcRewritten = fp.flow([
fp.split("\n"),
......@@ -435,6 +438,7 @@ Repository.prototype.continueRebase = function(
signature = signature || repo.defaultSignature();
var rebase;
return repo.refreshIndex()
.then(function(index) {
if (index.hasConflicts()) {
......@@ -443,9 +447,17 @@ Repository.prototype.continueRebase = function(
return NodeGit.Rebase.open(repo);
})
.then(function(rebase) {
rebase.commit(null, signature);
.then(function(_rebase) {
rebase = _rebase;
return rebase.commit(null, signature)
.catch(function() {
// Ignore all errors to prevent
// this routine from choking now
// that we made rebase.commit
// asynchronous
});
})
.then(function() {
return performRebase(
repo,
rebase,
......@@ -499,8 +511,8 @@ Repository.prototype.createBranch = function(name, commit, force) {
* @param {Buffer} buffer
* @return {Oid}
*/
Repository.prototype.createBlobFromBuffer = function(buffer, callback) {
return Blob.createFromBuffer(this, buffer, buffer.length, callback);
Repository.prototype.createBlobFromBuffer = function(buffer) {
return Blob.createFromBuffer(this, buffer, buffer.length);
};
/**
......@@ -1636,17 +1648,36 @@ Repository.prototype.stageFilemode =
})
.then(function(diff) {
var origLength = filePaths.length;
filePaths = filePaths.filter(function(p) {
return (
(NodeGit.Status.file(repo, p) & NodeGit.Status.STATUS.WT_MODIFIED) ||
(NodeGit.Status.file(repo, p) & NodeGit.Status.STATUS.INDEX_MODIFIED)
);
});
if (filePaths.length === 0 && origLength > 0) {
return Promise.reject
("Selected staging is only available on modified files.");
}
return diff.patches();
var fileFilterPromises = fp.map(function(p) {
return NodeGit.Status.file(repo, p)
.then(function(status) {
return {
path: p,
filter: (
(status & NodeGit.Status.STATUS.WT_MODIFIED) ||
(status & NodeGit.Status.STATUS.INDEX_MODIFIED)
)
};
});
}, filePaths);
return Promise.all(fileFilterPromises)
.then(function(results) {
filePaths = fp.flow([
fp.filter(function(filterResult) {
return filterResult.filter;
}),
fp.map(function(filterResult) {
return filterResult.path;
})
])(results);
if (filePaths.length === 0 && origLength > 0) {
return Promise.reject
("Selected staging is only available on modified files.");
}
return diff.patches();
});
})
.then(function(patches) {
var pathPatches = patches.filter(function(patch) {
......@@ -1753,9 +1784,9 @@ Repository.prototype.stageLines =
.then(function(newContent) {
var newContentBuffer = new Buffer(newContent);
var newOid = repo.createBlobFromBuffer(newContentBuffer);
return repo.getBlob(newOid);
return repo.createBlobFromBuffer(newContentBuffer);
})
.then(newOid => repo.getBlob(newOid))
.then(function(newBlob) {
var entry = index.getByPath(filePath, 0);
entry.id = newBlob.id();
......
{
"name": "nodegit",
"description": "Node.js libgit2 asynchronous native bindings",
"version": "0.19.0",
"version": "0.20.1",
"homepage": "http://nodegit.org",
"keywords": [
"libgit2",
......
var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);
var promisify = require("promisify-node");
var fse = promisify("fs-extra");
var exec = require("../../utils/execPromise");
describe("Blob", function() {
var NodeGit = require("../../");
var Oid = NodeGit.Oid;
var Repository = NodeGit.Repository;
var Blob = NodeGit.Blob;
var FileMode = NodeGit.TreeEntry.FILEMODE;
var reposPath = local("../repos/workdir");
var oid = "111dd657329797f6165f52f5085f61ac976dcf04";
var previousCommitOid = "";
function commitFile(repo, fileName, fileContent, commitMessage) {
var index;
var treeOid;
var parent;
return fse.writeFile(path.join(repo.workdir(), fileName), fileContent)
.then(function() {
return repo.refreshIndex();
})
.then(function(indexResult) {
index = indexResult;
})
.then(function() {
return index.addByPath(fileName);
})
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
})
.then(function(oidResult) {
treeOid = oidResult;
return NodeGit.Reference.nameToId(repo, "HEAD");
})
.then(function(head) {
return repo.getCommit(head);
})
.then(function(parentResult) {
parent = parentResult;
return Promise.all([
NodeGit.Signature.create("Foo Bar", "foo@bar.com", 123456789, 60),
NodeGit.Signature.create("Foo A Bar", "foo@bar.com", 987654321, 90)
]);
})
.then(function(signatures) {
var author = signatures[0];
var committer = signatures[1];
return repo.createCommit(
"HEAD",
author,
committer,
commitMessage,
treeOid,
[parent]
);
});
}
before(function() {
return Repository.open(reposPath)
.then(function(repository) {
return repository.getHeadCommit();
})
.then(function(commit) {
previousCommitOid = commit.id();
});
});
beforeEach(function() {
var test = this;
......@@ -26,6 +91,16 @@ describe("Blob", function() {
});
});
after(function() {
return exec("git clean -xdf", {cwd: reposPath})
.then(function() {
return exec("git checkout master", {cwd: reposPath});
})
.then(function() {
return exec("git reset --hard " + previousCommitOid, {cwd: reposPath});
});
});
it("can provide content as a buffer", function() {
var contents = this.blob.content();
......@@ -50,4 +125,359 @@ describe("Blob", function() {
assert.equal(blob.id().toString(), oid);
});
});
describe("createFromBuffer", function() {
it("creates a new blob from the buffer", function() {
var content = "This is a new buffer";
var buf = new Buffer(content, content.length);
var test = this;
return Blob.createFromBuffer(test.repository, buf, content.length)
.then(function(oid) {
return test.repository.getBlob(oid);
})
.then(function(newBlob) {
assert.equal(newBlob.toString(), content);
});
});
it("creates blob with content equal to length", function() {
var content = "This is a new buffer";
var buf = new Buffer(content, content.length);
var test = this;
return Blob.createFromBuffer(test.repository, buf, 2)
.then(function(oid) {
return test.repository.getBlob(oid);
})
.then(function(newBlob) {
assert.equal(newBlob.toString(), "Th");
});
});
it("throws an error when repository is null", function() {
return Blob.createFromBuffer(null, null, 0)
.catch(function(error) {
assert.strictEqual(error.message, "Repository repo is required.");
});
});
it("throws an error when buffer is null", function