Skip to content

Commit ed023f9

Browse files
author
Vladimir Kotal
committed
refactor getFilesForCommit(), add javadoc
1 parent 0423d3a commit ed023f9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/GitRepository.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import org.eclipse.jgit.lib.ObjectReader;
7070
import org.eclipse.jgit.lib.PersonIdent;
7171
import org.eclipse.jgit.lib.Ref;
72+
import org.eclipse.jgit.lib.Repository;
7273
import org.eclipse.jgit.revwalk.FollowFilter;
7374
import org.eclipse.jgit.revwalk.RevCommit;
7475
import org.eclipse.jgit.revwalk.RevTree;
@@ -584,8 +585,7 @@ public History getHistory(File file, String sinceRevision, String tillRevision)
584585
}
585586

586587
for (RevCommit commit : walk) {
587-
int numParents = commit.getParentCount();
588-
if (numParents > 1 && !isMergeCommitsEnabled()) {
588+
if (commit.getParentCount() > 1 && !isMergeCommitsEnabled()) {
589589
continue;
590590
}
591591

@@ -597,7 +597,7 @@ public History getHistory(File file, String sinceRevision, String tillRevision)
597597

598598
if (isDirectory) {
599599
SortedSet<String> files = new TreeSet<>();
600-
getFilesForCommit(renamedFiles, repository, commit, numParents, files);
600+
getFilesForCommit(renamedFiles, files, commit, repository);
601601
historyEntry.setFiles(files);
602602
}
603603

@@ -619,8 +619,19 @@ public History getHistory(File file, String sinceRevision, String tillRevision)
619619
return result;
620620
}
621621

622-
private void getFilesForCommit(Set<String> renamedFiles, org.eclipse.jgit.lib.Repository repository,
623-
RevCommit commit, int numParents, SortedSet<String> files) throws IOException {
622+
/**
623+
* Accumulate list of changed files and renamed files (if enabled) for given commit
624+
* @param renamedFiles result containing the renamed files in this commit
625+
* @param files result containing changed files in this commit
626+
* @param commit RevCommit object
627+
* @param repository repository object
628+
* @throws IOException on error traversing the commit tree
629+
*/
630+
private void getFilesForCommit(Set<String> renamedFiles, SortedSet<String> files, RevCommit commit,
631+
Repository repository) throws IOException {
632+
633+
int numParents = commit.getParentCount();
634+
624635
if (numParents == 1) {
625636
getFiles(repository, commit.getParent(0), commit, files, renamedFiles);
626637
} else if (numParents == 0) { // first commit

0 commit comments

Comments
 (0)