Skip to content

Commit 6231c50

Browse files
committed
File history walk: include both new and old file paths when renamed
1 parent 0eba069 commit 6231c50

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

generate/templates/manual/revwalk/file_history_walk.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ class FileHistoryEvent {
4444
Nan::Set(historyEntry, Nan::New("status").ToLocalChecked(), Nan::New<Number>(type));
4545
Nan::Set(historyEntry, Nan::New("isMergeCommit").ToLocalChecked(), Nan::New(isMergeCommit));
4646
if (type == GIT_DELTA_RENAMED) {
47-
if (existsInCurrentTree) {
47+
if (from != NULL) {
4848
Nan::Set(historyEntry, Nan::New("oldName").ToLocalChecked(), Nan::New(from).ToLocalChecked());
49-
} else {
49+
}
50+
if (to != NULL) {
5051
Nan::Set(historyEntry, Nan::New("newName").ToLocalChecked(), Nan::New(to).ToLocalChecked());
5152
}
5253
}
@@ -100,7 +101,7 @@ class FileHistoryEvent {
100101
false,
101102
currentCommit,
102103
delta->old_file.path,
103-
NULL
104+
delta->new_file.path
104105
);
105106
git_diff_free(diff);
106107
git_tree_entry_free(currentEntry);
@@ -139,7 +140,7 @@ class FileHistoryEvent {
139140
false,
140141
false,
141142
currentCommit,
142-
NULL,
143+
delta->old_file.path,
143144
delta->new_file.path
144145
);
145146
git_diff_free(diff);

0 commit comments

Comments
 (0)