Skip to content
Open
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
2 changes: 1 addition & 1 deletion examples/walk-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,13 @@
"ownedByThis": true
}
},
"git_commit_tree": {
"isAsync": true,
"return" : {
"isReturn": true,
"isErrorCode": true
}
},
"git_commit_tree_id": {
"return": {
"ownedByThis": true
Expand Down
16 changes: 3 additions & 13 deletions lib/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*
Expand Down
10 changes: 5 additions & 5 deletions lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/tests/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions test/tests/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -408,7 +408,7 @@ describe("Diff", function() {
})
.then(function(headCommit) {
return Promise.all([
headCommit.getTree(),
headCommit.tree(),
test.repository.index()
]);
})
Expand Down
2 changes: 1 addition & 1 deletion test/tests/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/tests/stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/tests/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/tests/tree_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("TreeEntry", function() {
return Promise.all(testPromises);
};

return this.commit.getTree()
return this.commit.tree()
.then(testTree)
.done(function() {
done();
Expand Down Expand Up @@ -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");
});
Expand Down
4 changes: 2 additions & 2 deletions test/tests/treebuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down