Skip to content

Commit a84df76

Browse files
committed
fixup! Fix behavior of Commit#parent
1 parent 976f7d6 commit a84df76

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

lib/commit.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var Commit = NodeGit.Commit;
44
var LookupWrapper = NodeGit.Utils.lookupWrapper;
55

66
var _amend = Commit.prototype.amend;
7+
var _parent = Commit.prototype.parent;
78

89
/**
910
* Retrieves the commit pointed to by the oid
@@ -19,24 +20,18 @@ Commit.lookup = LookupWrapper(Commit);
1920
* @param {Number} n
2021
* @return {Commit}
2122
*/
22-
Commit.prototype.parent = (function(parent) {
23-
if (typeof parent !== "function") {
24-
throw new Error("parent is not a function!");
25-
}
26-
27-
return function(n, callback) {
28-
var repo = this.repo;
29-
return parent.call(this, n).then(p => {
30-
p.repo = repo;
23+
Commit.prototype.parent = function(n, callback) {
24+
var repo = this.repo;
25+
return _parent.call(this, n).then(p => {
26+
p.repo = repo;
3127

32-
if (typeof callback === "function") {
33-
callback(null, p);
34-
}
28+
if (typeof callback === "function") {
29+
callback(null, p);
30+
}
3531

36-
return p;
37-
}, callback);
38-
};
39-
})(Commit.prototype.parent);
32+
return p;
33+
}, callback);
34+
};
4035

4136
/**
4237
* Amend a commit

0 commit comments

Comments
 (0)