diff --git a/examples/walk-tree.js b/examples/walk-tree.js index 6c564acb6..830650f3d 100644 --- a/examples/walk-tree.js +++ b/examples/walk-tree.js @@ -10,7 +10,7 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git")) return repo.getMasterCommit(); }) .then(function(firstCommitOnMaster) { - return firstCommitOnMaster.getTree(); + return firstCommitOnMaster.tree(); }) .then(function(tree) { // `walk()` returns an event. diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index 096d4df9b..0f7639d83 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -652,6 +652,13 @@ "ownedByThis": true } }, + "git_commit_tree": { + "isAsync": true, + "return" : { + "isReturn": true, + "isErrorCode": true + } + }, "git_commit_tree_id": { "return": { "ownedByThis": true diff --git a/lib/commit.js b/lib/commit.js index 232d771b0..a1d6daefd 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -82,12 +82,12 @@ Commit.prototype.getDiff = function(callback) { Commit.prototype.getDiffWithOptions = function(options, callback) { var commit = this; - return commit.getTree().then(function(thisTree) { + return commit.tree().then(function(thisTree) { return commit.getParents().then(function(parents) { var diffs; if (parents.length) { diffs = parents.map(function(parent) { - return parent.getTree().then(function(parentTree) { + return parent.tree().then(function(parentTree) { return thisTree.diffWithOptions(parentTree, options); }); }); @@ -115,7 +115,7 @@ Commit.prototype.getDiffWithOptions = function(options, callback) { * @return {TreeEntry} */ Commit.prototype.getEntry = function(path, callback) { - return this.getTree().then(function(tree) { + return this.tree().then(function(tree) { return tree.getEntry(path).then(function(entry) { if (typeof callback === "function") { callback(null, entry); @@ -180,16 +180,6 @@ Commit.prototype.getSignature = function(field) { return Commit.extractSignature(this.repo, this.id(), field); }; -/** - * Get the tree associated with this commit. - * - * @async - * @return {Tree} - */ -Commit.prototype.getTree = function(callback) { - return this.repo.getTree(this.treeId(), callback); -}; - /** * Walk the history from this commit backwards. * diff --git a/lib/repository.js b/lib/repository.js index d5e941134..30ac9b962 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -136,7 +136,7 @@ function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) { if (isStaged) { return repo.getHeadCommit() .then(function getTreeFromCommit(commit) { - return commit.getTree(); + return commit.tree(); }) .then(function getDiffFromTree(tree) { return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); @@ -413,7 +413,7 @@ Repository.prototype.checkoutRef = function(reference, opts) { NodeGit.Checkout.STRATEGY.RECREATE_MISSING); return repo.getReferenceCommit(reference.name()) .then(function(commit) { - return commit.getTree(); + return commit.tree(); }) .then(function(tree) { return Checkout.tree(repo, tree, opts); @@ -1564,7 +1564,7 @@ Repository.prototype.mergeBranches = function( " to branch " + fromBranch.shorthand(); - return branchCommits[1].getTree() + return branchCommits[1].tree() .then(function(tree) { if (toBranch.isHead()) { // Checkout the tree if we're on the branch @@ -1652,7 +1652,7 @@ Repository.prototype.mergeBranches = function( return repo.getBranchCommit(branch); }) .then(function(branchCommit) { - return branchCommit.getTree(); + return branchCommit.tree(); }) .then(function(tree) { var opts = { @@ -1712,7 +1712,7 @@ Repository.prototype.stageFilemode = : repo.getHeadCommit() .then(function getTreeFromCommit(commit) { - return commit.getTree(); + return commit.tree(); }) .then(function getDiffFromTree(tree) { return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); diff --git a/test/tests/commit.js b/test/tests/commit.js index d6e6a5ce7..c8d03cd0d 100644 --- a/test/tests/commit.js +++ b/test/tests/commit.js @@ -529,7 +529,7 @@ describe("Commit", function() { var commitTreeEntryCount = 0; var expectedCommitTreeEntryCount = 198; - return this.commit.getTree().then(function(tree) { + return this.commit.tree().then(function(tree) { return new Promise(function(resolve, fail) { var treeWalker = tree.walk(); diff --git a/test/tests/diff.js b/test/tests/diff.js index d9dfec7bc..6bc870cb1 100644 --- a/test/tests/diff.js +++ b/test/tests/diff.js @@ -57,7 +57,7 @@ describe("Diff", function() { return test.repository.getBranchCommit("master"); }) .then(function(masterCommit) { - return masterCommit.getTree(); + return masterCommit.tree(); }) .then(function(tree) { test.masterCommitTree = tree; @@ -408,7 +408,7 @@ describe("Diff", function() { }) .then(function(headCommit) { return Promise.all([ - headCommit.getTree(), + headCommit.tree(), test.repository.index() ]); }) diff --git a/test/tests/patch.js b/test/tests/patch.js index 158685a08..e3456341f 100644 --- a/test/tests/patch.js +++ b/test/tests/patch.js @@ -23,7 +23,7 @@ describe("Patch", function() { return test.repository.getBranchCommit("master"); }) .then(function(masterCommit) { - return masterCommit.getTree(); + return masterCommit.tree(); }) .then(function(tree) { test.masterCommitTree = tree; diff --git a/test/tests/stage.js b/test/tests/stage.js index 34de76630..6a14b4d73 100644 --- a/test/tests/stage.js +++ b/test/tests/stage.js @@ -85,7 +85,7 @@ describe("Stage", function() { return test.repository.getBranchCommit("master"); }) .then(function(masterCommit) { - var treePromise = masterCommit.getTree(); + var treePromise = masterCommit.tree(); var indexPromise = test.repository.refreshIndex(); return Promise.all([treePromise, indexPromise]); @@ -246,7 +246,7 @@ describe("Stage", function() { //fileModeDifference - expected (newfilemode) - (oldfilemode) return test.repository.getHeadCommit() .then(function(commit) { - return commit.getTree(); + return commit.tree(); }) .then(function(tree) { if (vsWorkdir) { diff --git a/test/tests/tree.js b/test/tests/tree.js index e5272116d..8ed5752df 100644 --- a/test/tests/tree.js +++ b/test/tests/tree.js @@ -32,7 +32,7 @@ describe("Tree", function() { it("gets an entry by name", function(done) { - this.commit.getTree().then(function(tree) { + this.commit.tree().then(function(tree) { var entry = tree.entryByName("README.md"); assert(entry); }).done(done); @@ -52,7 +52,7 @@ describe("Tree", function() { return RepoUtils.commitFileToRepo(repo, file2, "", commit); }) .then(function(commit) { - return commit.getTree(); + return commit.tree(); }) .then(function(tree) { assert(tree); diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index 086a4f8d2..f23cfa626 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -81,7 +81,7 @@ describe("TreeEntry", function() { return Promise.all(testPromises); }; - return this.commit.getTree() + return this.commit.tree() .then(testTree) .done(function() { done(); @@ -182,7 +182,7 @@ describe("TreeEntry", function() { var test = this; return leakTest(NodeGit.TreeEntry, function() { - return test.commit.getTree() + return test.commit.tree() .then(function(tree) { return tree.entryByPath("example"); }); diff --git a/test/tests/treebuilder.js b/test/tests/treebuilder.js index 6462fd934..12498346a 100644 --- a/test/tests/treebuilder.js +++ b/test/tests/treebuilder.js @@ -34,7 +34,7 @@ describe("TreeBuilder", function(){ //get latest commit return test.repo.getHeadCommit() //get tree of commit - .then(function(commit){ return commit.getTree(); }) + .then(function(commit){ return commit.tree(); }) //make treebuilder from tree .then(function(tree){ return Git.Treebuilder.create(test.repo, tree); }) //verify treebuilder can do stuff @@ -56,7 +56,7 @@ describe("TreeBuilder", function(){ //get latest commit return test.repo.getHeadCommit() //get tree of commit - .then(function(commit){ return commit.getTree(); }) + .then(function(commit){ return commit.tree(); }) //make treebuilder from tree .then(function(tree){ return Git.Treebuilder.create(test.repo, tree); }) //verify treebuilder can do stuff