@@ -175,13 +175,20 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
175175 const git_diff_delta *delta = git_patch_get_delta (nextPatch);
176176 bool isEqualOldFile = !strcmp (delta->old_file .path , baton->file_path );
177177 bool isEqualNewFile = !strcmp (delta->new_file .path , baton->file_path );
178+ int oldLen = strlen (delta->old_file .path );
179+ int newLen = strlen (delta->new_file .path );
180+ char *outPair = new char [oldLen + newLen + 2 ];
181+ strcpy (outPair, delta->new_file .path );
182+ outPair[newLen] = ' \n ' ;
183+ outPair[newLen + 1 ] = ' \0 ' ;
184+ strcat (outPair, delta->old_file .path );
178185
179186 if (isEqualNewFile) {
180187 std::pair<git_commit *, std::pair<char *, git_delta_t > > *historyEntry;
181188 if (!isEqualOldFile) {
182189 historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t > >(
183190 nextCommit,
184- std::pair<char *, git_delta_t >(strdup (delta-> old_file . path ), delta->status )
191+ std::pair<char *, git_delta_t >(strdup (outPair ), delta->status )
185192 );
186193 } else {
187194 historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t > >(
@@ -195,12 +202,14 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
195202 std::pair<git_commit *, std::pair<char *, git_delta_t > > *historyEntry;
196203 historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t > >(
197204 nextCommit,
198- std::pair<char *, git_delta_t >(strdup (delta-> new_file . path ), delta->status )
205+ std::pair<char *, git_delta_t >(strdup (outPair ), delta->status )
199206 );
200207 baton->out ->push_back (historyEntry);
201208 flag = true ;
202209 }
203210
211+ delete[] outPair;
212+
204213 git_patch_free (nextPatch);
205214
206215 if (flag) {
@@ -255,7 +264,13 @@ void GitRevwalk::FileHistoryWalkWorker::HandleOKCallback()
255264 Nan::Set (historyEntry, Nan::New (" commit" ).ToLocalChecked (), GitCommit::New (batonResult->first , true ));
256265 Nan::Set (historyEntry, Nan::New (" status" ).ToLocalChecked (), Nan::New<Number>(batonResult->second .second ));
257266 if (batonResult->second .second == GIT_DELTA_RENAMED) {
258- Nan::Set (historyEntry, Nan::New (" altname" ).ToLocalChecked (), Nan::New (batonResult->second .first ).ToLocalChecked ());
267+ char *namePair = batonResult->second .first ;
268+ char *split = strchr (namePair, ' \n ' );
269+ *split = ' \0 ' ;
270+ char *oldName = split + 1 ;
271+
272+ Nan::Set (historyEntry, Nan::New (" oldName" ).ToLocalChecked (), Nan::New (oldName).ToLocalChecked ());
273+ Nan::Set (historyEntry, Nan::New (" newName" ).ToLocalChecked (), Nan::New (namePair).ToLocalChecked ());
259274 }
260275 Nan::Set (result, Nan::New<Number>(i), historyEntry);
261276
0 commit comments