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

Optimize rename detection in historywalk by implausible · Pull Request #900 · nodegit/nodegit · GitHub

Repository navigation

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .cc  (1) All 1 file type 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
Next Next commit
Optimize rename detection in historywalk
  • Loading branch information
implausible committed Feb 9, 2016
commit c2f6d811a07cd627d7b6f34fa6f12bc28ca66d29
39 changes: 33 additions & 6 deletions generate/templates/manual/revwalk/file_history_walk.cc
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 @@ -55,6 +55,10 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
}

git_diff *diffs;
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
char *file_path = strdup(baton->file_path);
opts.pathspec.strings = &file_path;
opts.pathspec.count = 1;
git_commit *parent;
unsigned int parents = git_commit_parentcount(nextCommit);
if (parents > 1) {
Expand All @@ -67,19 +71,23 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
}
if (
(baton->error_code = git_commit_tree(&parentTree, parent)) != GIT_OK ||
(baton->error_code = git_diff_tree_to_tree(&diffs, repo, parentTree, thisTree, NULL)) != GIT_OK
(baton->error_code = git_diff_tree_to_tree(&diffs, repo, parentTree, thisTree, &opts)) != GIT_OK
) {
git_commit_free(nextCommit);
git_commit_free(parent);
break;
}
} else {
if ((baton->error_code = git_diff_tree_to_tree(&diffs, repo, NULL, thisTree, NULL)) != GIT_OK) {
if ((baton->error_code = git_diff_tree_to_tree(&diffs, repo, NULL, thisTree, &opts)) != GIT_OK) {
git_commit_free(nextCommit);
break;
}
}

free(file_path);
opts.pathspec.strings = NULL;
opts.pathspec.count = 0;

bool flag = false;
bool doRenamedPass = false;
unsigned int numDeltas = git_diff_num_deltas(diffs);
Expand Down Expand Up @@ -127,10 +135,29 @@ void GitRevwalk::FileHistoryWalkWorker::Execute()
}
}

if (
doRenamedPass &&
(baton->error_code = git_diff_find_similar(diffs, NULL)) == GIT_OK
) {
if (doRenamedPass) {
git_diff_free(diffs);

if (parents == 1) {
if ((baton->error_code = git_diff_tree_to_tree(&diffs, repo, parentTree, thisTree, NULL)) != GIT_OK) {
git_commit_free(nextCommit);
break;
}
if ((baton->error_code = git_diff_find_similar(diffs, NULL)) != GIT_OK) {
git_commit_free(nextCommit);
break;
}
} else {
if ((baton->error_code = git_diff_tree_to_tree(&diffs, repo, NULL, thisTree, NULL)) != GIT_OK) {
git_commit_free(nextCommit);
break;
}
if((baton->error_code = git_diff_find_similar(diffs, NULL)) != GIT_OK) {
git_commit_free(nextCommit);
break;
}
}

flag = false;
numDeltas = git_diff_num_deltas(diffs);
for (unsigned int j = 0; j < numDeltas; ++j) {
Expand Down

Back | FazBrowse Home | New Git URL