]> source.dussan.org Git - jgit.git/commit
ApplyCommand: add a base-85 codec 92/177592/4
authorThomas Wolf <thomas.wolf@paranor.ch>
Fri, 5 Mar 2021 22:55:18 +0000 (23:55 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 25 May 2021 22:37:45 +0000 (00:37 +0200)
commit501fc0dadde1b68a6c7bccd870e18cdf03d0e62c
treea1eb67a970baf5889a670b14e6c689dcc7a43253
parentd2846cc8b2a831a089ee768a0475e64ec5b85519
ApplyCommand: add a base-85 codec

Add an implementation for base-85 encoding and decoding [1]. Git binary
patches use this format.

Base-85 encoding assembles bytes as 32-bit MSB values, then converts
these values to base-85 numbers (always 5 bytes) encoded as printable
ASCII characters. Decoding base-85 is the reverse operation. Note
that decoding may overflow on invalid input as 85^5 > 2^32. Encodings
always have a length that is a multiple of 5. If input length is not
divisible by 4, padding bytes are (logically) added, which are ignored
when decoding. The encoding for n bytes has thus always exactly length
(n + 3) / 4 * 5 in integer arithmetic (truncating division).

Includes tests.

[1] https://datatracker.ietf.org/doc/html/rfc1924

Bug: 371725
Change-Id: Ib5b9a503cd62cf70e080a4fb38c8cd1eeeaebcfe
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/Base85Test.java [new file with mode: 0644]
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/util/Base85.java [new file with mode: 0644]