diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 0d926c4db..9d145a866 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -63,8 +63,14 @@ TreeEntry.prototype.getTree = function(callback) { * Retrieve the tree for this entry. Make sure to call `isTree` first! * @return {Blob} */ -TreeEntry.prototype.getBlob = function() { - return this.parent.repo.getBlob(this.oid()); +TreeEntry.prototype.getBlob = function(callback) { + return this.parent.repo.getBlob(this.oid()).then(function(blob) { + if (typeof callback === "function") { + callback(null, blob); + } + + return blob; + }, callback); }; /** diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index ae481a1d2..c3451d8b3 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -54,6 +54,15 @@ describe("TreeEntry", function() { }); }); + it("provides the blob representation via callback", function() { + return this.commit.getEntry("test/raw-commit.js") + .then(function(entry) { + entry.getBlob(function (error, blob) { + assert.equal(blob.rawsize(), 2736); + }); + }); + }); + it("provides the tree the entry is part of", function() { return this.commit.getEntry("test") .then(function(entry) {