@@ -139,7 +139,22 @@ object CommitCrawler {
139139 Logger .printCommit(commit.shortMessage, commit.name, perc)
140140
141141 val diffEntries = df.scan(parentCommit, commit)
142- val diffEdits = diffEntries.map { diff ->
142+ val diffEdits = diffEntries
143+ .filter { diff ->
144+ diff.changeType != DiffEntry .ChangeType .COPY
145+ }
146+ .filter { diff ->
147+ val fileId =
148+ if (diff.getNewPath() != DiffEntry .DEV_NULL ) {
149+ diff.getNewId().toObjectId()
150+ } else {
151+ diff.getOldId().toObjectId()
152+ }
153+ val stream = try { repo.open(fileId).openStream() }
154+ catch (e: Exception ) { null }
155+ stream != null && ! RawText .isBinary(stream)
156+ }
157+ .map { diff ->
143158 JgitDiff (diff, df.toFileHeader(diff).toEditList())
144159 }
145160 subscriber.onNext(JgitPair (commit, diffEdits))
@@ -180,18 +195,6 @@ object CommitCrawler {
180195 private fun getDiffFiles (jgitRepo : Repository ,
181196 jgitDiffs : List <JgitDiff >) : List <DiffFile > {
182197 return jgitDiffs
183- // Skip binary files.
184- .filter { (diff, _) ->
185- val fileId =
186- if (diff.getNewPath() != DiffEntry .DEV_NULL ) {
187- diff.getNewId().toObjectId()
188- } else {
189- diff.getOldId().toObjectId()
190- }
191- val stream = try { jgitRepo.open(fileId).openStream() }
192- catch (e: Exception ) { null }
193- stream != null && ! RawText .isBinary(stream)
194- }
195198 .map { (diff, edits) ->
196199 // TODO(anatoly): Can produce exception for large object.
197200 // Investigate for size.
0 commit comments