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: 5 additions & 5 deletions generate/templates/manual/revwalk/file_history_walk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
}

const git_diff_delta *delta = git_patch_get_delta(nextPatch);
bool isEqualOldFile = !strcmp(delta->old_file.path, baton->file_path);
bool isEqualNewFile = !strcmp(delta->new_file.path, baton->file_path);
bool isEqualOldFile = !strncmp(delta->old_file.path, baton->file_path, strlen(baton->file_path));
bool isEqualNewFile = !strncmp(delta->new_file.path, baton->file_path, strlen(baton->file_path));

if (isEqualNewFile) {
if (delta->status == GIT_DELTA_ADDED || delta->status == GIT_DELTA_DELETED) {
Expand Down Expand Up @@ -173,8 +173,8 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
}

const git_diff_delta *delta = git_patch_get_delta(nextPatch);
bool isEqualOldFile = !strcmp(delta->old_file.path, baton->file_path);
bool isEqualNewFile = !strcmp(delta->new_file.path, baton->file_path);
bool isEqualOldFile = !strncmp(delta->old_file.path, baton->file_path, strlen(baton->file_path));
bool isEqualNewFile = !strncmp(delta->new_file.path, baton->file_path, strlen(baton->file_path));
int oldLen = strlen(delta->old_file.path);
int newLen = strlen(delta->new_file.path);
char *outPair = new char[oldLen + newLen + 2];
Expand All @@ -185,7 +185,7 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()

if (isEqualNewFile) {
std::pair<git_commit *, std::pair<char *, git_delta_t> > *historyEntry;
if (!isEqualOldFile) {
if (!isEqualOldFile || delta->status == GIT_DELTA_RENAMED) {
historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t> >(
nextCommit,
std::pair<char *, git_delta_t>(strdup(outPair), delta->status)
Expand Down
30 changes: 30 additions & 0 deletions test/tests/revwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,36 @@ describe("Revwalk", function() {
});
});

it("can get the history of a dir", function() {
var test = this;
var magicShas = [
"6ed3027eda383d417457b99b38c73f88f601c368",
"95cefff6aabd3c1f6138ec289f42fec0921ff610",
"7ad92a7e4d26a1af93f3450aea8b9d9b8069ea8c",
"96f077977eb1ffcb63f9ce766cdf110e9392fdf5",
"694adc5369687c47e02642941906cfc5cb21e6c2",
"eebd0ead15d62eaf0ba276da53af43bbc3ce43ab",
"1273fff13b3c28cfdb13ba7f575d696d2a8902e1",
"271c65ed16ab147cee715e1076e1d716156cc5a3",
"94d532004323641fd169f375869c36a82b32fac7",
"1c71929a905da9faab64472d53815d46ff4391dd",
"3947245612ae27077517038704b7a679e742658e",
"a44c81558d0f72ccf6c1facbe2ba0b9b711586a9",
"01d469416b26340ee4922d5171ef8dbe46c879f4"
];

return test.walker.fileHistoryWalk("include/functions", 1000)
.then(function(results) {
var shas = results.map(function(result) {
return result.commit.sha();
});
assert.equal(magicShas.length, shas.length);
magicShas.forEach(function(sha, i) {
assert.equal(sha, shas[i]);
});
});
});

it("can get the history of a file while ignoring parallel branches",
function() {
var test = this;
Expand Down