| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c2f6d81 commit d23ba87
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -175,13 +175,20 @@ void GitRevwalk::FileHistoryWalkWorker::Execute() | |||
| 175 | 175 | const git_diff_delta *delta = git_patch_get_delta(nextPatch); | |
| 176 | 176 | bool isEqualOldFile = !strcmp(delta->old_file.path, baton->file_path); | |
| 177 | 177 | 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); | ||
| 178 | 185 | ||
| 179 | 186 | if (isEqualNewFile) { | |
| 180 | 187 | std::pair<git_commit *, std::pair<char *, git_delta_t> > *historyEntry; | |
| 181 | 188 | if (!isEqualOldFile) { | |
| 182 | 189 | historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t> >( | |
| 183 | 190 | 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) | ||
| 185 | 192 | ); | |
| 186 | 193 | } else { | |
| 187 | 194 | historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t> >( | |
@@ -195,12 +202,14 @@ void GitRevwalk::FileHistoryWalkWorker::Execute() | |||
| 195 | 202 | std::pair<git_commit *, std::pair<char *, git_delta_t> > *historyEntry; | |
| 196 | 203 | historyEntry = new std::pair<git_commit *, std::pair<char *, git_delta_t> >( | |
| 197 | 204 | 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) | ||
| 199 | 206 | ); | |
| 200 | 207 | baton->out->push_back(historyEntry); | |
| 201 | 208 | flag = true; | |
| 202 | 209 | } | |
| 203 | 210 | ||
| 211 | + delete[] outPair; | ||
| 212 | + | ||
| 204 | 213 | git_patch_free(nextPatch); | |
| 205 | 214 | ||
| 206 | 215 | if (flag) { | |
@@ -255,7 +264,13 @@ void GitRevwalk::FileHistoryWalkWorker::HandleOKCallback() | |||
| 255 | 264 | Nan::Set(historyEntry, Nan::New("commit").ToLocalChecked(), GitCommit::New(batonResult->first, true)); | |
| 256 | 265 | Nan::Set(historyEntry, Nan::New("status").ToLocalChecked(), Nan::New<Number>(batonResult->second.second)); | |
| 257 | 266 | 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()); | ||
| 259 | 274 | } | |
| 260 | 275 | Nan::Set(result, Nan::New<Number>(i), historyEntry); | |
| 261 | 276 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,9 @@ Revwalk.prototype.getCommits = function(count) { | |||
| 129 | 129 | * @type {Object} | |
| 130 | 130 | * @property {Commit} commit the commit for this entry | |
| 131 | 131 | * @property {Number} status the status of the file in the commit | |
| 132 | - * @property {String} altname the other name that is provided when status is | ||
| 132 | + * @property {String} newName the new name that is provided when status is | ||
| 133 | + * renamed | ||
| 134 | + * @property {String} oldName the old name that is provided when status is | ||
| 133 | 135 | * renamed | |
| 134 | 136 | */ | |
| 135 | 137 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -286,7 +286,8 @@ describe("Revwalk", function() { | |||
| 286 | 286 | }) | |
| 287 | 287 | .then(function(results) { | |
| 288 | 288 | assert.equal(results[0].status, NodeGit.Diff.DELTA.RENAMED); | |
| 289 | - assert.equal(results[0].altname, fileNameA); | ||
| 289 | + assert.equal(results[0].newName, fileNameB); | ||
| 290 | + assert.equal(results[0].oldName, fileNameA); | ||
| 290 | 291 | }) | |
| 291 | 292 | .then(function() { | |
| 292 | 293 | var walker = repo.createRevWalk(); | |
@@ -296,7 +297,8 @@ describe("Revwalk", function() { | |||
| 296 | 297 | }) | |
| 297 | 298 | .then(function(results) { | |
| 298 | 299 | assert.equal(results[0].status, NodeGit.Diff.DELTA.RENAMED); | |
| 299 | - assert.equal(results[0].altname, fileNameB); | ||
| 300 | + assert.equal(results[0].newName, fileNameB); | ||
| 301 | + assert.equal(results[0].oldName, fileNameA); | ||
| 300 | 302 | }) | |
| 301 | 303 | .then(function() { | |
| 302 | 304 | return fse.remove(repoPath); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments