diff --git a/lib/revert.js b/lib/revert.js index 2dddb2cee..84c05b5c9 100644 --- a/lib/revert.js +++ b/lib/revert.js @@ -50,7 +50,7 @@ Revert.commit = function( /** * Reverts the given commit, producing changes in the index and * working directory. - * + * * @async * @param {Repository} repo the repository to perform the revert in * @param {Commit} commit the commit to revert @@ -71,7 +71,7 @@ Revert.revert = function(repo, commit, revertOpts) { revertOpts = normalizeOptions(revertOpts, NodeGit.RevertOptions); - if (revertOpts) { + if (mergeOpts) { revertOpts.mergeOpts = normalizeOptions(mergeOpts, NodeGit.MergeOptions); } diff --git a/test/tests/revert.js b/test/tests/revert.js index 8733c870f..46263e7b9 100644 --- a/test/tests/revert.js +++ b/test/tests/revert.js @@ -74,4 +74,11 @@ describe("Revert", function() { throw error; }); }); + + it("RevertOptions without MergeOptions should not segfault", function() { + return Revert.revert(test.repository, test.firstCommit, {}) + .catch(function(error) { + throw error; + }); + }); });