Skip to content

Commit 7cca0eb

Browse files
committed
Sorting exposed with commit.history(sort.Time)
1 parent 7209660 commit 7cca0eb

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

example/walk-history.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var git = require('../'),
2-
path = require('path');
2+
path = require('path'),
3+
sort = git.RevWalk.Sort;
34

45
// This code walks the history of the master branch and prints results
56
// that look very similar to calling `git log` from the command line
@@ -11,7 +12,7 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) {
1112
if (error) throw error;
1213

1314
// History returns an event.
14-
var history = branch.history();
15+
var history = branch.history(sort.Time);
1516

1617
// History emits 'commit' event for each commit in the branch's history
1718
history.on('commit', function(commit) {

lib/commit.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Commit.prototype.history = function() {
6666

6767
var oid = this.oid();
6868
var revwalk = this.repo.createRevWalk();
69+
revwalk.sorting.apply(revwalk, arguments);
70+
6971
var commits = [];
7072
event.start = function() {
7173
revwalk.walk(oid, function commitRevWalk(error, commit) {

lib/revwalk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RevWalk.Sort = {
1717
* Set the sort order for the revwalk. This function takes variable arguments
1818
* like `revwalk.sorting(git.RevWalk.Topological, git.RevWalk.Reverse).`
1919
*
20-
* @param {Number}
20+
* @param {Number} sort
2121
*/
2222
RevWalk.prototype.sorting = function() {
2323
var sort = 0;

0 commit comments

Comments
 (0)