oracle / opengrok

OpenGrok is a fast and usable source code search and cross reference engine, written in Java
http://oracle.github.io/opengrok/
Other
4.33k stars 746 forks source link

renamed file paths in History should not overlap with file paths in HistoryEntry #3588

Open vladak opened 3 years ago

vladak commented 3 years ago

The renamed file handling in FileHistoryCache is needlessly complex. The way it currently works is that the repository in question will place the renamed files into both the renamedFiles set in the History object as well as the files list in the HistoryEntry objects. The FileHistoryCache#store() then needs to pick them apart: https://github.com/oracle/opengrok/blob/1374d7eaf95a0381acb2a576c1d5590d9d2bf276/opengrok-indexer/src/main/java/org/opengrok/indexer/history/FileHistoryCache.java#L503-L506 and actually reconstruct the set needlessly: https://github.com/oracle/opengrok/blob/1374d7eaf95a0381acb2a576c1d5590d9d2bf276/opengrok-indexer/src/main/java/org/opengrok/indexer/history/FileHistoryCache.java#L526-L536 The store() method should really rely on the renamedFiles set passed in with the History object.

vladak commented 3 years ago

Of course, respective repository code needs to change as well, e.g. https://github.com/oracle/opengrok/blob/1374d7eaf95a0381acb2a576c1d5590d9d2bf276/opengrok-indexer/src/main/java/org/opengrok/indexer/history/GitRepository.java#L620-L628