Skip to content
Merged
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
10 changes: 9 additions & 1 deletion generate/templates/manual/revwalk/file_history_walk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
}
baton->out->push_back(historyEntry);
flag = true;
} else if (isEqualOldFile) {
std::pair<git_commit *, std::pair<char *, git_delta_t> > *historyEntry;
historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t> >(
nextCommit,
std::pair<char *, git_delta_t>(strdup(delta->new_file.path), delta->status)
);
baton->out->push_back(historyEntry);
flag = true;
}

git_patch_free(nextPatch);
Expand Down Expand Up @@ -220,7 +228,7 @@ void GitRevwalk::FileHistoryWalkWorker::HandleOKCallback()
Nan::Set(historyEntry, Nan::New("commit").ToLocalChecked(), GitCommit::New(batonResult->first, true));
Nan::Set(historyEntry, Nan::New("status").ToLocalChecked(), Nan::New<Number>(batonResult->second.second));
if (batonResult->second.second == GIT_DELTA_RENAMED) {
Nan::Set(historyEntry, Nan::New("oldName").ToLocalChecked(), Nan::New(batonResult->second.first).ToLocalChecked());
Nan::Set(historyEntry, Nan::New("altname").ToLocalChecked(), Nan::New(batonResult->second.first).ToLocalChecked());
}
Nan::Set(result, Nan::New<Number>(i), historyEntry);

Expand Down
2 changes: 1 addition & 1 deletion lib/revwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Revwalk.prototype.getCommits = function(count) {
* @type {Object}
* @property {Commit} commit the commit for this entry
* @property {Number} status the status of the file in the commit
* @property {String} oldName the old name that is provided when status is
* @property {String} altname the other name that is provided when status is
* renamed
*/

Expand Down
15 changes: 14 additions & 1 deletion test/tests/revwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ describe("Revwalk", function() {
var repoPath = local("../repos/renamedFileRepo");
var signature = NodeGit.Signature.create("Foo bar",
"foo@bar.com", 123456789, 60);
var headCommit;

return RepoUtils.createRepository(repoPath)
.then(function(r) {
repo = r;
Expand Down Expand Up @@ -276,14 +278,25 @@ describe("Revwalk", function() {
return NodeGit.Reference.nameToId(repo, "HEAD");
})
.then(function(commitOid) {
headCommit = commitOid.tostrS();
var walker = repo.createRevWalk();
walker.sorting(NodeGit.Revwalk.SORT.TIME);
walker.push(commitOid.tostrS());
return walker.fileHistoryWalk(fileNameB, 5);
})
.then(function(results) {
assert.equal(results[0].status, NodeGit.Diff.DELTA.RENAMED);
assert.equal(results[0].oldName, fileNameA);
assert.equal(results[0].altname, fileNameA);
})
.then(function() {
var walker = repo.createRevWalk();
walker.sorting(NodeGit.Revwalk.SORT.TIME);
walker.push(headCommit);
return walker.fileHistoryWalk(fileNameA, 5);
})
.then(function(results) {
assert.equal(results[0].status, NodeGit.Diff.DELTA.RENAMED);
assert.equal(results[0].altname, fileNameB);
})
.then(function() {
return fse.remove(repoPath);
Expand Down