Skip to content

Commit cb83ac2

Browse files
committed
Made revwalk push synchronous, fix segfault
1 parent f8f7305 commit cb83ac2

File tree

4 files changed

+44
-49
lines changed

4 files changed

+44
-49
lines changed

generate/descriptor.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,10 @@
381381
"isConstructorMethod": true,
382382
"jsFunctionName": "createRevwalk",
383383
"cppFunctionName": "CreateRevwalk",
384-
"args": [{ "shouldAlloc": true }]
384+
"args": [
385+
{ "isReturn": true },
386+
{ "isSelf": false }
387+
]
385388
},
386389

387390
"git_revwalk_sorting": {
@@ -391,17 +394,8 @@
391394

392395
"git_revwalk_push": {
393396
"ignore": false,
394-
"isAsync": true,
395-
"args": [
396-
{
397-
"isSelf": true,
398-
"isReturn": false
399-
},
400-
{
401-
"isReturn": false
402-
}
403-
],
404-
397+
"isAsync": false,
398+
"args": [{ "isSelf": true, "isReturn": false }],
405399
"return": {
406400
"isErrorCode": true
407401
}

lib/commit.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var git = require('../');
22
var Commit = git.Commit;
33
var Oid = git.Oid;
4+
var Revwalk = git.Revwalk;
45
var events = require('events');
56
var Tree = require("./tree");
67

@@ -98,6 +99,7 @@ Commit.prototype.history = function() {
9899
event.emit('end', commits);
99100
return;
100101
}
102+
101103
event.emit('commit', commit);
102104
commits.push(commit);
103105
});

lib/revwalk.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,24 @@ Revwalk.prototype.sorting = function() {
4444
Revwalk.prototype.walk = function(oid, callback) {
4545
var self = this;
4646

47-
this.push(oid, function revWalkPush(error) {
48-
if (error) return callback(error);
47+
this.push(oid);
4948

50-
function walk() {
51-
self.next(function revWalkNext(error, oid) {
52-
if (error) return callback(error);
53-
if (!oid) return callback();
49+
function walk() {
50+
self.next(function revWalkNext(error, oid) {
51+
if (error) return callback(error);
52+
if (!oid) return callback();
5453

55-
self.repo.getCommit(oid, function revWalkCommitLookup(error, commit) {
56-
if (error) return callback(error);
54+
self.repo.getCommit(oid, function revWalkCommitLookup(error, commit) {
55+
if (error) return callback(error);
5756

58-
callback(null, commit);
59-
walk();
60-
});
57+
callback(null, commit);
58+
walk();
6159
});
62-
}
60+
});
61+
}
6362

64-
walk();
65-
});
63+
walk();
6664
};
67-
util.normalizeOid(Revwalk.prototype, 'getTag');
68-
util.makeSafe(Revwalk.prototype, 'getTag');
65+
66+
util.normalizeOid(Revwalk.prototype, 'walk');
67+
util.makeSafe(Revwalk.prototype, 'walk');

test/commit.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,27 @@ exports.improperCommitId = function(test) {
140140
/**
141141
* Test that retreiving walking a given commit's history works as expected.
142142
*/
143-
//exports.history = function(test) {
144-
// test.expect(4);
145-
// git.Repo.open('repos/workdir/.git', function(error, repository) {
146-
// repository.getCommit(historyCountKnownSHA, function(error, commit) {
147-
// test.equals(null, error, 'Getting latest branch commit should not error');
148-
// var historyCount = 0;
149-
// var expectedHistoryCount = 364;
150-
// commit.history().on('commit', function(commit) {
151-
// // historyCount++;
152-
// // }).on('end', function(commits) {
153-
// // test.equals(null, error, 'There should be no errors');
154-
// // test.equals(historyCount, expectedHistoryCount);
155-
// // test.equals(commits.length, expectedHistoryCount);
156-
// test.done();
157-
// // }).on('error', function(error) {
158-
// // test.equals(null, error, 'There should be no errors');
159-
// // test.ok(false, 'There should be no errors');
160-
// }).start();
161-
// });
162-
// });
163-
//};
143+
exports.history = function(test) {
144+
test.expect(4);
145+
git.Repo.open('repos/workdir/.git', function(error, repository) {
146+
repository.getCommit(historyCountKnownSHA, function(error, commit) {
147+
test.equals(null, error, 'Getting latest branch commit should not error');
148+
var historyCount = 0;
149+
var expectedHistoryCount = 364;
150+
commit.history().on('commit', function(commit) {
151+
historyCount++;
152+
}).on('end', function(commits) {
153+
test.equals(null, error, 'There should be no errors');
154+
test.equals(historyCount, expectedHistoryCount);
155+
test.equals(commits.length, expectedHistoryCount);
156+
test.done();
157+
}).on('error', function(error) {
158+
test.equals(null, error, 'There should be no errors');
159+
test.ok(false, 'There should be no errors');
160+
}).start();
161+
});
162+
});
163+
};
164164

165165
/**
166166
* Test that retreiving master branch's HEAD commit works as expected.

0 commit comments

Comments
 (0)