FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Hot fix historywalk by implausible · Pull Request #896 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cc  (1) .js  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL