Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: eclipse-jgit/jgit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: GitLiveApp/kgit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 17 commits
  • 218 files changed
  • 1 contributor

Commits on May 10, 2024

  1. Rename .java to .kt

    nbransby committed May 10, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    6527fb3 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    3bd4a41 View commit details
  3. Update README.md

    Signed-off-by: Nicholas Bransby-Williams <nbransby@gmail.com>
    nbransby authored May 10, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    b794cb1 View commit details

Commits on May 15, 2024

  1. .idea folder

    nbransby committed May 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    25b25ad View commit details
  2. Rename .java to .kt

    nbransby committed May 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    db78486 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    7050923 View commit details
  4. make MAX_BASES a const

    nbransby committed May 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    69d9928 View commit details
  5. Rename .java to .kt

    nbransby committed May 15, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    c3bc9bf View commit details
  6. Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    3a7818d View commit details
  7. Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    cb382ef View commit details

Commits on May 16, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    5002934 View commit details
  2. remove unneeded @JvmField

    nbransby committed May 16, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    23ed3b1 View commit details

Commits on May 18, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    01bab91 View commit details
  2. Rename .java to .kt

    nbransby committed May 18, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    edf33ee View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    cd6ffb8 View commit details

Commits on May 19, 2024

  1. Rename .java to .kt

    nbransby committed May 19, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    ef6ba0f View commit details
  2. convert HistogramDiff

    nbransby committed May 19, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    thomaseizinger Thomas Eizinger
    Copy the full SHA
    011589f View commit details
Showing with 16,043 additions and 15,885 deletions.
  1. +3 −0 .idea/.gitignore
  2. +250 −0 .idea/compiler.xml
  3. +74 −0 .idea/encodings.xml
  4. +25 −0 .idea/jarRepositories.xml
  5. +6 −0 .idea/kotlinc.xml
  6. +12 −0 .idea/misc.xml
  7. +6 −0 .idea/vcs.xml
  8. +3 −3 README.md
  9. +20 −20 org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java
  10. +12 −12 org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditTest.java
  11. +2 −2 org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextLoadTest.java
  12. +1 −1 org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
  13. +1 −1 org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/GitlinkMergeTest.java
  14. +65 −1 org.eclipse.jgit/pom.xml
  15. +0 −539 org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
  16. +492 −0 org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.kt
  17. +10 −10 org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java
  18. +0 −240 org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffAlgorithm.java
  19. +244 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffAlgorithm.kt
  20. +10 −10 org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
  21. +0 −262 org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
  22. +230 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.kt
  23. +0 −56 org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java
  24. +51 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.kt
  25. +0 −41 org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequence.java
  26. +32 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequence.kt
  27. +0 −47 org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequenceComparator.java
  28. +43 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequenceComparator.kt
  29. +0 −88 org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequencePair.java
  30. +74 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequencePair.kt
  31. +0 −188 org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java
  32. +173 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.kt
  33. +0 −306 org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiffIndex.java
  34. +296 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiffIndex.kt
  35. +0 −64 org.eclipse.jgit/src/org/eclipse/jgit/diff/LowLevelDiffAlgorithm.java
  36. +65 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/LowLevelDiffAlgorithm.kt
  37. +0 −556 org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java
  38. +577 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.kt
  39. +0 −581 org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
  40. +581 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.kt
  41. +0 −309 org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.java
  42. +312 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.kt
  43. +19 −16 org.eclipse.jgit/src/org/eclipse/jgit/diff/{Sequence.java → Sequence.kt}
  44. +0 −100 org.eclipse.jgit/src/org/eclipse/jgit/diff/SequenceComparator.java
  45. +99 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/SequenceComparator.kt
  46. +0 −131 org.eclipse.jgit/src/org/eclipse/jgit/diff/Subsequence.java
  47. +111 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/Subsequence.kt
  48. +0 −48 org.eclipse.jgit/src/org/eclipse/jgit/diff/SubsequenceComparator.java
  49. +39 −0 org.eclipse.jgit/src/org/eclipse/jgit/diff/SubsequenceComparator.kt
  50. +0 −65 org.eclipse.jgit/src/org/eclipse/jgit/errors/AmbiguousObjectException.java
  51. +52 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/AmbiguousObjectException.kt
  52. +13 −12 org.eclipse.jgit/src/org/eclipse/jgit/errors/{BinaryBlobException.java → BinaryBlobException.kt}
  53. +13 −15 org.eclipse.jgit/src/org/eclipse/jgit/errors/{CancelledException.java → CancelledException.kt}
  54. +0 −69 org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.java
  55. +68 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/CheckoutConflictException.kt
  56. +0 −60 org.eclipse.jgit/src/org/eclipse/jgit/errors/CommandFailedException.java
  57. +58 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/CommandFailedException.kt
  58. +0 −58 org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java
  59. +40 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.kt
  60. +0 −40 org.eclipse.jgit/src/org/eclipse/jgit/errors/ConfigInvalidException.java
  61. +37 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/ConfigInvalidException.kt
  62. +0 −114 org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.java
  63. +121 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.kt
  64. +0 −61 org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptPackIndexException.java
  65. +57 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptPackIndexException.kt
  66. +0 −52 org.eclipse.jgit/src/org/eclipse/jgit/errors/DiffInterruptedException.java
  67. +48 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/DiffInterruptedException.kt
  68. +0 −55 org.eclipse.jgit/src/org/eclipse/jgit/errors/DirCacheNameConflictException.java
  69. +42 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/DirCacheNameConflictException.kt
  70. +0 −34 org.eclipse.jgit/src/org/eclipse/jgit/errors/EntryExistsException.java
  71. +31 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/EntryExistsException.kt
  72. +12 −13 ...t/src/org/eclipse/jgit/errors/{IllegalTodoFileModification.java → IllegalTodoFileModification.kt}
  73. +0 −55 org.eclipse.jgit/src/org/eclipse/jgit/errors/IncorrectObjectTypeException.java
  74. +50 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/IncorrectObjectTypeException.kt
  75. +29 −33 org.eclipse.jgit/src/org/eclipse/jgit/errors/{IndexReadException.java → IndexReadException.kt}
  76. +26 −30 org.eclipse.jgit/src/org/eclipse/jgit/errors/{IndexWriteException.java → IndexWriteException.kt}
  77. +0 −58 org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.java
  78. +54 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidObjectIdException.kt
  79. +0 −61 org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidPatternException.java
  80. +54 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/InvalidPatternException.kt
  81. +0 −153 org.eclipse.jgit/src/org/eclipse/jgit/errors/LargeObjectException.java
  82. +144 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/LargeObjectException.kt
  83. +0 −74 org.eclipse.jgit/src/org/eclipse/jgit/errors/LockFailedException.java
  84. +67 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/LockFailedException.kt
  85. +0 −51 org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java
  86. +48 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.kt
  87. +0 −78 org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java
  88. +81 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.kt
  89. +0 −51 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoClosingBracketException.java
  90. +58 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoClosingBracketException.kt
  91. +0 −95 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoMergeBaseException.java
  92. +99 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoMergeBaseException.kt
  93. +13 −15 ...se.jgit/src/org/eclipse/jgit/errors/{NoPackSignatureException.java → NoPackSignatureException.kt}
  94. +0 −47 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoRemoteRepositoryException.java
  95. +44 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoRemoteRepositoryException.kt
  96. +0 −28 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoWorkTreeException.java
  97. +22 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/NoWorkTreeException.kt
  98. +0 −44 org.eclipse.jgit/src/org/eclipse/jgit/errors/NotSupportedException.java
  99. +42 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/NotSupportedException.kt
  100. +0 −42 org.eclipse.jgit/src/org/eclipse/jgit/errors/ObjectWritingException.java
  101. +40 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/ObjectWritingException.kt
  102. +0 −74 org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java
  103. +64 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.kt
  104. +0 −54 org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java
  105. +44 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.kt
  106. +0 −74 org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java
  107. +72 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.kt
  108. +18 −19 ....jgit/src/org/eclipse/jgit/errors/{RemoteRepositoryException.java → RemoteRepositoryException.kt}
  109. +0 −71 org.eclipse.jgit/src/org/eclipse/jgit/errors/RepositoryNotFoundException.java
  110. +63 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/RepositoryNotFoundException.kt
  111. +17 −18 org.eclipse.jgit/src/org/eclipse/jgit/errors/{RevWalkException.java → RevWalkException.kt}
  112. +0 −56 org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java
  113. +52 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.kt
  114. +0 −42 org.eclipse.jgit/src/org/eclipse/jgit/errors/SearchForReuseTimeout.java
  115. +43 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/SearchForReuseTimeout.kt
  116. +5 −10 org.eclipse.jgit/src/org/eclipse/jgit/errors/{StopWalkException.java → StopWalkException.kt}
  117. +0 −29 org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.java
  118. +27 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/StoredObjectRepresentationNotAvailableException.kt
  119. +12 −14 ...c/org/eclipse/jgit/errors/{SymlinksNotSupportedException.java → SymlinksNotSupportedException.kt}
  120. +0 −66 org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargeObjectInPackException.java
  121. +70 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargeObjectInPackException.kt
  122. +0 −49 org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargePackException.java
  123. +49 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/TooLargePackException.kt
  124. +0 −60 org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleException.java
  125. +49 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleException.kt
  126. +0 −40 org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleLoadingException.java
  127. +41 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleLoadingException.kt
  128. +0 −53 org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationStringMissingException.java
  129. +49 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationStringMissingException.kt
  130. +0 −76 org.eclipse.jgit/src/org/eclipse/jgit/errors/TransportException.java
  131. +73 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/TransportException.kt
  132. +0 −46 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnmergedPathException.java
  133. +37 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnmergedPathException.kt
  134. +0 −33 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnpackException.java
  135. +32 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnpackException.kt
  136. +0 −35 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedCredentialItem.java
  137. +34 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedCredentialItem.kt
  138. +0 −36 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedPackIndexVersionException.java
  139. +37 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedPackIndexVersionException.kt
  140. +0 −36 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedPackVersionException.java
  141. +37 −0 org.eclipse.jgit/src/org/eclipse/jgit/errors/UnsupportedPackVersionException.kt
  142. +1 −1 org.eclipse.jgit/src/org/eclipse/jgit/errors/{package-info.java → package-info.kt}
  143. +0 −554 org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
  144. +547 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.kt
  145. +0 −86 org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncObjectLoaderQueue.java
  146. +84 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncObjectLoaderQueue.kt
  147. +0 −67 org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncObjectSizeQueue.java
  148. +65 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncObjectSizeQueue.kt
  149. +0 −44 org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncOperation.java
  150. +43 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncOperation.kt
  151. +14 −15 org.eclipse.jgit/src/org/eclipse/jgit/lib/{BitmapObject.java → BitmapObject.kt}
  152. +0 −24 org.eclipse.jgit/src/org/eclipse/jgit/lib/CheckoutEntry.java
  153. +22 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/CheckoutEntry.kt
  154. +0 −1,015 org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
  155. +1,011 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.kt
  156. +0 −783 org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
  157. +806 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.kt
  158. +0 −95 org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgObjectSigner.java
  159. +100 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgObjectSigner.kt
  160. +0 −285 org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java
  161. +270 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.kt
  162. +0 −32 org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSet.java
  163. +32 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSet.kt
  164. +0 −77 org.eclipse.jgit/src/org/eclipse/jgit/lib/ProgressMonitor.java
  165. +80 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/ProgressMonitor.kt
  166. +0 −89 org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogEntry.java
  167. +92 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogEntry.kt
  168. +0 −63 org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.java
  169. +50 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.kt
  170. +0 −39 org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryBuilder.java
  171. +35 −0 org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryBuilder.kt
  172. +8 −10 ...lipse.jgit/src/org/eclipse/jgit/lib/{RepositoryBuilderFactory.java → RepositoryBuilderFactory.kt}
  173. +8 −9 org.eclipse.jgit/src/org/eclipse/jgit/merge/{ContentMergeStrategy.java → ContentMergeStrategy.kt}
  174. +39 −48 org.eclipse.jgit/src/org/eclipse/jgit/merge/{EolAwareOutputStream.java → EolAwareOutputStream.kt}
  175. +0 −386 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java
  176. +402 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.kt
  177. +0 −128 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeChunk.java
  178. +100 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeChunk.kt
  179. +0 −171 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java
  180. +154 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.kt
  181. +0 −217 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java
  182. +235 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.kt
  183. +0 −176 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.java
  184. +145 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.kt
  185. +0 −161 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java
  186. +181 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.kt
  187. +0 −149 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java
  188. +135 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.kt
  189. +0 −162 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.java
  190. +175 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.kt
  191. +0 −344 org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java
  192. +335 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.kt
  193. +0 −239 org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.java
  194. +229 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.kt
  195. +0 −1,952 org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
  196. +2,034 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.kt
  197. +0 −73 org.eclipse.jgit/src/org/eclipse/jgit/merge/SquashMessageFormatter.java
  198. +64 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/SquashMessageFormatter.kt
  199. +0 −94 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyOneSided.java
  200. +70 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyOneSided.kt
  201. +0 −43 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyRecursive.java
  202. +36 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyRecursive.kt
  203. +0 −41 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyResolve.java
  204. +35 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyResolve.kt
  205. +0 −179 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategySimpleTwoWayInCore.java
  206. +161 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategySimpleTwoWayInCore.kt
  207. +5 −8 org.eclipse.jgit/src/org/eclipse/jgit/merge/{ThreeWayMergeStrategy.java → ThreeWayMergeStrategy.kt}
  208. +0 −125 org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java
  209. +113 −0 org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.kt
  210. +1 −1 org.eclipse.jgit/src/org/eclipse/jgit/merge/{package-info.java → package-info.kt}
  211. +2 −2 org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java
  212. +0 −239 org.eclipse.jgit/src/org/eclipse/jgit/util/IntList.java
  213. +228 −0 org.eclipse.jgit/src/org/eclipse/jgit/util/IntList.kt
  214. +5 −5 org.eclipse.jgit/src/org/eclipse/jgit/util/{MutableInteger.java → MutableInteger.kt}
  215. +0 −1,407 org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java
  216. +1,503 −0 org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.kt
  217. +0 −61 org.eclipse.jgit/src/org/eclipse/jgit/util/time/MonotonicClock.java
  218. +62 −0 org.eclipse.jgit/src/org/eclipse/jgit/util/time/MonotonicClock.kt
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

250 changes: 250 additions & 0 deletions .idea/compiler.xml

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions .idea/encodings.xml
25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml
6 changes: 6 additions & 0 deletions .idea/kotlinc.xml
12 changes: 12 additions & 0 deletions .idea/misc.xml
6 changes: 6 additions & 0 deletions .idea/vcs.xml
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Java Git
# Kotlin Git

An implementation of the Git version control system in pure Java.
An fork of the JGit project translated to Kotlin.

This project is licensed under the __EDL__ (Eclipse Distribution
License).

JGit can be imported straight into Eclipse and built and tested from
KGit can be imported straight into IntelliJ and built and tested from
there. It can be built from the command line using
[Maven](https://maven.apache.org/) or [Bazel](https://bazel.build/).
The CI builds use Maven and run on [Jenkins](https://ci.eclipse.org/jgit/).
Original file line number Diff line number Diff line change
@@ -123,10 +123,10 @@ public void testCreateFileHeader_Add() throws Exception {
assertEquals(1, el.size());

Edit e = el.get(0);
assertEquals(0, e.getBeginA());
assertEquals(0, e.getEndA());
assertEquals(0, e.getBeginB());
assertEquals(2, e.getEndB());
assertEquals(0, e.beginA);
assertEquals(0, e.endA);
assertEquals(0, e.beginB);
assertEquals(2, e.endB);
assertEquals(Edit.Type.INSERT, e.getType());
}

@@ -159,10 +159,10 @@ public void testCreateFileHeader_Delete() throws Exception {
assertEquals(1, el.size());

Edit e = el.get(0);
assertEquals(0, e.getBeginA());
assertEquals(2, e.getEndA());
assertEquals(0, e.getBeginB());
assertEquals(0, e.getEndB());
assertEquals(0, e.beginA);
assertEquals(2, e.endA);
assertEquals(0, e.beginB);
assertEquals(0, e.endB);
assertEquals(Edit.Type.DELETE, e.getType());
}

@@ -194,10 +194,10 @@ public void testCreateFileHeader_Modify() throws Exception {
assertEquals(1, el.size());

Edit e = el.get(0);
assertEquals(1, e.getBeginA());
assertEquals(1, e.getEndA());
assertEquals(1, e.getBeginB());
assertEquals(3, e.getEndB());
assertEquals(1, e.beginA);
assertEquals(1, e.endA);
assertEquals(1, e.beginB);
assertEquals(3, e.endB);
assertEquals(Edit.Type.INSERT, e.getType());
}

@@ -273,10 +273,10 @@ public void testCreateFileHeader_AddGitLink() throws Exception {
assertEquals(1, el.size());

Edit e = el.get(0);
assertEquals(0, e.getBeginA());
assertEquals(0, e.getEndA());
assertEquals(0, e.getBeginB());
assertEquals(1, e.getEndB());
assertEquals(0, e.beginA);
assertEquals(0, e.endA);
assertEquals(0, e.beginB);
assertEquals(1, e.endB);
assertEquals(Edit.Type.INSERT, e.getType());
}

@@ -304,10 +304,10 @@ public void testCreateFileHeader_DeleteGitLink() throws Exception {
assertEquals(1, el.size());

Edit e = el.get(0);
assertEquals(0, e.getBeginA());
assertEquals(1, e.getEndA());
assertEquals(0, e.getBeginB());
assertEquals(0, e.getEndB());
assertEquals(0, e.beginA);
assertEquals(1, e.endA);
assertEquals(0, e.beginB);
assertEquals(0, e.endB);
assertEquals(Edit.Type.DELETE, e.getType());
}

24 changes: 12 additions & 12 deletions org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/EditTest.java
Original file line number Diff line number Diff line change
@@ -22,19 +22,19 @@ public class EditTest {
@Test
public void testCreate() {
final Edit e = new Edit(1, 2, 3, 4);
assertEquals(1, e.getBeginA());
assertEquals(2, e.getEndA());
assertEquals(3, e.getBeginB());
assertEquals(4, e.getEndB());
assertEquals(1, e.beginA);
assertEquals(2, e.endA);
assertEquals(3, e.beginB);
assertEquals(4, e.endB);
}

@Test
public void testCreateEmpty() {
final Edit e = new Edit(1, 3);
assertEquals(1, e.getBeginA());
assertEquals(1, e.getEndA());
assertEquals(3, e.getBeginB());
assertEquals(3, e.getEndB());
assertEquals(1, e.beginA);
assertEquals(1, e.endA);
assertEquals(3, e.beginB);
assertEquals(3, e.endB);
assertTrue("is empty", e.isEmpty());
assertSame(Edit.Type.EMPTY, e.getType());
}
@@ -43,10 +43,10 @@ public void testCreateEmpty() {
public void testSwap() {
final Edit e = new Edit(1, 2, 3, 4);
e.swap();
assertEquals(3, e.getBeginA());
assertEquals(4, e.getEndA());
assertEquals(1, e.getBeginB());
assertEquals(2, e.getEndB());
assertEquals(3, e.beginA);
assertEquals(4, e.endA);
assertEquals(1, e.beginB);
assertEquals(2, e.endB);
}

@Test
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ private RawText textFor(byte[] data, int limit) throws IOException, BinaryBlobEx
public void testSmallOK() throws Exception {
byte[] data = generate(1000, -1);
RawText result = textFor(data, 1 << 20);
Assert.assertArrayEquals(result.content, data);
Assert.assertArrayEquals(result.getRawContent(), data);
}

@Test(expected = BinaryBlobException.class)
@@ -60,7 +60,7 @@ public void testSmallNull() throws Exception {
public void testBigOK() throws Exception {
byte[] data = generate(10000, -1);
RawText result = textFor(data, 1 << 20);
Assert.assertArrayEquals(result.content, data);
Assert.assertArrayEquals(result.getRawContent(), data);
}

@Test(expected = BinaryBlobException.class)
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ public void testNul() {
String input = "foo-a\nf\0o-b\n";
byte[] data = Constants.encodeASCII(input);
final RawText a = new RawText(data);
assertArrayEquals(a.content, data);
assertArrayEquals(a.getRawContent(), data);
assertEquals(2, a.size());
assertEquals("foo-a\n", a.getString(0, 1, false));
assertEquals("f\0o-b\n", a.getString(1, 2, false));
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ private Merger newIgnoreConflictMerger() {
@Override
protected boolean mergeImpl() throws IOException {
// emulate call with ignore conflicts.
return mergeTrees(mergeBase(), sourceTrees[0], sourceTrees[1],
return mergeTrees(mergeBase(), getSourceTrees()[0], getSourceTrees()[1],
true);
}
};
66 changes: 65 additions & 1 deletion org.eclipse.jgit/pom.xml
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
<properties>
<translate-qualifier/>
<source-bundle-manifest>${project.build.directory}/META-INF/SOURCE-MANIFEST.MF</source-bundle-manifest>
<kotlin.version>1.9.24</kotlin.version>
</properties>

<dependencies>
@@ -51,11 +52,22 @@
<artifactId>commons-codec</artifactId>
<version>1.16.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<sourceDirectory>src/</sourceDirectory>
<sourceDirectory>src</sourceDirectory>

<resources>
<resource>
@@ -164,6 +176,58 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
539 changes: 0 additions & 539 deletions org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java

This file was deleted.

492 changes: 492 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.kt

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java
Original file line number Diff line number Diff line change
@@ -167,26 +167,26 @@ private static void blame(EditList editList, Candidate a, Candidate b) {
Edit e = editList.get(eIdx);

// Edit ends before the next candidate region. Skip the edit.
if (e.getEndB() <= r.sourceStart) {
if (e.endB <= r.sourceStart) {
eIdx++;
continue;
}

// Next candidate region starts before the edit. Assign some
// of the blame onto A, but possibly split and also on B.
if (r.sourceStart < e.getBeginB()) {
int d = e.getBeginB() - r.sourceStart;
if (r.sourceStart < e.beginB) {
int d = e.beginB - r.sourceStart;
if (r.length <= d) {
// Pass the blame for this region onto A.
Region next = r.next;
r.sourceStart = e.getBeginA() - d;
r.sourceStart = e.beginA - d;
aTail = add(aTail, a, r);
r = next;
continue;
}

// Split the region and assign some to A, some to B.
aTail = add(aTail, a, r.splitFirst(e.getBeginA() - d, d));
aTail = add(aTail, a, r.splitFirst(e.beginA - d, d));
r.slideAndShrink(d);
}

@@ -201,18 +201,18 @@ private static void blame(EditList editList, Candidate a, Candidate b) {

// If the region ends before the edit, blame on B.
int rEnd = r.sourceStart + r.length;
if (rEnd <= e.getEndB()) {
if (rEnd <= e.endB) {
Region next = r.next;
bTail = add(bTail, b, r);
r = next;
if (rEnd == e.getEndB())
if (rEnd == e.endB)
eIdx++;
continue;
}

// This region extends beyond the edit. Blame the first
// half of the region on B, and process the rest after.
int len = e.getEndB() - r.sourceStart;
int len = e.endB - r.sourceStart;
bTail = add(bTail, b, r.splitFirst(r.sourceStart, len));
r.slideAndShrink(len);
eIdx++;
@@ -224,8 +224,8 @@ private static void blame(EditList editList, Candidate a, Candidate b) {
// For any remaining region, pass the blame onto A after shifting
// the source start to account for the difference between the two.
Edit e = editList.get(editList.size() - 1);
int endB = e.getEndB();
int d = endB - e.getEndA();
int endB = e.endB;
int d = endB - e.endA;
if (aTail == null)
a.regionList = r;
else
240 changes: 0 additions & 240 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffAlgorithm.java

This file was deleted.

244 changes: 244 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffAlgorithm.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

import org.eclipse.jgit.diff.EditList.Companion.singleton
import org.eclipse.jgit.diff.Subsequence.Companion.a
import org.eclipse.jgit.diff.Subsequence.Companion.b
import org.eclipse.jgit.diff.Subsequence.Companion.toBase

/**
* Compares two [org.eclipse.jgit.diff.Sequence]s to create an
* [org.eclipse.jgit.diff.EditList] of changes.
*
*
* An algorithm's `diff` method must be callable from concurrent threads
* without data collisions. This permits some algorithms to use a singleton
* pattern, with concurrent invocations using the same singleton. Other
* algorithms may support parameterization, in which case the caller can create
* a unique instance per thread.
*/
abstract class DiffAlgorithm {
/**
* Supported diff algorithm
*/
enum class SupportedAlgorithm {
/**
* Myers diff algorithm
*/
MYERS,

/**
* Histogram diff algorithm
*/
HISTOGRAM
}

/**
* Compare two sequences and identify a list of edits between them.
*
* @param <S>
* type of sequence being compared.
* @param cmp
* the comparator supplying the element equivalence function.
* @param a
* the first (also known as old or pre-image) sequence. Edits
* returned by this algorithm will reference indexes using the
* 'A' side: [org.eclipse.jgit.diff.Edit.getBeginA],
* [org.eclipse.jgit.diff.Edit.getEndA].
* @param b
* the second (also known as new or post-image) sequence. Edits
* returned by this algorithm will reference indexes using the
* 'B' side: [org.eclipse.jgit.diff.Edit.getBeginB],
* [org.eclipse.jgit.diff.Edit.getEndB].
* @return a modifiable edit list comparing the two sequences. If empty, the
* sequences are identical according to `cmp`'s rules. The
* result list is never null.
</S> */
fun <S : Sequence> diff(
cmp: SequenceComparator<in S>, a: S, b: S
): EditList {
val region = cmp.reduceCommonStartEnd(a, b, coverEdit(a, b))

when (region!!.type) {
Edit.Type.INSERT, Edit.Type.DELETE -> return singleton(region)

Edit.Type.REPLACE -> {
if (region.lengthA == 1 && region.lengthB == 1) return singleton(region)

val cs = SubsequenceComparator(cmp)
val `as` = a(a, region)
val bs = b(b, region)
val e: EditList = toBase<S>(diffNonCommon(cs, `as`, bs), `as`, bs)
return normalize(cmp, e, a, b)
}

Edit.Type.EMPTY -> return EditList(0)

else -> throw IllegalStateException()
}
}

/**
* Compare two sequences and identify a list of edits between them.
*
* This method should be invoked only after the two sequences have been
* proven to have no common starting or ending elements. The expected
* elimination of common starting and ending elements is automatically
* performed by the [.diff]
* method, which invokes this method using
* [org.eclipse.jgit.diff.Subsequence]s.
*
* @param <S>
* type of sequence being compared.
* @param cmp
* the comparator supplying the element equivalence function.
* @param a
* the first (also known as old or pre-image) sequence. Edits
* returned by this algorithm will reference indexes using the
* 'A' side: [org.eclipse.jgit.diff.Edit.getBeginA],
* [org.eclipse.jgit.diff.Edit.getEndA].
* @param b
* the second (also known as new or post-image) sequence. Edits
* returned by this algorithm will reference indexes using the
* 'B' side: [org.eclipse.jgit.diff.Edit.getBeginB],
* [org.eclipse.jgit.diff.Edit.getEndB].
* @return a modifiable edit list comparing the two sequences.
</S> */
abstract fun <S : Sequence> diffNonCommon(
cmp: SequenceComparator<in S>, a: S, b: S
): EditList

companion object {
/**
* Get diff algorithm
*
* @param alg
* the diff algorithm for which an implementation should be
* returned
* @return an implementation of the specified diff algorithm
*/
@JvmStatic
fun getAlgorithm(alg: SupportedAlgorithm?): DiffAlgorithm {
return when (alg) {
SupportedAlgorithm.MYERS -> MyersDiff.INSTANCE
SupportedAlgorithm.HISTOGRAM -> HistogramDiff()
else -> throw IllegalArgumentException()
}
}

private fun <S : Sequence?> coverEdit(a: S, b: S): Edit {
return Edit(0, a!!.size(), 0, b!!.size())
}

/**
* Reorganize an [EditList] for better diff consistency.
*
*
* `DiffAlgorithms` may return [Edit.Type.INSERT] or
* [Edit.Type.DELETE] edits that can be "shifted". For
* example, the deleted section
* <pre>
* -a
* -b
* -c
* a
* b
* c
</pre> *
* can be shifted down by 1, 2 or 3 locations.
*
*
* To avoid later merge issues, we shift such edits to a
* consistent location. `normalize` uses a simple strategy of
* shifting such edits to their latest possible location.
*
*
* This strategy may not always produce an aesthetically pleasing
* diff. For instance, it works well with
* <pre>
* function1 {
* ...
* }
*
* +function2 {
* + ...
* +}
* +
* function3 {
* ...
* }
</pre> *
* but less so for
* <pre>
* #
* # comment1
* #
* function1() {
* }
*
* #
* +# comment3
* +#
* +function3() {
* +}
* +
* +#
* # comment2
* #
* function2() {
* }
</pre> *
* [More
* sophisticated strategies](https://github.com/mhagger/diff-slider-tools) are possible, say by calculating a
* suitable "aesthetic cost" for each possible position and using
* the lowest cost, but `normalize` just shifts edits
* to the end as much as possible.
*
* @param <S>
* type of sequence being compared.
* @param cmp
* the comparator supplying the element equivalence function.
* @param e
* a modifiable edit list comparing the provided sequences.
* @param a
* the first (also known as old or pre-image) sequence.
* @param b
* the second (also known as new or post-image) sequence.
* @return a modifiable edit list with edit regions shifted to their
* latest possible location. The result list is never null.
* @since 4.7
</S> */
private fun <S : Sequence> normalize(
cmp: SequenceComparator<in S>, e: EditList, a: S, b: S
): EditList {
var prev: Edit? = null
for (i in e.indices.reversed()) {
val cur = e[i]
val curType = cur.type

val maxA = if ((prev == null)) a.size() else prev.beginA
val maxB = if ((prev == null)) b.size() else prev.beginB

if (curType == Edit.Type.INSERT) {
while (cur.endA < maxA && cur.endB < maxB && cmp.equals(b, cur.beginB, b, cur.endB)) {
cur.shift(1)
}
} else if (curType == Edit.Type.DELETE) {
while (cur.endA < maxA && cur.endB < maxB && cmp.equals(a, cur.beginA, a, cur.endA)) {
cur.shift(1)
}
}
prev = cur
}
return e
}
}
}
20 changes: 10 additions & 10 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
Original file line number Diff line number Diff line change
@@ -786,26 +786,26 @@ public void format(EditList edits, RawText a, RawText b)
final int endIdx = findCombinedEnd(edits, curIdx);
final Edit endEdit = edits.get(endIdx);

int aCur = (int) Math.max(0, (long) curEdit.getBeginA() - context);
int bCur = (int) Math.max(0, (long) curEdit.getBeginB() - context);
final int aEnd = (int) Math.min(a.size(), (long) endEdit.getEndA() + context);
final int bEnd = (int) Math.min(b.size(), (long) endEdit.getEndB() + context);
int aCur = (int) Math.max(0, (long) curEdit.beginA - context);
int bCur = (int) Math.max(0, (long) curEdit.beginB - context);
final int aEnd = (int) Math.min(a.size(), (long) endEdit.endA + context);
final int bEnd = (int) Math.min(b.size(), (long) endEdit.endB + context);

writeHunkHeader(aCur, aEnd, bCur, bEnd);

while (aCur < aEnd || bCur < bEnd) {
if (aCur < curEdit.getBeginA() || endIdx + 1 < curIdx) {
if (aCur < curEdit.beginA || endIdx + 1 < curIdx) {
writeContextLine(a, aCur);
if (isEndOfLineMissing(a, aCur))
out.write(noNewLine);
aCur++;
bCur++;
} else if (aCur < curEdit.getEndA()) {
} else if (aCur < curEdit.endA) {
writeRemovedLine(a, aCur);
if (isEndOfLineMissing(a, aCur))
out.write(noNewLine);
aCur++;
} else if (bCur < curEdit.getEndB()) {
} else if (bCur < curEdit.endB) {
writeAddedLine(b, bCur);
if (isEndOfLineMissing(b, bCur))
out.write(noNewLine);
@@ -1237,14 +1237,14 @@ private int findCombinedEnd(List<Edit> edits, int i) {
}

private boolean combineA(List<Edit> e, int i) {
return e.get(i).getBeginA() - e.get(i - 1).getEndA() <= 2 * context;
return e.get(i).beginA - e.get(i - 1).endA <= 2 * context;
}

private boolean combineB(List<Edit> e, int i) {
return e.get(i).getBeginB() - e.get(i - 1).getEndB() <= 2 * context;
return e.get(i).beginB - e.get(i - 1).endB <= 2 * context;
}

private static boolean end(Edit edit, int a, int b) {
return edit.getEndA() <= a && edit.getEndB() <= b;
return edit.endA <= a && edit.endB <= b;
}
}
262 changes: 0 additions & 262 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java

This file was deleted.

230 changes: 230 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/*
* Copyright (C) 2008-2009, Johannes E. Schindelin <johannes.schindelin@gmx.de> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* A modified region detected between two versions of roughly the same content.
*
*
* An edit covers the modified region only. It does not cover a common region.
*
*
* Regions should be specified using 0 based notation, so add 1 to the start and
* end marks for line numbers in a file.
*
*
* An edit where `beginA == endA && beginB < endB` is an insert edit, that
* is sequence B inserted the elements in region `[beginB, endB)` at
* `beginA`.
*
*
* An edit where `beginA < endA && beginB == endB` is a delete edit, that
* is sequence B has removed the elements between `[beginA, endA)`.
*
*
* An edit where `beginA < endA && beginB < endB` is a replace edit, that
* is sequence B has replaced the range of elements between
* `[beginA, endA)` with those found in `[beginB, endB)`.
*/
class Edit
/**
* Create a new edit.
*
* @param as
* beginA: start of region in sequence A; 0 based.
* @param ae
* endA: end of region in sequence A; must be &gt;= as.
* @param bs
* beginB: start of region in sequence B; 0 based.
* @param be
* endB: end of region in sequence B; must be &gt; = bs.
*/(
/**
* Get start point in sequence A
*
* @return start point in sequence A
*/
@JvmField var beginA: Int,
/**
* Get end point in sequence A
*
* @return end point in sequence A
*/
@JvmField var endA: Int,
/**
* Get start point in sequence B
*
* @return start point in sequence B
*/
@JvmField var beginB: Int,
/**
* Get end point in sequence B
*
* @return end point in sequence B
*/
@JvmField var endB: Int
) {
/** Type of edit */
enum class Type {
/** Sequence B has inserted the region. */
INSERT,

/** Sequence B has removed the region. */
DELETE,

/** Sequence B has replaced the region with different content. */
REPLACE,

/** Sequence A and B have zero length, describing nothing. */
EMPTY
}

/**
* Create a new empty edit.
*
* @param as
* beginA: start and end of region in sequence A; 0 based.
* @param bs
* beginB: start and end of region in sequence B; 0 based.
*/
constructor(`as`: Int, bs: Int) : this(`as`, `as`, bs, bs)

val type: Type
/**
* Get type
*
* @return the type of this region
*/
get() {
if (beginA < endA) {
if (beginB < endB) {
return Type.REPLACE
}
return Type.DELETE
}
if (beginB < endB) {
return Type.INSERT
}
// beginB == endB)
return Type.EMPTY
}

val isEmpty: Boolean
/**
* Whether edit is empty
*
* @return `true` if the edit is empty (lengths of both a and b is
* zero)
*/
get() = beginA == endA && beginB == endB

val lengthA: Int
/**
* Get length of the region in A
*
* @return length of the region in A
*/
get() = endA - beginA

val lengthB: Int
/**
* Get length of the region in B
*
* @return return length of the region in B
*/
get() = endB - beginB

/**
* Move the edit region by the specified amount.
*
* @param amount
* the region is shifted by this amount, and can be positive or
* negative.
* @since 4.8
*/
fun shift(amount: Int) {
beginA += amount
endA += amount
beginB += amount
endB += amount
}

/**
* Construct a new edit representing the region before cut.
*
* @param cut
* the cut point. The beginning A and B points are used as the
* end points of the returned edit.
* @return an edit representing the slice of `this` edit that occurs
* before `cut` starts.
*/
fun before(cut: Edit): Edit {
return Edit(beginA, cut.beginA, beginB, cut.beginB)
}

/**
* Construct a new edit representing the region after cut.
*
* @param cut
* the cut point. The ending A and B points are used as the
* starting points of the returned edit.
* @return an edit representing the slice of `this` edit that occurs
* after `cut` ends.
*/
fun after(cut: Edit): Edit {
return Edit(cut.endA, endA, cut.endB, endB)
}

/**
* Increase [.getEndA] by 1.
*/
fun extendA() {
endA++
}

/**
* Increase [.getEndB] by 1.
*/
fun extendB() {
endB++
}

/**
* Swap A and B, so the edit goes the other direction.
*/
fun swap() {
val sBegin = beginA
val sEnd = endA

beginA = beginB
endA = endB

beginB = sBegin
endB = sEnd
}

override fun hashCode(): Int {
return beginA xor endA
}

override fun equals(other: Any?): Boolean {
if (other is Edit) {
val e = other
return this.beginA == e.beginA && (this.endA == e.endA
) && (this.beginB == e.beginB) && (this.endB == e.endB)
}
return false
}

override fun toString(): String {
val t = type
return "$t($beginA-$endA,$beginB-$endB)"
}
}
56 changes: 0 additions & 56 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java

This file was deleted.

51 changes: 51 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2009, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Specialized list of [org.eclipse.jgit.diff.Edit]s in a document.
*/
class EditList : ArrayList<Edit> {
/**
* Create a new, empty edit list.
*/
constructor() : super(16)

/**
* Create an empty edit list with the specified capacity.
*
* @param capacity
* the initial capacity of the edit list. If additional edits are
* added to the list, it will be grown to support them.
*/
constructor(capacity: Int) : super(capacity)

override fun toString(): String {
return "EditList" + super.toString() //$NON-NLS-1$
}

companion object {
private const val serialVersionUID = 1L

/**
* Construct an edit list containing a single edit.
*
* @param edit
* the edit to return in the list.
* @return list containing only `edit`.
*/
@JvmStatic
fun singleton(edit: Edit): EditList {
val res = EditList(1)
res.add(edit)
return res
}
}
}
41 changes: 0 additions & 41 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequence.java

This file was deleted.

32 changes: 32 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequence.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Wraps a [org.eclipse.jgit.diff.Sequence] to assign hash codes to
* elements.
*
*
* This sequence acts as a proxy for the real sequence, caching element hash
* codes so they don't need to be recomputed each time. Sequences of this type
* must be used with a [org.eclipse.jgit.diff.HashedSequenceComparator].
*
*
* To construct an instance of this type use
* [org.eclipse.jgit.diff.HashedSequencePair].
*
* @param <S>
* the base sequence type.
</S> */
class HashedSequence<S : Sequence> internal constructor(val base: S, val hashes: IntArray) : Sequence() {
override fun size(): Int {
return base.size()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Wrap another comparator for use with
* [org.eclipse.jgit.diff.HashedSequence].
*
*
* This comparator acts as a proxy for the real comparator, evaluating the
* cached hash code before testing the underlying comparator's equality.
* Comparators of this type must be used with a
* [org.eclipse.jgit.diff.HashedSequence].
*
*
* To construct an instance of this type use
* [org.eclipse.jgit.diff.HashedSequencePair].
*
* @param <S>
* the base sequence type.
</S> */
class HashedSequenceComparator<S : Sequence> internal constructor(private val cmp: SequenceComparator<in S>) :
SequenceComparator<HashedSequence<S>>() {

override fun equals(
a: HashedSequence<S>, ai: Int, //
b: HashedSequence<S>, bi: Int
): Boolean {
return (a.hashes[ai] == b.hashes[bi]
&& cmp.equals(a.base, ai, b.base, bi))
}

override fun hash(seq: HashedSequence<S>, ptr: Int): Int {
return seq.hashes[ptr]
}
}
88 changes: 0 additions & 88 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequencePair.java

This file was deleted.

74 changes: 74 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HashedSequencePair.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Wraps two [org.eclipse.jgit.diff.Sequence] instances to cache their
* element hash codes.
*
*
* This pair wraps two sequences that contain cached hash codes for the input
* sequences.
*
* @param <S>
* the base sequence type.
</S> */
class HashedSequencePair<S : Sequence>
/**
* Construct a pair to provide fast hash codes.
*
* @param cmp
* the base comparator for the sequence elements.
* @param a
* the A sequence.
* @param b
* the B sequence.
*/(private val cmp: SequenceComparator<in S>, private val baseA: S, private val baseB: S) {
private var cachedA: HashedSequence<S>? = null

private var cachedB: HashedSequence<S>? = null

val comparator: HashedSequenceComparator<S>
/**
* Get comparator
*
* @return obtain a comparator that uses the cached hash codes
*/
get() = HashedSequenceComparator(cmp)

val a: HashedSequence<S>
/**
* Get A
*
* @return wrapper around A that includes cached hash codes
*/
get() {
if (cachedA == null) cachedA = wrap(baseA)
return cachedA!!
}

val b: HashedSequence<S>
/**
* Get B
*
* @return wrapper around B that includes cached hash codes
*/
get() {
if (cachedB == null) cachedB = wrap(baseB)
return cachedB!!
}

private fun wrap(base: S): HashedSequence<S> {
val end = base.size()
val hashes = IntArray(end)
for (ptr in 0 until end) hashes[ptr] = cmp.hash(base, ptr)
return HashedSequence(base, hashes)
}
}
188 changes: 0 additions & 188 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.java

This file was deleted.

173 changes: 173 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiff.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

import org.eclipse.jgit.diff.Subsequence.Companion.a
import org.eclipse.jgit.diff.Subsequence.Companion.b
import org.eclipse.jgit.diff.Subsequence.Companion.toBase

/**
* An extended form of Bram Cohen's patience diff algorithm.
*
*
* This implementation was derived by using the 4 rules that are outlined in
* Bram Cohen's [blog](http://bramcohen.livejournal.com/73318.html),
* and then was further extended to support low-occurrence common elements.
*
*
* The basic idea of the algorithm is to create a histogram of occurrences for
* each element of sequence A. Each element of sequence B is then considered in
* turn. If the element also exists in sequence A, and has a lower occurrence
* count, the positions are considered as a candidate for the longest common
* subsequence (LCS). After scanning of B is complete the LCS that has the
* lowest number of occurrences is chosen as a split point. The region is split
* around the LCS, and the algorithm is recursively applied to the sections
* before and after the LCS.
*
*
* By always selecting a LCS position with the lowest occurrence count, this
* algorithm behaves exactly like Bram Cohen's patience diff whenever there is a
* unique common element available between the two sequences. When no unique
* elements exist, the lowest occurrence element is chosen instead. This offers
* more readable diffs than simply falling back on the standard Myers' O(ND)
* algorithm would produce.
*
*
* To prevent the algorithm from having an O(N^2) running time, an upper limit
* on the number of unique elements in a histogram bucket is configured by
* [.setMaxChainLength]. If sequence A has more than this many
* elements that hash into the same hash bucket, the algorithm passes the region
* to [.setFallbackAlgorithm]. If no fallback algorithm is
* configured, the region is emitted as a replace edit.
*
*
* During scanning of sequence B, any element of A that occurs more than
* [.setMaxChainLength] times is never considered for an LCS match
* position, even if it is common between the two sequences. This limits the
* number of locations in sequence A that must be considered to find the LCS,
* and helps maintain a lower running time bound.
*
*
* So long as [.setMaxChainLength] is a small constant (such as 64),
* the algorithm runs in O(N * D) time, where N is the sum of the input lengths
* and D is the number of edits in the resulting EditList. If the supplied
* [org.eclipse.jgit.diff.SequenceComparator] has a good hash function,
* this implementation typically out-performs
* [org.eclipse.jgit.diff.MyersDiff], even though its theoretical running
* time is the same.
*
*
* This implementation has an internal limitation that prevents it from handling
* sequences with more than 268,435,456 (2^28) elements.
*/
class HistogramDiff : LowLevelDiffAlgorithm() {
/** Algorithm to use when there are too many element occurrences. */
var fallback: DiffAlgorithm? = MyersDiff.INSTANCE

/**
* Maximum number of positions to consider for a given element hash.
*
* All elements with the same hash are stored into a single chain. The chain
* size is capped to ensure search is linear time at O(len_A + len_B) rather
* than quadratic at O(len_A * len_B).
*/
private var maxChainLength: Int = 64

/**
* Set the algorithm used when there are too many element occurrences.
*
* @param alg
* the secondary algorithm. If null the region will be denoted as
* a single REPLACE block.
*/
fun setFallbackAlgorithm(alg: DiffAlgorithm?) {
fallback = alg
}

/**
* Maximum number of positions to consider for a given element hash.
*
* All elements with the same hash are stored into a single chain. The chain
* size is capped to ensure search is linear time at O(len_A + len_B) rather
* than quadratic at O(len_A * len_B).
*
* @param maxLen
* new maximum length.
*/
fun setMaxChainLength(maxLen: Int) {
maxChainLength = maxLen
}

override fun <S : Sequence> diffNonCommon(
edits: EditList,
cmp: HashedSequenceComparator<S>, a: HashedSequence<S>,
b: HashedSequence<S>, region: Edit
) {
State<S>(edits, cmp, a, b).diffRegion(region)
}

private inner class State<S : Sequence>(
/** Result edits we have determined that must be made to convert a to b. */
val edits: EditList, private val cmp: HashedSequenceComparator<S>,
private val a: HashedSequence<S>, private val b: HashedSequence<S>
) {
private val queue: MutableList<Edit> = ArrayList()

fun diffRegion(r: Edit) {
diffReplace(r)
while (!queue.isEmpty()) diff(queue.removeAt(queue.size - 1))
}

private fun diffReplace(r: Edit) {
val lcs = HistogramDiffIndex(maxChainLength, cmp, a, b, r)
.findLongestCommonSequence()
if (lcs != null) {
// If we were given an edit, we can prove a result here.
//
if (lcs.isEmpty) {
// An empty edit indicates there is nothing in common.
// Replace the entire region.
//
edits.add(r)
} else {
queue.add(r.after(lcs))
queue.add(r.before(lcs))
}
} else if (fallback is LowLevelDiffAlgorithm) {
val fb = fallback as LowLevelDiffAlgorithm
fb.diffNonCommon(edits, cmp, a, b, r)
} else if (fallback != null) {
val cs = subcmp()
val `as` = a(a, r)
val bs = b(b, r)

val res = fallback!!.diffNonCommon(cs, `as`, bs)
edits.addAll(toBase(res, `as`, bs))
} else {
edits.add(r)
}
}

private fun diff(r: Edit) {
when (r.type) {
Edit.Type.INSERT, Edit.Type.DELETE -> edits.add(r)
Edit.Type.REPLACE -> if (r.lengthA == 1 && r.lengthB == 1) edits.add(r)
else diffReplace(r)

Edit.Type.EMPTY -> throw IllegalStateException()
else -> throw IllegalStateException()
}
}

private fun subcmp(): SubsequenceComparator<HashedSequence<S>> {
return SubsequenceComparator(cmp)
}
}
}
306 changes: 0 additions & 306 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiffIndex.java

This file was deleted.

296 changes: 296 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/HistogramDiffIndex.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

import org.eclipse.jgit.internal.JGitText
import kotlin.math.max
import kotlin.math.min

/**
* Support [HistogramDiff] by computing occurrence counts of elements.
*
*
* Each element in the range being considered is put into a hash table, tracking
* the number of times that distinct element appears in the sequence. Once all
* elements have been inserted from sequence A, each element of sequence B is
* probed in the hash table and the longest common subsequence with the lowest
* occurrence count in A is used as the result.
*
* @param <S>
* type of the base sequence.
</S> */
internal class HistogramDiffIndex<S : Sequence>(
private val maxChainLength: Int, private val cmp: HashedSequenceComparator<S>,
private val a: HashedSequence<S>, private val b: HashedSequence<S>, private val region: Edit
) {
/** Keyed by [.hash] for [.recs] index. */
private val table: IntArray

/** Number of low bits to discard from a key to index [.table]. */
private val keyShift: Int

/**
* Describes a unique element in sequence A.
*
* The records in this table are actually 3-tuples of:
*
* * index of next record in this table that has same hash code
* * index of first element in this occurrence chain
* * occurrence count for this element (length of locs list)
*
*
* The occurrence count is capped at [.MAX_CNT], as the field is only
* a few bits wide. Elements that occur more frequently will have their
* count capped.
*/
private var recs: LongArray

/** Number of elements in [.recs]; also is the unique element count. */
private var recCnt = 0

/**
* For `ptr`, `next[ptr - ptrShift]` has subsequent index.
*
* For the sequence element `ptr`, the value stored at location
* `next[ptr - ptrShift]` is the next occurrence of the exact same
* element in the sequence.
*
* Chains always run from the lowest index to the largest index. Therefore
* the array will store `next[1] = 2`, but never `next[2] = 1`.
* This allows a chain to terminate with `0`, as `0` would never
* be a valid next element.
*
* The array is sized to be `region.getLengthA()` and element indexes
* are converted to array indexes by subtracting [.ptrShift], which is
* just a cached version of `region.beginA`.
*/
private val next: IntArray

/**
* For element `ptr` in A, index of the record in [.recs] array.
*
* The record at `recs[recIdx[ptr - ptrShift]]` is the record
* describing all occurrences of the element appearing in sequence A at
* position `ptr`. The record is needed to get the occurrence count of
* the element, or to locate all other occurrences of that element within
* sequence A. This index provides constant-time access to the record, and
* avoids needing to scan the hash chain.
*/
private val recIdx: IntArray

/** Value to subtract from element indexes to key [.next] array. */
private val ptrShift: Int

private var lcs: Edit? = null

private var cnt = 0

private var hasCommon = false

init {
require(region.endA < MAX_PTR) { JGitText.get().sequenceTooLargeForDiffAlgorithm }

val sz = region.lengthA
val tableBits = tableBits(sz)
table = IntArray(1 shl tableBits)
keyShift = 32 - tableBits
ptrShift = region.beginA

recs = LongArray(max(4.0, (sz ushr 3).toDouble()).toInt())
next = IntArray(sz)
recIdx = IntArray(sz)
}

fun findLongestCommonSequence(): Edit? {
if (!scanA()) return null

lcs = Edit(0, 0)
cnt = maxChainLength + 1

var bPtr = region.beginB
while (bPtr < region.endB) {
bPtr = tryLongestCommonSequence(bPtr)
}

return if (hasCommon && maxChainLength < cnt) null else lcs
}

private fun scanA(): Boolean {
// Scan the elements backwards, inserting them into the hash table
// as we go. Going in reverse places the earliest occurrence of any
// element at the start of the chain, so we consider earlier matches
// before later matches.
//
var ptr = region.endA - 1
SCAN@ while (region.beginA <= ptr) {
val tIdx = hash(a, ptr)

var chainLen = 0
var rIdx = table[tIdx]
while (rIdx != 0) {
val rec = recs[rIdx]
if (cmp.equals(a, recPtr(rec), a, ptr)) {
// ptr is identical to another element. Insert it onto
// the front of the existing element chain.
//
var newCnt = recCnt(rec) + 1
if (MAX_CNT < newCnt) newCnt = MAX_CNT
recs[rIdx] = recCreate(recNext(rec), ptr, newCnt)
next[ptr - ptrShift] = recPtr(rec)
recIdx[ptr - ptrShift] = rIdx
ptr--
continue@SCAN
}

rIdx = recNext(rec)
chainLen++
}

if (chainLen == maxChainLength) return false

// This is the first time we have ever seen this particular
// element in the sequence. Construct a new chain for it.
//
rIdx = ++recCnt
if (rIdx == recs.size) {
val sz = min((recs.size shl 1).toDouble(), (1 + region.lengthA).toDouble()).toInt()
val n = LongArray(sz)
System.arraycopy(recs, 0, n, 0, recs.size)
recs = n
}

recs[rIdx] = recCreate(table[tIdx], ptr, 1)
recIdx[ptr - ptrShift] = rIdx
table[tIdx] = rIdx
ptr--
}
return true
}

private fun tryLongestCommonSequence(bPtr: Int): Int {
var bNext = bPtr + 1
var rIdx = table[hash(b, bPtr)]
var rec: Long
while (rIdx != 0) {
rec = recs[rIdx]

// If there are more occurrences in A, don't use this chain.
if (recCnt(rec) > cnt) {
if (!hasCommon) hasCommon = cmp.equals(a, recPtr(rec), b, bPtr)
rIdx = recNext(rec)
continue
}

var `as` = recPtr(rec)
if (!cmp.equals(a, `as`, b, bPtr)) {
rIdx = recNext(rec)
continue
}

hasCommon = true
TRY_LOCATIONS@ while (true) {
var np = next[`as` - ptrShift]
var bs = bPtr
var ae = `as` + 1
var be = bs + 1
var rc = recCnt(rec)

while (region.beginA < `as` && region.beginB < bs && cmp.equals(a, `as` - 1, b, bs - 1)) {
`as`--
bs--
if (1 < rc) rc = min(
rc.toDouble(),
recCnt(recs[recIdx[`as` - ptrShift]]).toDouble()
).toInt()
}
while (ae < region.endA && be < region.endB && cmp.equals(a, ae, b, be)) {
if (1 < rc) rc = min(rc.toDouble(), recCnt(recs[recIdx[ae - ptrShift]]).toDouble())
.toInt()
ae++
be++
}

if (bNext < be) bNext = be
if (lcs!!.lengthA < ae - `as` || rc < cnt) {
// If this region is the longest, or there are less
// occurrences of it in A, its now our LCS.
//
lcs!!.beginA = `as`
lcs!!.beginB = bs
lcs!!.endA = ae
lcs!!.endB = be
cnt = rc
}

// Because we added elements in reverse order index 0
// cannot possibly be the next position. Its the first
// element of the sequence and thus would have been the
// value of as at the start of the TRY_LOCATIONS loop.
//
if (np == 0) break@TRY_LOCATIONS

while (np < ae) {
// The next location to consider was actually within
// the LCS we examined above. Don't reconsider it.
//
np = next[np - ptrShift]
if (np == 0) break@TRY_LOCATIONS
}

`as` = np
}
rIdx = recNext(rec)
}
return bNext
}

private fun hash(s: HashedSequence<S>, idx: Int): Int {
return (cmp.hash(s, idx) * -0x61c8ffff /* mix bits */) ushr keyShift
}

companion object {
private const val REC_NEXT_SHIFT = 28 + 8

private const val REC_PTR_SHIFT = 8

private const val REC_PTR_MASK = (1 shl 28) - 1

private const val REC_CNT_MASK = (1 shl 8) - 1

private const val MAX_PTR = REC_PTR_MASK

private const val MAX_CNT = (1 shl 8) - 1

private fun recCreate(next: Int, ptr: Int, cnt: Int): Long {
return ((next.toLong() shl REC_NEXT_SHIFT) //
or (ptr.toLong() shl REC_PTR_SHIFT) //
or cnt.toLong())
}

private fun recNext(rec: Long): Int {
return (rec ushr REC_NEXT_SHIFT).toInt()
}

private fun recPtr(rec: Long): Int {
return ((rec ushr REC_PTR_SHIFT).toInt()) and REC_PTR_MASK
}

private fun recCnt(rec: Long): Int {
return (rec.toInt()) and REC_CNT_MASK
}

private fun tableBits(sz: Int): Int {
var bits = 31 - Integer.numberOfLeadingZeros(sz)
if (bits == 0) bits = 1
if (1 shl bits < sz) bits++
return bits
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Compares two sequences primarily based upon hash codes.
*/
abstract class LowLevelDiffAlgorithm : DiffAlgorithm() {
override fun <S : Sequence> diffNonCommon(
cmp: SequenceComparator<in S>, a: S, b: S
): EditList {
var p: HashedSequencePair<S>? = HashedSequencePair(cmp, a, b)
val hc = p!!.comparator
val ha = p.a
val hb = p.b
p = null

val res = EditList()
val region = Edit(0, a.size(), 0, b.size())
diffNonCommon(res, hc, ha, hb, region)
return res
}

/**
* Compare two sequences and identify a list of edits between them.
*
* This method should be invoked only after the two sequences have been
* proven to have no common starting or ending elements. The expected
* elimination of common starting and ending elements is automatically
* performed by the [.diff]
* method, which invokes this method using
* [org.eclipse.jgit.diff.Subsequence]s.
*
* @param <S>
* type of Sequence compared
* @param edits
* result list to append the region's edits onto.
* @param cmp
* the comparator supplying the element equivalence function.
* @param a
* the first (also known as old or pre-image) sequence. Edits
* returned by this algorithm will reference indexes using the
* 'A' side: [org.eclipse.jgit.diff.Edit.getBeginA],
* [org.eclipse.jgit.diff.Edit.getEndA].
* @param b
* the second (also known as new or post-image) sequence. Edits
* returned by this algorithm will reference indexes using the
* 'B' side: [org.eclipse.jgit.diff.Edit.getBeginB],
* [org.eclipse.jgit.diff.Edit.getEndB].
* @param region
* the region being compared within the two sequences.
</S> */
abstract fun <S : Sequence> diffNonCommon(
edits: EditList,
cmp: HashedSequenceComparator<S>, a: HashedSequence<S>,
b: HashedSequence<S>, region: Edit
)
}
556 changes: 0 additions & 556 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java

This file was deleted.

577 changes: 577 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.kt

Large diffs are not rendered by default.

581 changes: 0 additions & 581 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java

This file was deleted.

581 changes: 581 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.kt

Large diffs are not rendered by default.

309 changes: 0 additions & 309 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.java

This file was deleted.

312 changes: 312 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
/*
* Copyright (C) 2009-2010, Google Inc.
* Copyright (C) 2008-2009, Johannes E. Schindelin <johannes.schindelin@gmx.de> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

import org.eclipse.jgit.util.IntList
import org.eclipse.jgit.util.RawCharUtil

/**
* Equivalence function for [org.eclipse.jgit.diff.RawText].
*/
abstract class RawTextComparator : SequenceComparator<RawText>() {
override fun hash(seq: RawText, ptr: Int): Int {
val begin = seq.lines[ptr + 1]
val end = seq.lines[ptr + 2]
return hashRegion(seq.rawContent, begin, end)
}

override fun reduceCommonStartEnd(a: RawText, b: RawText, e: Edit): Edit? {
// This is a faster exact match based form that tries to improve
// performance for the common case of the header and trailer of
// a text file not changing at all. After this fast path we use
// the slower path based on the super class' using equals() to
// allow for whitespace ignore modes to still work.

if (e.beginA == e.endA || e.beginB == e.endB) return e

val aRaw = a.rawContent
val bRaw = b.rawContent

var aPtr = a.lines[e.beginA + 1]
var bPtr = a.lines[e.beginB + 1]

var aEnd = a.lines[e.endA + 1]
var bEnd = b.lines[e.endB + 1]

// This can never happen, but the JIT doesn't know that. If we
// define this assertion before the tight while loops below it
// should be able to skip the array bound checks on access.
//
if (aPtr < 0 || bPtr < 0 || aEnd > aRaw.size || bEnd > bRaw.size) throw ArrayIndexOutOfBoundsException()

while (aPtr < aEnd && bPtr < bEnd && aRaw[aPtr] == bRaw[bPtr]) {
aPtr++
bPtr++
}

while (aPtr < aEnd && bPtr < bEnd && aRaw[aEnd - 1] == bRaw[bEnd - 1]) {
aEnd--
bEnd--
}

e.beginA = findForwardLine(a.lines, e.beginA, aPtr)
e.beginB = findForwardLine(b.lines, e.beginB, bPtr)

e.endA = findReverseLine(a.lines, e.endA, aEnd)

val partialA = aEnd < a.lines[e.endA + 1]
if (partialA) bEnd += a.lines[e.endA + 1] - aEnd

e.endB = findReverseLine(b.lines, e.endB, bEnd)

if (!partialA && bEnd < b.lines[e.endB + 1]) e.endA++

return super.reduceCommonStartEnd(a, b, e)
}

/**
* Compute a hash code for a region.
*
* @param raw
* the raw file content.
* @param ptr
* first byte of the region to hash.
* @param end
* 1 past the last byte of the region.
* @return hash code for the region `[ptr, end)` of raw.
*/
protected abstract fun hashRegion(raw: ByteArray, ptr: Int, end: Int): Int

companion object {
/** No special treatment. */
@JvmField
val DEFAULT: RawTextComparator = object : RawTextComparator() {
override fun equals(a: RawText, ai: Int, b: RawText, bi: Int): Boolean {
var ai = ai
var bi = bi
ai++
bi++

var `as` = a.lines[ai]
var bs = b.lines[bi]
val ae = a.lines[ai + 1]
val be = b.lines[bi + 1]

if (ae - `as` != be - bs) return false

while (`as` < ae) {
if (a.rawContent[`as`++] != b.rawContent[bs++]) return false
}
return true
}

override fun hashRegion(raw: ByteArray, ptr: Int, end: Int): Int {
var ptr = ptr
var hash = 5381
while (ptr < end) {
hash = ((hash shl 5) + hash) + (raw[ptr].toInt() and 0xff)
ptr++
}
return hash
}
}

/** Ignores all whitespace. */
@JvmField
val WS_IGNORE_ALL: RawTextComparator = object : RawTextComparator() {
override fun equals(a: RawText, ai: Int, b: RawText, bi: Int): Boolean {
var ai = ai
var bi = bi
ai++
bi++

var `as` = a.lines[ai]
var bs = b.lines[bi]
var ae = a.lines[ai + 1]
var be = b.lines[bi + 1]

ae = RawCharUtil.trimTrailingWhitespace(a.rawContent, `as`, ae)
be = RawCharUtil.trimTrailingWhitespace(b.rawContent, bs, be)

while (`as` < ae && bs < be) {
var ac = a.rawContent[`as`]
var bc = b.rawContent[bs]

while (`as` < ae - 1 && RawCharUtil.isWhitespace(ac)) {
`as`++
ac = a.rawContent[`as`]
}

while (bs < be - 1 && RawCharUtil.isWhitespace(bc)) {
bs++
bc = b.rawContent[bs]
}

if (ac != bc) return false

`as`++
bs++
}

return `as` == ae && bs == be
}

override fun hashRegion(raw: ByteArray, ptr: Int, end: Int): Int {
var ptr = ptr
var hash = 5381
while (ptr < end) {
val c = raw[ptr]
if (!RawCharUtil.isWhitespace(c)) hash = ((hash shl 5) + hash) + (c.toInt() and 0xff)
ptr++
}
return hash
}
}

/**
* Ignore leading whitespace.
*/
@JvmField
val WS_IGNORE_LEADING: RawTextComparator = object : RawTextComparator() {
override fun equals(a: RawText, ai: Int, b: RawText, bi: Int): Boolean {
var ai = ai
var bi = bi
ai++
bi++

var `as` = a.lines[ai]
var bs = b.lines[bi]
val ae = a.lines[ai + 1]
val be = b.lines[bi + 1]

`as` = RawCharUtil.trimLeadingWhitespace(a.rawContent, `as`, ae)
bs = RawCharUtil.trimLeadingWhitespace(b.rawContent, bs, be)

if (ae - `as` != be - bs) return false

while (`as` < ae) {
if (a.rawContent[`as`++] != b.rawContent[bs++]) return false
}
return true
}

override fun hashRegion(raw: ByteArray, ptr: Int, end: Int): Int {
var ptr = ptr
var hash = 5381
ptr = RawCharUtil.trimLeadingWhitespace(raw, ptr, end)
while (ptr < end) {
hash = ((hash shl 5) + hash) + (raw[ptr].toInt() and 0xff)
ptr++
}
return hash
}
}

/** Ignores trailing whitespace. */
@JvmField
val WS_IGNORE_TRAILING: RawTextComparator = object : RawTextComparator() {
override fun equals(a: RawText, ai: Int, b: RawText, bi: Int): Boolean {
var ai = ai
var bi = bi
ai++
bi++

var `as` = a.lines[ai]
var bs = b.lines[bi]
var ae = a.lines[ai + 1]
var be = b.lines[bi + 1]

ae = RawCharUtil.trimTrailingWhitespace(a.rawContent, `as`, ae)
be = RawCharUtil.trimTrailingWhitespace(b.rawContent, bs, be)

if (ae - `as` != be - bs) return false

while (`as` < ae) {
if (a.rawContent[`as`++] != b.rawContent[bs++]) return false
}
return true
}

override fun hashRegion(raw: ByteArray, ptr: Int, end: Int): Int {
var ptr = ptr
var end = end
var hash = 5381
end = RawCharUtil.trimTrailingWhitespace(raw, ptr, end)
while (ptr < end) {
hash = ((hash shl 5) + hash) + (raw[ptr].toInt() and 0xff)
ptr++
}
return hash
}
}

/** Ignores whitespace occurring between non-whitespace characters. */
@JvmField
val WS_IGNORE_CHANGE: RawTextComparator = object : RawTextComparator() {
override fun equals(a: RawText, ai: Int, b: RawText, bi: Int): Boolean {
var ai = ai
var bi = bi
ai++
bi++

var `as` = a.lines[ai]
var bs = b.lines[bi]
var ae = a.lines[ai + 1]
var be = b.lines[bi + 1]

ae = RawCharUtil.trimTrailingWhitespace(a.rawContent, `as`, ae)
be = RawCharUtil.trimTrailingWhitespace(b.rawContent, bs, be)

while (`as` < ae && bs < be) {
val ac = a.rawContent[`as`++]
val bc = b.rawContent[bs++]

if (RawCharUtil.isWhitespace(ac) && RawCharUtil.isWhitespace(bc)) {
`as` = RawCharUtil.trimLeadingWhitespace(a.rawContent, `as`, ae)
bs = RawCharUtil.trimLeadingWhitespace(b.rawContent, bs, be)
} else if (ac != bc) {
return false
}
}
return `as` == ae && bs == be
}

override fun hashRegion(raw: ByteArray, ptr: Int, end: Int): Int {
var ptr = ptr
var end = end
var hash = 5381
end = RawCharUtil.trimTrailingWhitespace(raw, ptr, end)
while (ptr < end) {
var c = raw[ptr++]
if (RawCharUtil.isWhitespace(c)) {
ptr = RawCharUtil.trimLeadingWhitespace(raw, ptr, end)
c = ' '.code.toByte()
}
hash = ((hash shl 5) + hash) + (c.toInt() and 0xff)
}
return hash
}
}

private fun findForwardLine(lines: IntList, idx: Int, ptr: Int): Int {
var idx = idx
val end = lines.size() - 2
while (idx < end && lines[idx + 2] < ptr) idx++
return idx
}

private fun findReverseLine(lines: IntList, idx: Int, ptr: Int): Int {
var idx = idx
while (0 < idx && ptr <= lines[idx]) idx--
return idx
}
}
}
Original file line number Diff line number Diff line change
@@ -8,30 +8,33 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/

package org.eclipse.jgit.diff;
package org.eclipse.jgit.diff

/**
* Arbitrary sequence of elements.
* <p>
*
*
* A sequence of elements is defined to contain elements in the index range
* <code>[0, {@link #size()})</code>, like a standard Java List implementation.
* `[0, [.size])`, like a standard Java List implementation.
* Unlike a List, the members of the sequence are not directly obtainable.
* <p>
*
*
* Implementations of Sequence are primarily intended for use in content
* difference detection algorithms, to produce an
* {@link org.eclipse.jgit.diff.EditList} of {@link org.eclipse.jgit.diff.Edit}
* [org.eclipse.jgit.diff.EditList] of [org.eclipse.jgit.diff.Edit]
* instances describing how two Sequence instances differ.
* <p>
*
*
* To be compared against another Sequence of the same type, a supporting
* {@link org.eclipse.jgit.diff.SequenceComparator} must also be supplied.
* [org.eclipse.jgit.diff.SequenceComparator] must also be supplied.
*/
public abstract class Sequence {
/** @return total number of items in the sequence. */
/**
* Get size
*
* @return size
*/
public abstract int size();
abstract class Sequence {
/** @return total number of items in the sequence.
*/
/**
* Get size
*
* @return size
*/
abstract fun size(): Int
}
100 changes: 0 additions & 100 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/SequenceComparator.java

This file was deleted.

99 changes: 99 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/SequenceComparator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Equivalence function for a [org.eclipse.jgit.diff.Sequence] compared by
* difference algorithm.
*
*
* Difference algorithms can use a comparator to compare portions of two
* sequences and discover the minimal edits required to transform from one
* sequence to the other sequence.
*
*
* Indexes within a sequence are zero-based.
*
* @param <S>
* type of sequence the comparator supports.
</S> */
abstract class SequenceComparator<S : Sequence> {
/**
* Compare two items to determine if they are equivalent.
*
* It is permissible to compare sequence `a` with itself (by passing
* `a` again in position `b`).
*
* @param a
* the first sequence.
* @param ai
* item of `ai` to compare.
* @param b
* the second sequence.
* @param bi
* item of `bi` to compare.
* @return true if the two items are identical according to this function's
* equivalence rule.
*/
abstract fun equals(a: S, ai: Int, b: S, bi: Int): Boolean

/**
* Get a hash value for an item in a sequence.
*
* If two items are equal according to this comparator's
* [.equals] method, then this hash
* method must produce the same integer result for both items.
*
* It is not required for two items to have different hash values if they
* are unequal according to the `equals()` method.
*
* @param seq
* the sequence.
* @param ptr
* the item to obtain the hash for.
* @return hash the hash value.
*/
abstract fun hash(seq: S, ptr: Int): Int

/**
* Modify the edit to remove common leading and trailing items.
*
* The supplied edit `e` is reduced in size by moving the beginning A
* and B points so the edit does not cover any items that are in common
* between the two sequences. The ending A and B points are also shifted to
* remove common items from the end of the region.
*
* @param a
* the first sequence.
* @param b
* the second sequence.
* @param e
* the edit to start with and update.
* @return `e` if it was updated in-place, otherwise a new edit
* containing the reduced region.
*/
open fun reduceCommonStartEnd(a: S, b: S, e: Edit): Edit? {
// Skip over items that are common at the start.
//
while (e.beginA < e.endA && e.beginB < e.endB && equals(a, e.beginA, b, e.beginB)) {
e.beginA++
e.beginB++
}

// Skip over items that are common at the end.
//
while (e.beginA < e.endA && e.beginB < e.endB && equals(a, e.endA - 1, b, e.endB - 1)) {
e.endA--
e.endB--
}

return e
}
}
131 changes: 0 additions & 131 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/Subsequence.java

This file was deleted.

111 changes: 111 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/Subsequence.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Wraps a [org.eclipse.jgit.diff.Sequence] to have a narrower range of
* elements.
*
*
* This sequence acts as a proxy for the real sequence, translating element
* indexes on the fly by adding `begin` to them. Sequences of this type
* must be used with a [org.eclipse.jgit.diff.SubsequenceComparator].
*
* @param <S>
* the base sequence type.
</S> */
class Subsequence<S : Sequence>(@JvmField val base: S, @JvmField val begin: Int, end: Int) : Sequence() {
private val size = end - begin

override fun size(): Int {
return size
}

companion object {
/**
* Construct a subsequence around the A region/base sequence.
*
* @param <S>
* type of returned Sequence
* @param a
* the A sequence.
* @param region
* the region of `a` to create a subsequence around.
* @return subsequence of `base` as described by A in `region`.
</S> */
fun <S : Sequence> a(a: S, region: Edit): Subsequence<S> {
return Subsequence(a, region.beginA, region.endA)
}

/**
* Construct a subsequence around the B region/base sequence.
*
* @param <S>
* type of returned Sequence
* @param b
* the B sequence.
* @param region
* the region of `b` to create a subsequence around.
* @return subsequence of `base` as described by B in `region`.
</S> */
fun <S : Sequence> b(b: S, region: Edit): Subsequence<S> {
return Subsequence(b, region.beginB, region.endB)
}

/**
* Adjust the Edit to reflect positions in the base sequence.
*
* @param <S>
* type of returned Sequence
* @param e
* edit to adjust in-place. Prior to invocation the indexes are
* in terms of the two subsequences; after invocation the indexes
* are in terms of the base sequences.
* @param a
* the A sequence.
* @param b
* the B sequence.
</S> */
fun <S : Sequence> toBase(
e: Edit, a: Subsequence<S>,
b: Subsequence<S>
) {
e.beginA += a.begin
e.endA += a.begin

e.beginB += b.begin
e.endB += b.begin
}

/**
* Adjust the Edits to reflect positions in the base sequence.
*
* @param <S>
* type of returned Sequence
* @param edits
* edits to adjust in-place. Prior to invocation the indexes are
* in terms of the two subsequences; after invocation the indexes
* are in terms of the base sequences.
* @param a
* the A sequence.
* @param b
* the B sequence.
* @return always `edits` (as the list was updated in-place).
</S> */
@JvmStatic
fun <S : Sequence> toBase(
edits: EditList,
a: Subsequence<S>, b: Subsequence<S>
): EditList {
for (e in edits) toBase(e, a, b)
return edits
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.diff

/**
* Wrap another comparator for use with
* [org.eclipse.jgit.diff.Subsequence].
*
*
* This comparator acts as a proxy for the real comparator, translating element
* indexes on the fly by adding the subsequence's begin offset to them.
* Comparators of this type must be used with a
* [org.eclipse.jgit.diff.Subsequence].
*
* @param <S>
* the base sequence type.
</S> */
class SubsequenceComparator<S : Sequence>
/**
* Construct a comparator wrapping another comparator.
*
* @param cmp
* the real comparator.
*/(private val cmp: SequenceComparator<in S>) : SequenceComparator<Subsequence<S>>() {
override fun equals(a: Subsequence<S>, ai: Int, b: Subsequence<S>, bi: Int): Boolean {
return cmp.equals(a.base, ai + a.begin, b.base, bi + b.begin)
}

override fun hash(seq: Subsequence<S>, ptr: Int): Int {
return cmp.hash(seq.base, ptr + seq.begin)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.lib.AbbreviatedObjectId
import org.eclipse.jgit.lib.ObjectId
import java.io.IOException
import java.text.MessageFormat

/**
* An [org.eclipse.jgit.lib.AbbreviatedObjectId] cannot be extended.
*/
class AmbiguousObjectException
/**
* Construct a MissingObjectException for the specified object id. Expected
* type is reported to simplify tracking down the problem.
*
* @param id
* SHA-1
* @param candidates
* the candidate matches returned by the ObjectReader.
*/(
/**
* Get the `AbbreviatedObjectId` that has more than one result
*
* @return the `AbbreviatedObjectId` that has more than one result
*/
val abbreviatedObjectId: AbbreviatedObjectId,
/**
* Get the matching candidates (or at least a subset of them)
*
* @return the matching candidates (or at least a subset of them)
*/
val candidates: Collection<ObjectId>
) : IOException(
MessageFormat.format(
JGitText.get().ambiguousObjectAbbreviation,
abbreviatedObjectId.name()
)
) {
companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -7,24 +7,25 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors;
package org.eclipse.jgit.errors

/**
* BinaryBlobException is used to signal that binary data was found
* in a context that requires text (eg. for generating textual diffs).
*
* @since 4.10
*/
public class BinaryBlobException extends Exception {
private static final long serialVersionUID = 1L;

/**
* Construct a BinaryBlobException.
*/
public BinaryBlobException() {}
class BinaryBlobException
/**
* Construct a BinaryBlobException.
*/
: Exception() {
@Synchronized
override fun fillInStackTrace(): Throwable {
return this
}

@Override
public synchronized Throwable fillInStackTrace() {
return this;
}
companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -7,26 +7,24 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

package org.eclipse.jgit.errors;

import java.io.IOException;
import java.io.IOException

/**
* Thrown when an operation was canceled
*
* @since 4.7
*/
public class CancelledException extends IOException {
private static final long serialVersionUID = 1L;

/**
* Constructor for CancelledException
*
* @param message
* error message
*/
public CancelledException(String message) {
super(message);
}
class CancelledException
/**
* Constructor for CancelledException
*
* @param message
* error message
*/
(message: String?) : IOException(message) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2007, Dave Watson <dwatson@mimvista.com>
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.io.IOException
import java.text.MessageFormat

/**
* Exception thrown if a conflict occurs during a merge checkout.
*/
class CheckoutConflictException : IOException {
/**
* Get the relative paths of the conflicting files
*
* @return the relative paths of the conflicting files (relative to the
* working directory root).
* @since 4.4
*/
val conflictingFiles: Array<String>

/**
* Construct a CheckoutConflictException for the specified file
*
* @param file
* relative path of a file
*/
constructor(file: String) : super(MessageFormat.format(JGitText.get().checkoutConflictWithFile, file)) {
conflictingFiles = arrayOf(file)
}

/**
* Construct a CheckoutConflictException for the specified set of files
*
* @param files
* an array of relative file paths
*/
constructor(files: Array<String>) : super(
MessageFormat.format(
JGitText.get().checkoutConflictWithFiles,
buildList(files)
)
) {
conflictingFiles = files
}

companion object {
private const val serialVersionUID = 1L

private fun buildList(files: Array<String>): String {
val builder = StringBuilder()
for (f in files) {
builder.append("\n") //$NON-NLS-1$
builder.append(f)
}
return builder.toString()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2016, Matthias Sohn <matthias.sohn@sap.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

/**
* Thrown when an external command failed
*
* @since 4.5
*/
class CommandFailedException : Exception {
/**
* Get return code returned by the command
*
* @return return code returned by the command
*/
var returnCode: Int
private set

/**
* Constructor for CommandFailedException
*
* @param returnCode
* return code returned by the command
* @param message
* error message
*/
constructor(returnCode: Int, message: String?) : super(message) {
this.returnCode = returnCode
}

/**
* Constructor for CommandFailedException
*
* @param returnCode
* return code returned by the command
* @param message
* error message
* @param cause
* exception causing this exception
*/
constructor(
returnCode: Int, message: String?,
cause: Throwable?
) : super(message, cause) {
this.returnCode = returnCode
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

40 changes: 40 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.util.*

/**
* An exception detailing multiple reasons for failure.
*/
class CompoundException(why: Collection<Throwable>) : Exception(format(why)) {
/**
* Get the complete list of reasons why this failure happened.
*
* @return unmodifiable collection of all possible reasons.
*/
val allCauses: List<Throwable> = Collections.unmodifiableList(ArrayList(why))

companion object {
private const val serialVersionUID = 1L

private fun format(causes: Collection<Throwable>): String {
val msg = StringBuilder()
msg.append(JGitText.get().failureDueToOneOfTheFollowing)
for (c in causes) {
msg.append(" ") //$NON-NLS-1$
msg.append(c.message)
msg.append("\n") //$NON-NLS-1$
}
return msg.toString()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2009, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

/**
* Indicates a text string is not a valid Git style configuration.
*/
class ConfigInvalidException : Exception {
/**
* Construct an invalid configuration error.
*
* @param message
* why the configuration is invalid.
*/
constructor(message: String?) : super(message)

/**
* Construct an invalid configuration error.
*
* @param message
* why the configuration is invalid.
* @param cause
* root cause of the error.
*/
constructor(message: String?, cause: Throwable?) : super(message, cause)

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

121 changes: 121 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/errors/CorruptObjectException.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (C) 2008, Google Inc.
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.annotations.Nullable
import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.lib.AnyObjectId
import org.eclipse.jgit.lib.ObjectChecker
import org.eclipse.jgit.lib.ObjectId
import java.io.IOException
import java.text.MessageFormat

/**
* Exception thrown when an object cannot be read from Git.
*/
class CorruptObjectException : IOException {
/**
* Specific error condition identified by
* [org.eclipse.jgit.lib.ObjectChecker].
*
* @return error condition or null.
* @since 4.2
*/
@get:Nullable
var errorType: ObjectChecker.ErrorType? = null
private set

/**
* Report a specific error condition discovered in an object.
*
* @param type
* type of error
* @param id
* identity of the bad object
* @param why
* description of the error.
* @since 4.2
*/
constructor(
type: ObjectChecker.ErrorType, id: AnyObjectId,
why: String?
) : super(
MessageFormat.format(
JGitText.get().objectIsCorrupt3,
type.messageId, id.name(), why
)
) {
this.errorType = type
}

/**
* Construct a CorruptObjectException for reporting a problem specified
* object id
*
* @param id
* a [org.eclipse.jgit.lib.AnyObjectId]
* @param why
* error message
*/
constructor(id: AnyObjectId, why: String?) : super(
MessageFormat.format(
JGitText.get().objectIsCorrupt,
id.name(),
why
)
)

/**
* Construct a CorruptObjectException for reporting a problem specified
* object id
*
* @param id
* a [org.eclipse.jgit.lib.ObjectId]
* @param why
* error message
*/
constructor(id: ObjectId, why: String?) : super(
MessageFormat.format(
JGitText.get().objectIsCorrupt,
id.name(),
why
)
)

/**
* Construct a CorruptObjectException for reporting a problem not associated
* with a specific object id.
*
* @param why
* error message
*/
constructor(why: String?) : super(why)

/**
* Construct a CorruptObjectException for reporting a problem not associated
* with a specific object id.
*
* @param why
* message describing the corruption.
* @param cause
* optional root cause exception
* @since 3.4
*/
constructor(why: String?, cause: Throwable?) : super(why) {
initCause(cause)
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2017, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.annotations.Nullable

/**
* Exception thrown when encounters a corrupt pack index file.
*
* @since 4.9
*/
class CorruptPackIndexException
/**
* Report a specific error condition discovered in an index file.
*
* @param message
* the error message.
* @param errorType
* the error type of corruption.
*/(
message: String?,
/**
* Specific the reason of the corrupt index file.
*
* @return error condition or null.
*/
@get:Nullable val errorType: ErrorType
) : Exception(message) {
/** The error type of a corrupt index file. */
enum class ErrorType {
/** Offset does not match index in pack file. */
MISMATCH_OFFSET,

/** CRC does not match CRC of the object data in pack file. */
MISMATCH_CRC,

/** CRC is not present in index file. */
MISSING_CRC,

/** Object in pack is not present in index file. */
MISSING_OBJ,

/** Object in index file is not present in pack file. */
UNKNOWN_OBJ,
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2015 Ericsson and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

/**
* Thrown when a thread executing a diff is interrupted
*
* @see org.eclipse.jgit.diff.MyersDiff
*
* @since 4.0
*/
class DiffInterruptedException : RuntimeException {
/**
* Constructor for DiffInterruptedException
*
* @param message
* error message
* @param cause
* a [java.lang.Throwable]
* @since 4.1
*/
constructor(message: String?, cause: Throwable?) : super(message, cause)

/**
* Constructor for DiffInterruptedException
*
* @param message
* error message
* @since 4.1
*/
constructor(message: String?) : super(message)

/**
* Indicates that the thread computing a diff was interrupted.
*/
constructor() : super()

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2015, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

/**
* Thrown by DirCache code when entries overlap in impossible way.
*
* @since 4.2
*/
class DirCacheNameConflictException
/**
* Construct an exception for a specific path.
*
* @param path1
* one path that conflicts.
* @param path2
* another path that conflicts.
*/(
/**
* Get one of the paths that has a conflict
*
* @return one of the paths that has a conflict
*/
val path1: String,
/**
* Get another path that has a conflict
*
* @return another path that has a conflict
*/
val path2: String
) : IllegalStateException("$path1 $path2") {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.io.IOException
import java.text.MessageFormat

/**
* Attempt to add an entry to a tree that already exists.
*/
class EntryExistsException
/**
* Construct an EntryExistsException when the specified name already
* exists in a tree.
*
* @param name workdir relative file name
*/
(name: String?) : IOException(MessageFormat.format(JGitText.get().treeEntryAlreadyExists, name)) {
companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -7,23 +7,22 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors;
package org.eclipse.jgit.errors

/**
* Attempt to modify a rebase-todo file in an unsupported way
*
* @since 3.2
*/
public class IllegalTodoFileModification extends Exception {
private static final long serialVersionUID = 1L;

/**
* Constructor for IllegalTodoFileModification
*
* @param msg
* error message
*/
public IllegalTodoFileModification(String msg) {
super(msg);
}
class IllegalTodoFileModification
/**
* Constructor for IllegalTodoFileModification
*
* @param msg
* error message
*/
(msg: String?) : Exception(msg) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2009, Google Inc.
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.lib.Constants.typeString
import org.eclipse.jgit.lib.ObjectId
import java.io.IOException
import java.text.MessageFormat

/**
* An inconsistency with respect to handling different object types.
*
* This most likely signals a programming error rather than a corrupt
* object database.
*/
class IncorrectObjectTypeException
/**
* Construct an IncorrectObjectTypeException for the specified object id.
*
* Provide the type to make it easier to track down the problem.
*
* @param id SHA-1
* @param type object type
*/
(id: ObjectId, type: String?) : IOException(MessageFormat.format(JGitText.get().objectIsNotA, id.name(), type)) {
/**
* Construct an IncorrectObjectTypeException for the specified object id.
*
* Provide the type to make it easier to track down the problem.
*
* @param id SHA-1
* @param type object type
*/
constructor(id: ObjectId, type: Int) : this(id, typeString(type))

companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -35,48 +35,44 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.errors;
package org.eclipse.jgit.errors

import java.io.IOException;

import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.JGitText
import java.io.IOException

/**
* Cannot read the index. This is a serious error that users need to be made
* aware of.
*
* @since 4.2
*/
public class IndexReadException extends IOException {
private static final long serialVersionUID = 1L;
class IndexReadException : IOException {
/**
* Constructs an IndexReadException with the default message.
*/
constructor() : super(JGitText.get().indexWriteException)

/**
* Constructs an IndexReadException with the default message.
*/
public IndexReadException() {
super(JGitText.get().indexWriteException);
}
/**
* Constructs an IndexReadException with the specified detail message.
*
* @param s
* message
*/
constructor(s: String?) : super(s)

/**
* Constructs an IndexReadException with the specified detail message.
*
* @param s
* message
*/
public IndexReadException(String s) {
super(s);
}
/**
* Constructs an IndexReadException with the specified detail message.
*
* @param s
* message
* @param cause
* root cause exception
*/
constructor(s: String?, cause: Throwable?) : super(s) {
initCause(cause)
}

/**
* Constructs an IndexReadException with the specified detail message.
*
* @param s
* message
* @param cause
* root cause exception
*/
public IndexReadException(String s, Throwable cause) {
super(s);
initCause(cause);
}
companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -35,43 +35,39 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.errors;
package org.eclipse.jgit.errors

import java.io.IOException;

import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.JGitText
import java.io.IOException

/**
* Cannot write a modified index. This is a serious error that users need to be
* made aware of.
*/
public class IndexWriteException extends IOException {
private static final long serialVersionUID = 1L;
class IndexWriteException : IOException {
/**
* Constructs an IndexWriteException with the default message.
*/
constructor() : super(JGitText.get().indexWriteException)

/**
* Constructs an IndexWriteException with the default message.
*/
public IndexWriteException() {
super(JGitText.get().indexWriteException);
}
/**
* Constructs an IndexWriteException with the specified detail message.
*
* @param s message
*/
constructor(s: String?) : super(s)

/**
* Constructs an IndexWriteException with the specified detail message.
*
* @param s message
*/
public IndexWriteException(String s) {
super(s);
}
/**
* Constructs an IndexWriteException with the specified detail message.
*
* @param s message
* @param cause root cause exception
*/
constructor(s: String?, cause: Throwable?) : super(s) {
initCause(cause)
}

/**
* Constructs an IndexWriteException with the specified detail message.
*
* @param s message
* @param cause root cause exception
*/
public IndexWriteException(String s, Throwable cause) {
super(s);
initCause(cause);
}
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2009, Jonas Fonseca <fonseca@diku.dk>
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.nio.charset.StandardCharsets
import java.text.MessageFormat

/**
* Thrown when an invalid object id is passed in as an argument.
*/
class InvalidObjectIdException : IllegalArgumentException {
/**
* Create exception with bytes of the invalid object id.
*
* @param bytes containing the invalid id.
* @param offset in the byte array where the error occurred.
* @param length of the sequence of invalid bytes.
*/
constructor(bytes: ByteArray, offset: Int, length: Int) : super(msg(bytes, offset, length))

/**
* Constructor for InvalidObjectIdException
*
* @param id
* the invalid id.
* @since 4.1
*/
constructor(id: String?) : super(MessageFormat.format(JGitText.get().invalidId, id))

companion object {
private const val serialVersionUID = 1L

private fun msg(bytes: ByteArray, offset: Int, length: Int): String {
return try {
MessageFormat.format(
JGitText.get().invalidId,
String(bytes, offset, length, StandardCharsets.US_ASCII)
)
} catch (e: StringIndexOutOfBoundsException) {
JGitText.get().invalidId0
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2008, Florian Köberle <florianskarten@web.de>
* Copyright (C) 2009, Vasyl' Vavrychuk <vvavrychuk@gmail.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

/**
* Thrown when a pattern passed in an argument was wrong.
*/
open class InvalidPatternException
/**
* Constructor for InvalidPatternException
*
* @param message
* explains what was wrong with the pattern.
* @param pattern
* the invalid pattern.
*/(
message: String?,
/**
* Get the invalid pattern
*
* @return the invalid pattern.
*/
val pattern: String
) : Exception(message) {
/**
* Constructor for InvalidPatternException
*
* @param message
* explains what was wrong with the pattern.
* @param pattern
* the invalid pattern.
* @param cause
* the cause.
* @since 4.10
*/
constructor(
message: String?, pattern: String,
cause: Throwable?
) : this(message, pattern) {
initCause(cause)
}

companion object {
private const val serialVersionUID = 1L
}
}
153 changes: 0 additions & 153 deletions org.eclipse.jgit/src/org/eclipse/jgit/errors/LargeObjectException.java

This file was deleted.

144 changes: 144 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/errors/LargeObjectException.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.lib.AnyObjectId
import org.eclipse.jgit.lib.ObjectId
import java.text.MessageFormat

/**
* An object is too big to load into memory as a single byte array.
*/
open class LargeObjectException : RuntimeException {
/**
* Get identity of the object that is too large; may be null
*
* @return identity of the object that is too large; may be null
*/
var objectId: ObjectId? = null

/**
* Set the identity of the object, if its not already set.
*
* @param id
* the id of the object that is too large to process.
*/
fun setObjectId(id: AnyObjectId) {
if (objectId == null) objectId = id.copy()
}

/**
* Create a large object exception, where the object isn't known.
*/
constructor()

/**
* Create a large object exception, where the object isn't known.
*
* @param cause
* the cause
* @since 4.10
*/
constructor(cause: Throwable?) {
initCause(cause)
}

/**
* Create a large object exception, naming the object that is too big.
*
* @param id
* identity of the object that is too big to be loaded as a byte
* array in this JVM.
*/
constructor(id: AnyObjectId) {
objectId = id.copy()
}

protected val objectName: String
/**
* Get the hex encoded name of the object, or 'unknown object'
*
* @return either the hex encoded name of the object, or 'unknown object'
*/
get() {
if (objectId != null) return objectId!!.name()
return JGitText.get().unknownObject
}

override val message: String
get() = MessageFormat.format(
JGitText.get().largeObjectException,
objectName
)

/** An error caused by the JVM being out of heap space. */
class OutOfMemory(cause: OutOfMemoryError?) : LargeObjectException() {
/**
* Construct a wrapper around the original OutOfMemoryError.
*
* @param cause
* the original root cause.
*/
init {
initCause(cause)
}

override val message: String
get() = MessageFormat.format(
JGitText.get().largeObjectOutOfMemory,
objectName
)

companion object {
private const val serialVersionUID = 1L
}
}

/** Object size exceeds JVM limit of 2 GiB per byte array. */
class ExceedsByteArrayLimit : LargeObjectException() {
override val message: String
get() = MessageFormat
.format(
JGitText.get().largeObjectExceedsByteArray,
objectName
)

companion object {
private const val serialVersionUID = 1L
}
}

/** Object size exceeds the caller's upper limit. */
class ExceedsLimit
/**
* Construct an exception for a particular size being exceeded.
*
* @param limit
* the limit the caller imposed on the object.
* @param size
* the actual size of the object.
*/(private val limit: Long, private val size: Long) : LargeObjectException() {
override val message: String
get() = MessageFormat.format(
JGitText.get().largeObjectExceedsLimit,
objectName, limit, size
)


companion object {
private const val serialVersionUID = 1L
}
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2011, GitHub Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.io.File
import java.io.IOException
import java.text.MessageFormat

/**
* An exception occurring when a file cannot be locked
*/
class LockFailedException : IOException {
/**
* Get the file that could not be locked
*
* @return file
*/
var file: File
private set

/**
* Constructor for LockFailedException
*
* @param file
* file that could not be locked
* @param message
* exception message
* @param cause
* cause, for later retrieval by
* [java.lang.Throwable.getCause]
* @since 4.1
*/
constructor(file: File, message: String?, cause: Throwable?) : super(message, cause) {
this.file = file
}

/**
* Construct a CannotLockException for the given file and message
*
* @param file
* file that could not be locked
* @param message
* exception message
*/
/**
* Construct a CannotLockException for the given file
*
* @param file
* file that could not be locked
*/
@JvmOverloads
constructor(file: File, message: String? = MessageFormat.format(JGitText.get().cannotLock, file)) : super(message) {
this.file = file
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2008, Google Inc.
* Copyright (C) 2009, Sasa Zivkov <sasa.zivkov@sap.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.lib.ObjectId
import org.eclipse.jgit.transport.URIish

/**
* Indicates a base/common object was required, but is not found.
*/
class MissingBundlePrerequisiteException
/**
* Constructs a MissingBundlePrerequisiteException for a set of objects.
*
* @param uri
* URI used for transport
* @param missingCommits
* the Map of the base/common object(s) we don't have. Keys are
* ids of the missing objects and values are short descriptions.
*/
(
uri: URIish,
missingCommits: Map<ObjectId, String?>
) : TransportException(uri, format(missingCommits)) {
companion object {
private const val serialVersionUID = 1L

private fun format(missingCommits: Map<ObjectId, String?>): String {
val r = StringBuilder()
r.append(JGitText.get().missingPrerequisiteCommits)
for ((key, value) in missingCommits) {
r.append("\n ") //$NON-NLS-1$
r.append(key.name())
if (value != null) r.append(" ").append(value) //$NON-NLS-1$
}
return r.toString()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2009, Google Inc.
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.lib.AbbreviatedObjectId
import org.eclipse.jgit.lib.Constants.typeString
import org.eclipse.jgit.lib.ObjectId
import java.io.IOException
import java.text.MessageFormat

/**
* An expected object is missing.
*/
class MissingObjectException : IOException {
/**
* Get the ObjectId that was not found
*
* @return the ObjectId that was not found
*/
val objectId: ObjectId?

/**
* Construct a MissingObjectException for the specified object id.
* Expected type is reported to simplify tracking down the problem.
*
* @param id SHA-1
* @param type object type
*/
constructor(id: ObjectId, type: String?) : super(
MessageFormat.format(
JGitText.get().missingObject,
type,
id.name()
)
) {
objectId = id.copy()
}

/**
* Construct a MissingObjectException for the specified object id.
* Expected type is reported to simplify tracking down the problem.
*
* @param id SHA-1
* @param type object type
*/
constructor(id: ObjectId, type: Int) : this(id, typeString(type))

/**
* Construct a MissingObjectException for the specified object id. Expected
* type is reported to simplify tracking down the problem.
*
* @param id
* SHA-1
* @param type
* object type
*/
constructor(id: AbbreviatedObjectId, type: Int) : super(
MessageFormat.format(
JGitText.get().missingObject,
typeString(type),
id.name()
)
) {
objectId = null
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2008, Florian Köberle <florianskarten@web.de>
* Copyright (C) 2009, Vasyl' Vavrychuk <vvavrychuk@gmail.com>
* Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.text.MessageFormat

/**
* Thrown when a pattern contains a character group which is open to the right
* side or a character class which is open to the right side.
*/
class NoClosingBracketException
/**
* Constructor for NoClosingBracketException
*
* @param indexOfOpeningBracket
* the position of the [ character which has no ] character.
* @param openingBracket
* the unclosed bracket.
* @param closingBracket
* the missing closing bracket.
* @param pattern
* the invalid pattern.
*/
(
indexOfOpeningBracket: Int,
openingBracket: String, closingBracket: String,
pattern: String
) : InvalidPatternException(
createMessage(
indexOfOpeningBracket, openingBracket,
closingBracket
), pattern
) {
companion object {
private const val serialVersionUID = 1L

private fun createMessage(
indexOfOpeningBracket: Int,
openingBracket: String, closingBracket: String
): String {
return MessageFormat.format(
JGitText.get().noClosingBracket,
closingBracket, openingBracket,
indexOfOpeningBracket
)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2013, Christian Halstrick <christian.halstrick@sap.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.io.IOException
import java.text.MessageFormat

/**
* Exception thrown if a merge fails because no merge base could be determined.
*
* @since 3.0
*/
class NoMergeBaseException : IOException {
/**
* Get the reason why no merge base could be found
*
* @return the reason why no merge base could be found
*/
var reason: MergeBaseFailureReason
private set

/**
* An enum listing the different reason why no merge base could be
* determined.
*/
enum class MergeBaseFailureReason {
/**
* Multiple merge bases have been found (e.g. the commits to be merged
* have multiple common predecessors) but the merge strategy doesn't
* support this (e.g. ResolveMerge)
*/
MULTIPLE_MERGE_BASES_NOT_SUPPORTED,

/**
* The number of merge bases exceeds [RecursiveMerger.MAX_BASES]
*/
TOO_MANY_MERGE_BASES,

/**
* In order to find a single merge base it may required to merge
* together multiple common predecessors. If during these merges
* conflicts occur the merge fails with this reason
*/
CONFLICTS_DURING_MERGE_BASE_CALCULATION
}


/**
* Construct a NoMergeBase exception
*
* @param reason
* the reason why no merge base could be found
* @param message
* a text describing the problem
*/
constructor(reason: MergeBaseFailureReason, message: String?) : super(
MessageFormat.format(
JGitText.get().noMergeBase,
reason.toString(), message
)
) {
this.reason = reason
}

/**
* Construct a NoMergeBase exception
*
* @param reason
* the reason why no merge base could be found
* @param message
* a text describing the problem
* @param why
* an exception causing this error
*/
constructor(
reason: MergeBaseFailureReason, message: String?,
why: Throwable?
) : super(
MessageFormat.format(
JGitText.get().noMergeBase,
reason.toString(), message
)
) {
this.reason = reason
initCause(why)
}

companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -7,26 +7,24 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

package org.eclipse.jgit.errors;

import java.io.IOException;
import java.io.IOException

/**
* Thrown when a Pack is found not to contain the pack signature defined by git.
*
* @since 4.5
*/
public class NoPackSignatureException extends IOException {
private static final long serialVersionUID = 1L;

/**
* Construct an exception.
*
* @param why
* description of the type of error.
*/
public NoPackSignatureException(String why) {
super(why);
}
class NoPackSignatureException
/**
* Construct an exception.
*
* @param why
* description of the type of error.
*/
(why: String?) : IOException(why) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.transport.URIish

/**
* Indicates a remote repository does not exist.
*/
class NoRemoteRepositoryException : TransportException {
/**
* Constructs an exception indicating a repository does not exist.
*
* @param uri
* URI used for transport
* @param s
* message
*/
constructor(uri: URIish, s: String) : super(uri, s)

/**
* Constructs an exception indicating a repository does not exist.
*
* @param uri
* URI used for transport
* @param s
* message
* @param cause
* root cause exception
* @since 5.13.1
*/
constructor(uri: URIish, s: String, cause: Throwable?) : super(uri, s, cause)

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText

/**
* Indicates a [org.eclipse.jgit.lib.Repository] has no working directory,
* and is thus bare.
*/
class NoWorkTreeException : IllegalStateException(JGitText.get().bareRepositoryNoWorkdirAndIndex) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import java.io.IOException

/**
* JGit encountered a case that it knows it cannot yet handle.
*/
class NotSupportedException : IOException {
/**
* Construct a NotSupportedException for some issue JGit cannot
* yet handle.
*
* @param s message describing the issue
*/
constructor(s: String?) : super(s)

/**
* Construct a NotSupportedException for some issue JGit cannot yet handle.
*
* @param s
* message describing the issue
* @param why
* a lower level implementation specific issue.
*/
constructor(s: String?, why: Throwable?) : super(s) {
initCause(why)
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006-2007, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import java.io.IOException

/**
* Cannot store an object in the object database. This is a serious
* error that users need to be made aware of.
*/
class ObjectWritingException : IOException {
/**
* Constructs an ObjectWritingException with the specified detail message.
*
* @param s message
*/
constructor(s: String?) : super(s)

/**
* Constructs an ObjectWritingException with the specified detail message.
*
* @param s message
* @param cause root cause exception
*/
constructor(s: String?, cause: Throwable?) : super(s) {
initCause(cause)
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2009, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.io.File
import java.io.IOException
import java.text.MessageFormat

/**
* Thrown when a Pack previously failed and is known to be unusable
*/
class PackInvalidException
/**
* Construct a pack invalid error with cause.
*
* @param path
* path of the invalid pack file.
* @param cause
* cause of the pack file becoming invalid.
* @since 4.5.7
*/
(path: String?, cause: Throwable?) :
IOException(MessageFormat.format(JGitText.get().packFileInvalid, path), cause) {
/**
* Construct a pack invalid error.
*
* @param path
* path of the invalid pack file.
*/
@Deprecated("Use {@link #PackInvalidException(File, Throwable)}.")
constructor(path: File) : this(path, null)

/**
* Construct a pack invalid error with cause.
*
* @param path
* path of the invalid pack file.
* @param cause
* cause of the pack file becoming invalid.
* @since 4.5.7
*/
constructor(path: File, cause: Throwable?) : this(path.absolutePath, cause)

/**
* Construct a pack invalid error.
*
* @param path
* path of the invalid pack file.
*/
@Deprecated("Use {@link #PackInvalidException(String, Throwable)}.")
constructor(path: String?) : this(path, null)

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2009, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import java.io.IOException

/**
* Thrown when a Pack no longer matches the PackIndex.
*/
class PackMismatchException
/**
* Construct a pack modification error.
*
* @param why
* description of the type of error.
*/
(why: String?) : IOException(why) {
/**
* Check if this is a permanent problem
*
* @return if this is a permanent problem and repeatedly scanning the
* packlist couldn't fix it
* @since 5.9.1
*/
/**
* Set the type of the exception
*
* @param permanent
* whether the exception is considered permanent
* @since 5.9.1
*/
var isPermanent: Boolean = false

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.transport.URIish

/**
* Indicates a protocol error has occurred while fetching/pushing objects.
*/
open class PackProtocolException : TransportException {
/**
* Constructs an PackProtocolException with the specified detail message
* prefixed with provided URI.
*
* @param uri
* URI used for transport
* @param s
* message, which may be shown to an end-user.
*/
constructor(uri: URIish, s: String) : super("$uri: $s") //$NON-NLS-1$


/**
* Constructs an PackProtocolException with the specified detail message
* prefixed with provided URI.
*
* @param uri
* URI used for transport
* @param s
* message, which may be shown to an end-user.
* @param cause
* root cause exception
*/
constructor(
uri: URIish, s: String,
cause: Throwable?
) : this("$uri: $s", cause) //$NON-NLS-1$


/**
* Constructs an PackProtocolException with the specified detail message.
*
* @param s
* message, which may be shown to an end-user.
*/
constructor(s: String?) : super(s)

/**
* Constructs an PackProtocolException with the specified detail message.
*
* @param s
* message, which may be shown to an end-user.
* @param cause
* root cause exception
*/
constructor(s: String?, cause: Throwable?) : super(s) {
initCause(cause)
}

companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -7,31 +7,30 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

package org.eclipse.jgit.errors;

import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.URIish

/**
* Contains a message from the remote repository indicating a problem.
* <p>
*
*
* Some remote repositories may send customized error messages describing why
* they cannot be accessed. These messages are wrapped up in this exception and
* thrown to the caller of the transport operation.
*/
public class RemoteRepositoryException extends TransportException {
private static final long serialVersionUID = 1L;

/**
* Constructs a RemoteRepositoryException for a message.
*
* @param uri
* URI used for transport
* @param message
* message, exactly as supplied by the remote repository. May
* contain LFs (newlines) if the remote formatted it that way.
*/
public RemoteRepositoryException(URIish uri, String message) {
super(uri, message);
}
class RemoteRepositoryException
/**
* Constructs a RemoteRepositoryException for a message.
*
* @param uri
* URI used for transport
* @param message
* message, exactly as supplied by the remote repository. May
* contain LFs (newlines) if the remote formatted it that way.
*/
(uri: URIish, message: String) : TransportException(uri, message) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2009-2010, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.io.File
import java.text.MessageFormat

/**
* Indicates a local repository does not exist.
*/
class RepositoryNotFoundException : TransportException {
/**
* Constructs an exception indicating a local repository does not exist.
*
* @param location
* description of the repository not found, usually file path.
*/
constructor(location: File) : this(location.path)

/**
* Constructs an exception indicating a local repository does not exist.
*
* @param location
* description of the repository not found, usually file path.
* @param why
* why the repository does not exist.
*/
constructor(location: File, why: Throwable?) : this(location.path, why)

/**
* Constructs an exception indicating a local repository does not exist.
*
* @param location
* description of the repository not found, usually file path.
*/
constructor(location: String) : super(message(location))

/**
* Constructs an exception indicating a local repository does not exist.
*
* @param location
* description of the repository not found, usually file path.
* @param why
* why the repository does not exist.
*/
constructor(location: String, why: Throwable?) : super(message(location), why)

companion object {
private const val serialVersionUID = 1L

private fun message(location: String): String {
return MessageFormat.format(JGitText.get().repositoryNotFound, location)
}
}
}
Original file line number Diff line number Diff line change
@@ -8,31 +8,30 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

package org.eclipse.jgit.errors;

import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.JGitText

/**
* Indicates a checked exception was thrown inside of
* {@link org.eclipse.jgit.revwalk.RevWalk}.
* <p>
* [org.eclipse.jgit.revwalk.RevWalk].
*
*
* Usually this exception is thrown from the Iterator created around a RevWalk
* instance, as the Iterator API does not allow checked exceptions to be thrown
* from hasNext() or next(). The {@link java.lang.Exception#getCause()} of this
* from hasNext() or next(). The [java.lang.Exception.getCause] of this
* exception is the original checked exception that we really wanted to throw
* back to the application for handling and recovery.
*/
public class RevWalkException extends RuntimeException {
private static final long serialVersionUID = 1L;

/**
* Create a new walk exception an original cause.
*
* @param cause
* the checked exception that describes why the walk failed.
*/
public RevWalkException(Throwable cause) {
super(JGitText.get().walkFailure, cause);
}
class RevWalkException
/**
* Create a new walk exception an original cause.
*
* @param cause
* the checked exception that describes why the walk failed.
*/
(cause: Throwable?) : RuntimeException(JGitText.get().walkFailure, cause) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006, Shawn O. Pearce <spearce@spearce.org>
* Copyright (C) 2009, Vasyl' Vavrychuk <vvavrychuk@gmail.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors


/**
* This signals a revision or object reference was not
* properly formatted.
*/
class RevisionSyntaxException : IllegalArgumentException {
/**
* Get the problematic revision string
*
* @return the problematic revision string
* @since 6.8
*/
val revstr: String

/**
* Construct a RevisionSyntaxException indicating a syntax problem with a
* revision (or object) string.
*
* @param revstr The problematic revision string
*/
constructor(revstr: String) {
this.revstr = revstr
}

/**
* Construct a RevisionSyntaxException indicating a syntax problem with a
* revision (or object) string.
*
* @param message a specific reason
* @param revstr The problematic revision string
*/
constructor(message: String?, revstr: String) : super(message) {
this.revstr = revstr
}

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2021, Fabio Ponciroli <ponch@gerritforge.com>
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import java.io.IOException
import java.text.MessageFormat
import java.time.Duration

/**
* Thrown when the search for reuse phase times out.
*
* @since 5.13
*/
class SearchForReuseTimeout
/**
* Construct a search for reuse timeout error.
*
* @param timeout
* time exceeded during the search for reuse phase.
*/
(timeout: Duration) : IOException(
MessageFormat.format(
JGitText.get().searchForReuseTimeout,
timeout.seconds
)
) {
@Synchronized
override fun fillInStackTrace(): Throwable {
return this
}

companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -8,21 +8,16 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/

package org.eclipse.jgit.errors;
package org.eclipse.jgit.errors

/**
* Stops the driver loop of walker and finish with current results.
*
* @see org.eclipse.jgit.revwalk.filter.RevFilter
*/
public class StopWalkException extends RuntimeException {
private static final long serialVersionUID = 1L;

/** Singleton instance for throwing within a filter. */
public static final StopWalkException INSTANCE = new StopWalkException();
object StopWalkException : RuntimeException() {
private const val serialVersionUID = 1L

private StopWalkException() {
// Nothing.
}
/** Singleton instance for throwing within a filter. */
val INSTANCE: StopWalkException = StopWalkException
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2010, 2021 Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

/**
* A previously selected representation is no longer available.
*/
class StoredObjectRepresentationNotAvailableException
/**
* Creates a new instance.
*
* @param cause
* [Throwable] that caused this exception
* @since 6.0
*/
(cause: Throwable?) : Exception(cause) {
companion object {
private const val serialVersionUID = 1L
}
}
Original file line number Diff line number Diff line change
@@ -8,24 +8,22 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

package org.eclipse.jgit.errors;

import java.io.IOException;
import java.io.IOException

/**
* An exception thrown when a symlink entry is found and cannot be
* handled.
*/
public class SymlinksNotSupportedException extends IOException {
private static final long serialVersionUID = 1L;

/**
* Construct a SymlinksNotSupportedException for the specified link
*
* @param s name of link in tree or workdir
*/
public SymlinksNotSupportedException(String s) {
super(s);
}
class SymlinksNotSupportedException
/**
* Construct a SymlinksNotSupportedException for the specified link
*
* @param s name of link in tree or workdir
*/
(s: String?) : IOException(s) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (C) 2011, Sasa Zivkov <sasa.zivkov@sap.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.transport.URIish
import java.text.MessageFormat

/**
* Thrown when PackParser finds an object larger than a predefined limit
*/
class TooLargeObjectInPackException : TransportException {
/**
* Construct a too large object in pack exception when the exact size of the
* too large object is not available. This will be used when we find out
* that a delta sequence is already larger than the maxObjectSizeLimit but
* don't want to inflate the delta just to find out the exact size of the
* resulting object.
*
* @param maxObjectSizeLimit
* the maximum object size limit
*/
constructor(maxObjectSizeLimit: Long) : super(
MessageFormat.format(
JGitText.get().receivePackObjectTooLarge1,
maxObjectSizeLimit
)
)

/**
* Construct a too large object in pack exception when the exact size of the
* too large object is known.
*
* @param objectSize
* a long.
* @param maxObjectSizeLimit
* a long.
*/
constructor(
objectSize: Long,
maxObjectSizeLimit: Long
) : super(
MessageFormat.format(
JGitText.get().receivePackObjectTooLarge2,
objectSize, maxObjectSizeLimit
)
)

/**
* Construct a too large object in pack exception.
*
* @param uri
* URI used for transport
* @param s
* message
* @since 4.4
*/
constructor(uri: URIish, s: String) : super(uri.setPass(null).toString() + ": " + s) //$NON-NLS-1$

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2014, Sasa Zivkov <sasa.zivkov@sap.com>, SAP AG and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import org.eclipse.jgit.internal.JGitText
import org.eclipse.jgit.transport.URIish
import java.text.MessageFormat

/**
* Thrown when a pack exceeds a given size limit
*
* @since 3.3
*/
class TooLargePackException : TransportException {
/**
* Construct a too large pack exception.
*
* @param packSizeLimit
* the pack size limit (in bytes) that was exceeded
*/
constructor(packSizeLimit: Long) : super(
MessageFormat.format(
JGitText.get().receivePackTooLarge,
packSizeLimit
)
)

/**
* Construct a too large pack exception.
*
* @param uri
* URI used for transport
* @param s
* message
* @since 4.0
*/
constructor(uri: URIish, s: String) : super(uri.setPass(null).toString() + ": " + s) //$NON-NLS-1$

companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import java.util.*

/**
* Common base class for all translation bundle related exceptions.
*/
abstract class TranslationBundleException
/**
* Construct an instance of
* [org.eclipse.jgit.errors.TranslationBundleException]
*
* @param message
* exception message
* @param bundleClass
* bundle class for which the exception occurred
* @param locale
* locale for which the exception occurred
* @param cause
* original exception that caused this exception. Usually thrown
* from the [java.util.ResourceBundle] class.
*/ protected constructor(
message: String?,
/**
* Get bundle class
*
* @return bundle class for which the exception occurred
*/
val bundleClass: Class<*>,
/**
* Get locale for which the exception occurred
*
* @return locale for which the exception occurred
*/
val locale: Locale, cause: Exception?
) : RuntimeException(message, cause) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import java.util.*

/**
* This exception will be thrown when a translation bundle loading
* fails.
*/
class TranslationBundleLoadingException
/**
* Construct a
* [org.eclipse.jgit.errors.TranslationBundleLoadingException] for the
* specified bundle class and locale.
*
* @param bundleClass
* the bundle class for which the loading failed
* @param locale
* the locale for which the loading failed
* @param cause
* the original exception thrown from the
* [java.util.ResourceBundle.getBundle]
* method.
*/
(bundleClass: Class<*>, locale: Locale, cause: Exception?) : TranslationBundleException(
"Loading of translation bundle failed for [" //$NON-NLS-1$
+ bundleClass.name + ", " + locale.toString() + "]", //$NON-NLS-1$ //$NON-NLS-2$
bundleClass, locale, cause
) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.errors

import java.util.*

/**
* This exception will be thrown when a translation string for a translation
* bundle and locale is missing.
*/
class TranslationStringMissingException
/**
* Construct a
* [org.eclipse.jgit.errors.TranslationStringMissingException] for the
* specified bundle class, locale and translation key
*
* @param bundleClass
* the bundle class for which a translation string was missing
* @param locale
* the locale for which a translation string was missing
* @param key
* the key of the missing translation string
* @param cause
* the original exception thrown from the
* [java.util.ResourceBundle.getString] method.
*/(
bundleClass: Class<*>, locale: Locale,
/**
* Get the key of the missing translation string
*
* @return the key of the missing translation string
*/
val key: String, cause: Exception?
) : TranslationBundleException(
"Translation missing for [" + bundleClass.name + ", " //$NON-NLS-1$ //$NON-NLS-2$
+ locale.toString() + ", " + key + "]", bundleClass, locale, //$NON-NLS-1$ //$NON-NLS-2$
cause
) {
companion object {
private const val serialVersionUID = 1L
}
}

This file was deleted.

73 changes: 73 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/errors/TransportException.kt

This file was deleted.

33 changes: 0 additions & 33 deletions org.eclipse.jgit/src/org/eclipse/jgit/errors/UnpackException.java

This file was deleted.

32 changes: 32 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/errors/UnpackException.kt

This file was deleted.

This file was deleted.

This file was deleted.

554 changes: 0 additions & 554 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java

This file was deleted.

547 changes: 547 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.kt

This file was deleted.

This file was deleted.

65 changes: 65 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncObjectSizeQueue.kt
44 changes: 0 additions & 44 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncOperation.java

This file was deleted.

43 changes: 43 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/AsyncOperation.kt
24 changes: 0 additions & 24 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/CheckoutEntry.java

This file was deleted.

22 changes: 22 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/CheckoutEntry.kt
1,015 changes: 0 additions & 1,015 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java

This file was deleted.

1,011 changes: 1,011 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.kt
783 changes: 0 additions & 783 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java

This file was deleted.

806 changes: 806 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.kt
95 changes: 0 additions & 95 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgObjectSigner.java

This file was deleted.

100 changes: 100 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgObjectSigner.kt
285 changes: 0 additions & 285 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java

This file was deleted.

270 changes: 270 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.kt
32 changes: 0 additions & 32 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSet.java

This file was deleted.

32 changes: 32 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSet.kt
77 changes: 0 additions & 77 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ProgressMonitor.java

This file was deleted.

80 changes: 80 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ProgressMonitor.kt
89 changes: 0 additions & 89 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogEntry.java

This file was deleted.

92 changes: 92 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogEntry.kt
63 changes: 0 additions & 63 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.java

This file was deleted.

50 changes: 50 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/ReflogReader.kt
39 changes: 0 additions & 39 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryBuilder.java

This file was deleted.

35 changes: 35 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryBuilder.kt
386 changes: 0 additions & 386 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java

This file was deleted.

402 changes: 402 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.kt
128 changes: 0 additions & 128 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeChunk.java

This file was deleted.

100 changes: 100 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeChunk.kt
171 changes: 0 additions & 171 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java

This file was deleted.

154 changes: 154 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.kt
217 changes: 0 additions & 217 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java

This file was deleted.

235 changes: 235 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.kt
176 changes: 0 additions & 176 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.java

This file was deleted.

145 changes: 145 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.kt
161 changes: 0 additions & 161 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java

This file was deleted.

181 changes: 181 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.kt
149 changes: 0 additions & 149 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.java

This file was deleted.

135 changes: 135 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeResult.kt
162 changes: 0 additions & 162 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.java

This file was deleted.

175 changes: 175 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeStrategy.kt
344 changes: 0 additions & 344 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java

This file was deleted.

335 changes: 335 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.kt
239 changes: 0 additions & 239 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.java

This file was deleted.

229 changes: 229 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.kt
1,952 changes: 0 additions & 1,952 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

This file was deleted.

2,034 changes: 2,034 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.kt

This file was deleted.

94 changes: 0 additions & 94 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyOneSided.java

This file was deleted.

70 changes: 70 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyOneSided.kt
43 changes: 0 additions & 43 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyRecursive.java

This file was deleted.

36 changes: 36 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyRecursive.kt
41 changes: 0 additions & 41 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyResolve.java

This file was deleted.

35 changes: 35 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyResolve.kt

This file was deleted.

125 changes: 0 additions & 125 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java

This file was deleted.

113 changes: 113 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.kt
4 changes: 2 additions & 2 deletions org.eclipse.jgit/src/org/eclipse/jgit/patch/HunkHeader.java
239 changes: 0 additions & 239 deletions org.eclipse.jgit/src/org/eclipse/jgit/util/IntList.java

This file was deleted.

228 changes: 228 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/util/IntList.kt
1,407 changes: 0 additions & 1,407 deletions org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java

This file was deleted.

1,503 changes: 1,503 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.kt

This file was deleted.

62 changes: 62 additions & 0 deletions org.eclipse.jgit/src/org/eclipse/jgit/util/time/MonotonicClock.kt