69
69
import org .eclipse .jgit .lib .ObjectReader ;
70
70
import org .eclipse .jgit .lib .PersonIdent ;
71
71
import org .eclipse .jgit .lib .Ref ;
72
+ import org .eclipse .jgit .lib .Repository ;
72
73
import org .eclipse .jgit .revwalk .FollowFilter ;
73
74
import org .eclipse .jgit .revwalk .RevCommit ;
74
75
import org .eclipse .jgit .revwalk .RevTree ;
@@ -584,8 +585,7 @@ public History getHistory(File file, String sinceRevision, String tillRevision)
584
585
}
585
586
586
587
for (RevCommit commit : walk ) {
587
- int numParents = commit .getParentCount ();
588
- if (numParents > 1 && !isMergeCommitsEnabled ()) {
588
+ if (commit .getParentCount () > 1 && !isMergeCommitsEnabled ()) {
589
589
continue ;
590
590
}
591
591
@@ -597,7 +597,7 @@ public History getHistory(File file, String sinceRevision, String tillRevision)
597
597
598
598
if (isDirectory ) {
599
599
SortedSet <String > files = new TreeSet <>();
600
- getFilesForCommit (renamedFiles , repository , commit , numParents , files );
600
+ getFilesForCommit (renamedFiles , files , commit , repository );
601
601
historyEntry .setFiles (files );
602
602
}
603
603
@@ -619,8 +619,19 @@ public History getHistory(File file, String sinceRevision, String tillRevision)
619
619
return result ;
620
620
}
621
621
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
+
624
635
if (numParents == 1 ) {
625
636
getFiles (repository , commit .getParent (0 ), commit , files , renamedFiles );
626
637
} else if (numParents == 0 ) { // first commit
0 commit comments