summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Merge branch 'stable-5.10' into stable-5.11" into stable-5.12Matthias Sohn2021-06-132-73/+16
|\
| * Merge branch 'stable-5.10' into stable-5.11Matthias Sohn2021-06-132-73/+16
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.10: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: I50dcc037a96f3a4237c09516c82e1c18acbd2e0b
| | * Merge branch 'stable-5.9' into stable-5.10Matthias Sohn2021-06-132-73/+16
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.9: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: Ib1299564a4cfb9c01f422d7ada05fcfac29700f8
| | | * Merge branch 'stable-5.8' into stable-5.9Matthias Sohn2021-06-132-73/+16
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.8: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: I9abf7dd8b8e5eb3199fd6b43a4653c4e4cf4bf1b
| | | | * Merge branch 'stable-5.7' into stable-5.8Matthias Sohn2021-06-132-73/+16
| | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.7: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: I1ee0d01c14fb7dca151b4e7ae1b989da5a3a01e3
| | | | | * Merge branch 'stable-5.6' into stable-5.7Matthias Sohn2021-06-132-73/+16
| | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: I4570cce185877cb4c50eee519a1cf9467a766dea
| | | | | | * Merge branch 'stable-5.5' into stable-5.6Matthias Sohn2021-06-132-73/+16
| | | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.5: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: I504483a4dc979c5e7af18bad45dc18675e32afd2
| | | | | | | * Merge branch 'stable-5.4' into stable-5.5Matthias Sohn2021-06-052-73/+16
| | | | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.4: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: If5232b68d3e25df7b71e417cbcbb39476e925f22
| | | | | | | | * Merge branch 'stable-5.3' into stable-5.4Matthias Sohn2021-06-052-73/+16
| | | | | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.3: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: I1338fc79a7be6b77fb28df511dd7504fb19b6d1a
| | | | | | | | | * Merge branch 'stable-5.2' into stable-5.3Matthias Sohn2021-06-052-73/+16
| | | | | | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.2: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: I7838f7d237a3598bf55995426d7ba1de146cb6ad
| | | | | | | | | | * Merge branch 'stable-5.1' into stable-5.2Matthias Sohn2021-06-052-73/+16
| | | | | | | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.1: Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired Optimize RefDirectory.isNameConflicting() Update bazlets and bazel version Change-Id: If1b5a2b380cf155e66bf5d5c6d216f86c919bb37
| | | | | | | | | | | * BatchRefUpdate: Skip saving conflicting ref names and prefixes in memoryKaushik Lingarkar2021-05-241-41/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than getting all ref names and prefixes and saving them in memory to perform the check for conflicting names, rely on RefDirectory.isNameConflicting as it is no longer an expensive call after it was optimized in Ie994fc. The old optimization to save ref names and prefixes in memory was targeted towards making clones faster. With this change, the clone performance is unaffected when tests were done with repos containing many(~500k) refs. Here are few recorded elapsed times for creating 10 branches using BatchRefUpdate on NFS based repositories with varying loose refs count. As seen here, this change helps improve the BatchRefUpdate performance from O(n^2) to O(1). loose_refs_count with_change without_change 50 241 ms 310 ms 300 263 ms 1502 ms 1k 181 ms 4241 ms 2k 204 ms 6440 ms 9k 158 ms 25930 ms 20k 154 ms 60443 ms 50k 171 ms 135199 ms 110k 157 ms 329450 ms 160k 209 ms 396328 ms This update improves the Gerrit notedb migration performance as it uses BatchRefUpdate to write change meta refs similar to the test performed above. Change-Id: I853ac6c7feb4b39c3156c01876b38cbd182accfe Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
| | | | | | | | | | | * Optimize RefDirectory.isNameConflicting()Kaushik Lingarkar2021-05-241-32/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid having to scan over ALL loose refs to determine if the name is nested within or is a container of an existing reference. This can get really expensive if there are too many loose refs. Instead use exactRef and getRefsByPrefix which scan based on a prefix. With a simple shell script(like below) using jgit client to create 1k refs in a new repository on NFS, this change brings down the time from 12mins to 7mins. for ref in $(seq 1 1000); do jgit branch "$ref" done Here are few recorded elapsed times to create a new branch on NFS based repositories with varying loose refs count. As we see here, this change improves the name conflicting check from O(n^2) to O(1). loose_refs_count with_change without_change 50 44 ms 164 ms 300 45 ms 1193 ms 1k 38 ms 2610 ms 2k 44 ms 6003 ms 9k 46 ms 27860 ms 20k 45 ms 48591 ms 50k 51 ms 135471 ms 110k 43 ms 294252 ms 160k 52 ms 430976 ms Change-Id: Ie994fc184b8f82811bfb37b111eb9733dbe3e6e0 Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
* | | | | | | | | | | | [errorprone] Fix warning InputStreamSlowMultibyteReadMatthias Sohn2021-06-072-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I50dace6e310016c04f524eb0cfcce0da05fadd47
* | | | | | | | | | | | [errorprone] Make operator precedence explicit in OpenSshConfigFileMatthias Sohn2021-06-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the errorprone warning OperatorPrecedence. Change-Id: I4c7dafa5ac8e1d58fa15cf91fe1b3cf3f182d536
* | | | | | | | | | | | Merge "Skip detecting content renames for binary files"Han-Wen NIenhuys2021-05-313-7/+60
|\ \ \ \ \ \ \ \ \ \ \ \
| * | | | | | | | | | | | Skip detecting content renames for binary filesYoussef Elghareeb2021-05-313-7/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is similar to change Idbc2c29bd that skipped detecting content renames for large files. With this change, we added a new option in RenameDetector called "skipContentRenamesForBinaryFiles", that when set, causes binary files with any slight modification to be identified as added/deleted. The default for this boolean is false, so preserving current behaviour. Change-Id: I4770b1f69c60b1037025ddd0940ba86df6047299
* | | | | | | | | | | | | RepoCommand: Retry commit on LockFailureIvan Frade2021-05-261-43/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the target repository is receiving commits from other sources, the repo command commit can fail with a LOCK_FAILURE. We could let callers retry, but then the command needs to redo all the work (opening all subrepos to recreate the tree). Retry the commit in LOCK_FAILURE inside the command. The commit rewrites the whole tree, so it shouldn't have merge errors. Use an exponential delay with jitter for the retries. Change-Id: I517b6f2afd16a4b695e6cf471b5d6cf492024ec4 Signed-off-by: Ivan Frade <ifrade@google.com>
* | | | | | | | | | | | | RepoCommand: Do not set 'branch' if the revision is a tagIvan Frade2021-05-261-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "branch" field in the .gitmodules is the signal for gerrit to keep the superproject autoupdated. Tags are immutable and there is no need to track them, plus the cgit client requires the field to be a "remote branch name" but not a tag. Do not set the "branch" field if the revision is a tag. Keep those tags in another field ("ref") as they help other tools to find the commit in the destination repository. We can still have false negatives when a refname is not fully qualified, but this check covers e.g. the most common case in android. Note that the javadoc of #setRecordRemoteBranch already mentions that "submodules that request a tag will not have branch name recorded". Change-Id: Ib1c321a4d3b7f8d51ca2ea204f72dc0cfed50c37 Signed-off-by: Ivan Frade <ifrade@google.com>
* | | | | | | | | | | | | Merge "Add git config for conflict style merge/diff3"Matthias Sohn2021-05-262-0/+22
|\ \ \ \ \ \ \ \ \ \ \ \ \
| * | | | | | | | | | | | | Add git config for conflict style merge/diff3Thomas Wolf2021-05-032-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a constant in ConfigConstants, and a ConflictStyle enum in MergeCommand. Change-Id: Idf8e036b6b6953bec06d6923a39e5ff30c2da562 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | | ApplyCommand: fix "no newline at end" detectionThomas Wolf2021-05-261-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check the last line of the last hunk of a file, not the last line of the whole patch. Note that C git only checks that this line starts with "\ " and is at least 12 characters long because of possible different texts when non- English messages are used. Change-Id: I0db81699eb3e99ed7b536a3e2b8dc97df1f58a89 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | | ApplyCommand: handle completely empty context lines in text patchesThomas Wolf2021-05-261-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C git treats completely empty lines as empty context lines (which traditionally have a single blank). Apparently newer GNU diff may produce such lines; see [1]. ("Newer" meaning "since 2006"...) [1] https://github.com/git/git/commit/b507b465f7831 Change-Id: I80c1f030edb17a46289b1dabf11a2648d2660d38 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | | ApplyCommand: use byte arrays for text patches, not stringsThomas Wolf2021-05-262-39/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of converting the patch bytes to strings apply the patch on byte level, like C git does. Converting the input lines and the hunk lines from bytes to strings and then applying the patch based on strings may give surprising results if a patch converts a text file from one encoding to another. Moreover, in the end we don't know which encoding to use to write the result. Previous code just wrote the result as UTF-8, which forcibly changed the encoding if the original input had some other encoding (even if the patch had the same non-UTF-8 encoding). It was also wrong if the input was UTF-8, and the patch should have changed the encoding to something else. So use ByteBuffers instead of Strings. This has the additional advantage that all these ByteBuffers can share the underlying byte arrays of the input and of the patch, so it also reduces memory consumption. Change-Id: I450975f2ba0e7d0bec8973e3113cc2e7aea187ee Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | | ApplyCommand: support binary patchesThomas Wolf2021-05-262-30/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement applying binary patches. Handles both literal and delta patches. Note that C git also runs binary files through the clean and smudge filters. Implement the same safeguards against corrupted patches as in C git: require the full OIDs to be present in the patch file, and apply a binary patch only if both pre- and post-image hashes match. Add tests for applying literal and delta patches. Bug: 371725 Change-Id: I71dc214fe4145d7cc8e4769384fb78c7d0d6c220 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | | ApplyCommand: add a stream to apply a delta patchThomas Wolf2021-05-262-0/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new BinaryDeltaInputStream that applies a delta provided by another InputStream to a given base. Because delta application needs random access to the base, the base itself cannot be yet another InputStream. But at least this enables streaming of the result. Add a simple test using delta hunks generated by C git. Bug: 371725 Change-Id: Ibd26fa2f49860737ad5c5387f7f4870d3e85e628 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | | | | | | | | ApplyCommand: add streams to read/write binary patch hunksThomas Wolf2021-05-263-0/+233
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add streams that can encode or decode git binary patch data on the fly. Git writes binary patches base-85 encoded, at most 52 un-encoded bytes, with the unencoded data length prefixed in a one-character encoding, and suffixed with a newline character. Add a test for both the new input and the output stream. The test roundtrips binary data of different lengths in different ways. Bug: 371725 Change-Id: Ic3faebaa4637520f5448b3d1acd78d5aaab3907a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | | ApplyCommand: add a base-85 codecThomas Wolf2021-05-262-0/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | | | | | | | | | ApplyCommand: convert to git internal format before applying patchThomas Wolf2021-05-181-24/+255
| |/ / / / / / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applying a patch on Windows failed if the patch had the (normal) single-LF line endings, but the file on disk had the usual Windows CR-LF line endings. Git (and JGit) compute diffs on the git-internal blob, i.e., after CR-LF transformation and clean filtering. Applying patches to files directly is thus incorrect and may fail if CR-LF settings don't match, or if clean/smudge filtering is involved. Change ApplyCommand to run the file content through the check-in filters before applying the patch, and run the result through the check-out filters. This makes patch application succeed even if the patch has single-LFs, but the file has CR-LF and core.autocrlf is true. Add tests for various combinations of line endings in the file and in the patch, and a test to verify the clean/smudge handling. See also [1]. Running the file though clean/smudge may give strange results with LFS-managed files. JGit's DiffFormatter has some extra code and applies the smudge filter again after having run the file through the check-in filters (CR-LF and clean). So JGit can actually produce a diff on LFS-managed files using the normal diff machinery. (If it doesn't run out of memory, that is. After all, LFS is intended for _large_ files.) How such a diff would be applied with either C git or JGit is entirely unclear; neither has any code for this special case. Compare also [2]. Note that C git just doesn't know about LFS and always diffs after the check-in filter chain, so for LFS files, it'll produce a diff of the LFS pointers. [1] https://github.com/git/git/commit/c24f3abac [2] https://github.com/git-lfs/git-lfs/issues/440 Bug: 571585 Change-Id: I8f71ff26313b5773ff1da612b0938ad2f18751f5 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | SSH config: fix whitespace handlingThomas Wolf2021-05-171-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use Character.isWhitespace() instead of Character.isSpaceChar() to treat TABs as whitespace, too. Change-Id: Iffc59c13357d981ede6a1e0feb6ea6ff03fb3064 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | SSH config: fix negated patternsThomas Wolf2021-05-171-58/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Negated patterns were handled wrongly. According to the OpenBSD ssh_config man page,[1] a negated pattern never matches. Negated patterns make only sense if there are positive patterns; the negated pattern then can define exceptions for the positive patterns. OpenSshConfigFile did this wrongly. It handled "!foo" as "matching everything but foo", but actually the semantics is "if the input is "foo", this entry doesn't apply. If the input is anything else, other patterns determine whether the entry may apply.". [1] https://man.openbsd.org/ssh_config Change-Id: I50f6e46581b7ece4c949eddf62f4a265573ec29e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | | | | | | | | Fix @since tag for introduction of PUBKEY_ACCEPTED_ALGORITHMSMatthias Sohn2021-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This constant was shipped with 5.11.1. Change-Id: I480dbefab1cccca78cefbc709b79e5405f8bf8cd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | | | | | | | Merge branch 'stable-5.12'Matthias Sohn2021-05-121-14/+13
|\ \ \ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.12: Remove texts which were added by mistake in 00386272 Fix formatting which was broken in 00386272 Change-Id: I1c936183e1fa17ea95ada7849a75bc76af275fa3
| * \ \ \ \ \ \ \ \ \ \ \ \ Merge branch 'stable-5.11' into stable-5.12Matthias Sohn2021-05-121-14/+13
| |\ \ \ \ \ \ \ \ \ \ \ \ \ | | | |/ / / / / / / / / / / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.11: Remove texts which were added by mistake in 00386272 Fix formatting which was broken in 00386272 Change-Id: I6184772bdeca1b9ccecf6e400ae15604ab4f5a69
| | * | | | | | | | | | | | Merge branch 'stable-5.10' into stable-5.11Matthias Sohn2021-05-121-14/+13
| | |\ \ \ \ \ \ \ \ \ \ \ \ | | | | |/ / / / / / / / / / | | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.10: Remove texts which were added by mistake in 00386272 Fix formatting which was broken in 00386272 Change-Id: I0f1511be5375716d41565e72b271cb956c3e847b
| | | * | | | | | | | | | | Merge branch 'stable-5.9' into stable-5.10Matthias Sohn2021-05-121-14/+13
| | | |\ \ \ \ \ \ \ \ \ \ \ | | | | | |/ / / / / / / / / | | | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.9: Remove texts which were added by mistake in 00386272 Fix formatting which was broken in 00386272 Change-Id: Ifa135077d8d07d2317df3b479822e30d87eca950
| | | | * | | | | | | | | | Merge branch 'stable-5.8' into stable-5.9Matthias Sohn2021-05-121-14/+13
| | | | |\ \ \ \ \ \ \ \ \ \ | | | | | | |/ / / / / / / / | | | | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.8: Remove texts which were added by mistake in 00386272 Fix formatting which was broken in 00386272 Change-Id: I9ca7a0237f87d1d4bcaba81e709eaa67902f27e5
| | | | | * | | | | | | | | Merge branch 'stable-5.7' into stable-5.8Matthias Sohn2021-05-112-18/+13
| | | | | |\ \ \ \ \ \ \ \ \ | | | | | | | |/ / / / / / / | | | | | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.7: Remove texts which were added by mistake in 00386272 Fix formatting which was broken in 00386272 Change-Id: I7ed3f47cb46e6c1bf483702c8925a24e88658e47
| | | | | | * | | | | | | | Merge branch 'stable-5.6' into stable-5.7Matthias Sohn2021-05-112-18/+13
| | | | | | |\ \ \ \ \ \ \ \ | | | | | | | | |/ / / / / / | | | | | | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Remove texts which were added by mistake in 00386272 Fix formatting which was broken in 00386272 Change-Id: I45d444b360485564744bf3dfad2c2f5a5e7fcdf6
| | | | | | | * | | | | | | Remove texts which were added by mistake in 00386272Matthias Sohn2021-05-111-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Iaed25dac0bc9af8f3fda6138a5f9fe553bff5d39 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | | | | | * | | | | | | Fix formatting which was broken in 00386272Matthias Sohn2021-05-111-14/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I10a3e2b117e790f64386a8e9e7663db8e59230d9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | | | | | | | | Merge branch 'stable-5.12'Matthias Sohn2021-05-112-49/+12
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.12: LockFile: create OutputStream only when needed Remove ReftableNumbersNotIncreasingException Change-Id: I9d85187d00771beef908f1136015d059024f4118
| * | | | | | | | | | | | | Merge branch 'stable-5.11' into stable-5.12Matthias Sohn2021-05-113-70/+92
| |\| | | | | | | | | | | | | | |_|_|_|_|_|/ / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.11: LockFile: create OutputStream only when needed Remove ReftableNumbersNotIncreasingException Change-Id: I7adb5c4fc28e0043a985b5136424f3f756b2f84f
| | * | | | | | | | | | | Merge branch 'stable-5.10' into stable-5.11Matthias Sohn2021-05-113-70/+92
| | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.10: LockFile: create OutputStream only when needed Remove ReftableNumbersNotIncreasingException Change-Id: Id6e0a78caf12c19a01a88d1ddb8a7df2b3590f98
| | | * | | | | | | | | | Merge branch 'stable-5.9' into stable-5.10Matthias Sohn2021-05-113-71/+93
| | | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.9: LockFile: create OutputStream only when needed Remove ReftableNumbersNotIncreasingException Fix stamping to produce stable file timestamps Change-Id: I056382d1d93f3e0a95838bdd1f0be89711c8a722
| | | | * | | | | | | | | Merge branch 'stable-5.8' into stable-5.9Matthias Sohn2021-05-113-71/+93
| | | | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.8: LockFile: create OutputStream only when needed Remove ReftableNumbersNotIncreasingException Change-Id: I3274c97cf560398c3c4c27d6759500452f315db0
| | | | | * | | | | | | | Merge branch 'stable-5.7' into stable-5.8Matthias Sohn2021-05-113-71/+97
| | | | | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.7: LockFile: create OutputStream only when needed Remove ReftableNumbersNotIncreasingException Change-Id: Ib3f280e0741f87a0ff615d857a5ea39b35527e74
| | | | | | * | | | | | | Merge branch 'stable-5.6' into stable-5.7Matthias Sohn2021-05-112-34/+97
| | | | | | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: LockFile: create OutputStream only when needed Change-Id: I7c0e37d2cee0923662a7e39df5a802a84c017e4f
| | | | | | | * | | | | | LockFile: create OutputStream only when neededThomas Wolf2021-05-102-108/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't create the stream eagerly in lock(); that may cause JGit to exceed OS or JVM limits on open file descriptors if many locks need to be created, for instance when creating many refs. Instead create the output stream only when one really needs to write something. Bug: 573328 Change-Id: If9441ed40494d46f594a896d34a5c4f56f91ebf4 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
| | | | | | * | | | | | | Remove ReftableNumbersNotIncreasingExceptionHan-Wen Nienhuys2021-03-011-37/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a distributed setting, one can have multiple datacenters use reftables for serving, while the ground truth for the Ref database is administered centrally. In this setting, replication delays combined with compaction can cause update-index ranges to overlap. Such a setting is used at Google, and the JGit code already handles this correctly (modulo a bugfix that applied in change I8f8215b99a). Remove the restriction that was applied at FileReftableDatabase. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I6f9ed0fbd7fbc5220083ab808b22a909215f13a9