summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* GPG: handle extended private key formatThomas Wolf2021-02-1920-94/+2157
| | | | | | | | | | | | | | | | | | | | | | | | | Add detection for the key-value pair format that was available in gpg-agent for some time already and that has become the default since gpg-agent 2.2.20. If a secret key in the .gnupg/private-keys-v1.d directory is found to have this format, extract the human-readable key from it, convert it to the binary serialized form and hand that to BouncyCastle. Encrypted keys in the new format may use AES/OCB. OCB is a patent- encumbered algorithm; although there is a license for open-source software, that may not be good enough and OCB may not be available in Java. It is not available in the default security provider in Java, and it is also not available in the BouncyCastle version included in Eclipse. Implement AES/OCB decryption, throwing a PGPException with a nice message if the algorithm is not available. Include a copy of the normal s-expression parser of BouncyCastle and fix it to properly handle data from such keys: such keys do not contain an internal hash since the AES/OCB cipher includes and checks a MAC already. Bug: 570501 Change-Id: Ifa6391a809a84cfc6ae7c6610af6a79204b4143b Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* dfs: handle short copieswh2021-02-191-2/+9
| | | | | | | | | | `copy` is documented as possibly returning a smaller number of bytes than requested. In practice, this can occur if a block is cached and the reader never pulls in the file to check its size. Bug: 565874 Change-Id: I1e53b3d2f4ab09334178934dc0ef74ea99045cd3 Signed-off-by: wh <wh9692@protonmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge "[GPG] Provide a factory for the BouncyCastleGpgSigner"Thomas Wolf2021-02-192-1/+36
|\
| * [GPG] Provide a factory for the BouncyCastleGpgSignerThomas Wolf2021-02-192-1/+36
| | | | | | | | | | | | | | Otherwise client code has no way to ever create an instance without using internal non-API. Change-Id: I6201f98d4b1704a053159967b8adacd98e368522 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Merge "Rename PackFile to Pack"Jonathan Nieder2021-02-1837-264/+267
|\ \ | |/ |/|
| * Rename PackFile to PackNasser Grainawi2021-02-1037-264/+267
| | | | | | | | | | | | | | | | Pack better represents the purpose of the object and paves the way to add a PackFile object that extends File. Change-Id: I39b4f697902d395e9b6df5e8ce53078ce72fcea3 Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
* | Fix boxing warningsMatthias Sohn2021-02-172-2/+2
| | | | | | | | Change-Id: Idf4887a99e87c375ec32e2fd289cfce82d78cbce Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | GPG: compute the keygrip to find a secret keyThomas Wolf2021-02-1625-67/+869
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gpg-agent stores secret keys in individual files in the secret key directory private-keys-v1.d. The files have the key's keygrip (in upper case) as name and extension ".key". A keygrip is a SHA1 hash over the parameters of the public key. By computing this keygrip, we can pre-compute the expected file name and then check only that one file instead of having to iterate over all keys stored in that directory. This file naming scheme is actually an implementation detail of gpg-agent. It is unlikely to change, though. The keygrip itself is computed via libgcrypt and will remain stable according to the GPG main author.[1] Add an implementation for calculating the keygrip and include tests. Do not iterate over files in BouncyCastleGpgKeyLocator but only check the single file identified by the keygrip. Ideally upstream BouncyCastle would provide such a getKeyGrip() method. But as it re-builds GPG and libgcrypt internals, it's doubtful it would be included there, and since BouncyCastle even lacks a number of curve OIDs for ed25519/curve25519 and uses the short-Weierstrass parameters instead of the more common Montgomery parameters, including it there might be quite a bit of work. [1] http://gnupg.10057.n7.nabble.com/GnuPG-2-1-x-and-2-2-x-keyring-formats-tp54146p54154.html Bug: 547536 Change-Id: I30022a0e7b33b1bf35aec1222f84591f0c30ddfd Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | GPG signature verification via BouncyCastleThomas Wolf2021-02-1624-44/+1507
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a GpgSignatureVerifier interface, plus a factory to create instances thereof that is provided via the ServiceLoader mechanism. Implement the new interface for BouncyCastle. A verifier maintains an internal LRU cache of previously found public keys to speed up verifying multiple objects (tag or commits). Mergetags are not handled. Provide a new VerifySignatureCommand in org.eclipse.jgit.api together with a factory method Git.verifySignature(). The command can verify signatures on tags or commits, and can be limited to accept only tags or commits. Provide a new public WrongObjectTypeException thrown when the command is limited to either tags or commits and a name resolves to some other object kind. In jgit.pgm, implement "git tag -v", "git log --show-signature", and "git show --show-signature". The output is similar to command-line gpg invoked via git, but not identical. In particular, lines are not prefixed by "gpg:" but by "bc:". Trust levels for public keys are read from the keys' trust packets, not from GPG's internal trust database. A trust packet may or may not be set. Command-line GPG produces more warning lines depending on the trust level, warning about keys with a trust level below "full". There are no unit tests because JGit still doesn't have any setup to do signing unit tests; this would require at least a faked .gpg directory with pre-created key rings and keys, and a way to make the BouncyCastle classes use that directory instead of the default. See bug 547538 and also bug 544847. Tested manually with a small test repository containing signed and unsigned commits and tags, with signatures made with different keys and made by command-line git using GPG 2.2.25 and by JGit using BouncyCastle 1.65. Bug: 547751 Change-Id: If7e34aeed6ca6636a92bf774d893d98f6d459181 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Post commit hook failure should not cause commit failureTim Neumann2021-02-152-4/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As the post commit hook is run after a commit is finished, it can not abort the commit and the exit code of this hook should not have any effect. This can be achieved by not throwing a AbortedByHookException exception. The stderr output is not lost thanks to contributions for bug 553471. Bug: 553428 Change-Id: I451a76e04103e632ff44e045561c5a41f7b7d558 Signed-off-by: Tim Neumann <Tim.Neumann@advantest.com> Signed-off-by: Fabian Pfaff <fabian.pfaff@vogella.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Allow to define additional Hook classes outside JGitMatthias Sohn2021-02-151-2/+2
| | | | | | | | | | | | | | | | EGit wants to add gitflow specific hooks in org.eclipse.egit.gitflow. Make GitHook public to allow sub-classing outside of the org.eclipse.jgit.hooks package. Change-Id: I439575ec901e3610b5cf9d66f7641c8324faa865 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | GitHook: use default charset for output and error streamsMatthias Sohn2021-02-151-4/+6
| | | | | | | | | | | | External scripts most probably expect the default charset. Change-Id: I318a5e1d9f536a95e70c06ffb5b6f408cd40f73a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | GitHook: use generic OutputStream instead of PrintStreamMatthias Sohn2021-02-155-28/+49
| | | | | | | | Change-Id: I15e64dc963c9d27dc9c8de4976dd63f74b918b15 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Update jetty to 9.4.36.v20210114Matthias Sohn2021-02-1317-315/+315
| | | | | | | | Change-Id: Iea57f0fddb0f10dbd1c9be886bfa5ad8c3ff5cb5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Allow dir/file conflicts in virtual base commit on recursive merge.Marija Savtchouk2021-02-092-10/+277
|/ | | | | | | | | | | | | | | | If RecursiveMerger finds multiple base commits, it tries to compute the virtual ancestor to use as a base for the three way merge. Currently, the content conflicts between ancestors are ignored (file staged with the conflict markers). If the path is a file in one ancestor and a dir in the other, it results in NoMergeBaseException (CONFLICTS_DURING_MERGE_BASE_CALCULATION). Allow these conflicts by ignoring this unmerged path in the virtual base. The merger will compute diff in the children instead and it can be further fixed manually if needed. Change-Id: Id59648ae1d6bdf300b26fff513c3204317b755ab Signed-off-by: Marija Savtchouk <mariasavtchouk@google.com>
* Merge "GitHook: make fields outputStream and errorStream private"Christian Halstrick2021-02-091-2/+2
|\
| * GitHook: make fields outputStream and errorStream privateMatthias Sohn2021-02-091-2/+2
| | | | | | | | | | | | Subclasses can use the corresponding getter methods. Change-Id: Iaa9ab01f5a9731a264b28608d2418a9405b601d7 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | GPG: support git config gpg.programThomas Wolf2021-02-076-37/+241
|/ | | | | | | | | | | | | | Add it to the GpgConfig. Change GpgConfig to load the values once only. Add a parameter to the GpgObjectSigner interface's operations to pass in a GpgConfig. Update CommitCommand and TagCommand to pass the value to the signer. Let the signer decide whether it can actually produce the wanted signature type (openpgp or x509). No behavior change. But this makes it possible to implement different signers that might support x509 signatures, or use gpg.program and shell out to an external GPG executable for signing. Change-Id: I427f83eb1ece81c310e1cddd85315f6f88cc99ea Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Bump bazel version to 4.0.0David Ostrovsky2021-02-071-1/+1
| | | | | Change-Id: I2faa67d5083f23b29f7a434e54c5e17360b1c0fe Signed-off-by: David Ostrovsky <david@ostrovsky.org>
* Bazel: Remove unused resources variableDavid Ostrovsky2021-02-071-2/+0
| | | | | Change-Id: Iac2e547791929c26027ab4730ceac6177899ccf1 Signed-off-by: David Ostrovsky <david@ostrovsky.org>
* Fix DateRevQueue tie breaks with more than 2 elementsAdithya Chakilam2021-02-074-9/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DateRevQueue is expected to give out the commits that have higher commit time. But in case of tie(same commit time), it should give the commit that is inserted first. This is inferred from the testInsertTie test case written for DateRevQueue. Also that test case, right now uses just two commits which caused it not to fail with the current implementation, so added another commit to make the test more robust. By fixing the DateRevQueue, we would also match the behaviour of LogCommand.addRange(c1,c2) with git log c1..c2. A test case for the same is added to show that current behaviour is not the expected one. By fixing addRange(), the order in which commits are applied during a rebase is altered. Rebase logic should have never depended upon LogCommand.addRange() since the intended order of addRange() is not the order a rebase should use. So, modify the RebaseCommand to use RevWalk directly with TopoNonIntermixSortGenerator. Add a new LogCommandTest.addRangeWithMerge() test case which creates commits in the following order: A - B - C - M \ / -D- Using git 2.30.0, git log B..M outputs: M C D LogCommand.addRange(B, M) without this fix outputs: M D C LogCommand.addRange(B, M) with this fix outputs: M C D Change-Id: I30cc3ba6c97f0960f64e9e021df96ff276f63db7 Signed-off-by: Adithya Chakilam <achakila@codeaurora.org>
* Field updateHead can be a local variable in RefDirectoryRenameLars Vogel2021-02-061-4/+1
| | | | | | | Keeping the field updateDate is unecessary, as it is set and used only in the doRename method. Change-Id: I1cdd1adf759b75c103480db7a74cec8c2d78b794 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
* Fix FileRepository#convertToReftable which failed if no reflog existedMatthias Sohn2021-02-051-4/+6
| | | | | | | | | Deleting non-existing files when converting to reftable without backup caused convertToReftable to fail. Observed this on a mirrored repository which had no reflogs. Fix this by skipping missing files during deletion. Change-Id: I3bb913d5bfddccc6813677b873006efb849a6ebc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix SeparateClassloaderTestRunner on Java 9 or higherMatthias Sohn2021-02-051-4/+10
| | | | | | | Since Java 9 the SystemClassLoader is no longer a URLClassLoader. Change-Id: I3aa834f1075e611c86fc4684fda6a50c684b3729 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge "reftable: add random suffix to table names"Matthias Sohn2021-02-051-2/+6
|\
| * reftable: add random suffix to table namesHan-Wen Nienhuys2021-01-251-2/+6
| | | | | | | | | | | | | | | | | | | | | | In some circumstances (eg. compacting a stack that has deletions), the result may have a {min, max} range that already exists. In these cases, we would rename onto an already existing file, which does not work on Windows. By adding a random suffix, we disambiguate the files, and avoid this failure scenario. Change-Id: I0273f99bb845cfbdbd8cdd582b55d3c310505d29 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* | TransportGitAnon: remove unnecessary socket bind to a local addressAlina Djamankulova2021-02-051-1/+0
| | | | | | | | | | | | | | | | | | before connecting. A socket gets bound on connect in the next line. Signed-off-by: Alina Djamankulova <adjama@google.com> Change-Id: I69a423c592e2fdd582b3c40099137b4ef3d05b39
* | Migrate to Apache MINA sshd 2.6.0 and Orbit I20210203173513David Ostrovsky2021-02-0446-453/+445
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-enable DSA, DSA_CERT, and RSA_CERT public key authentication. DSA is discouraged for a long time already, but it might still be way too disruptive to completely drop it. RSA is discouraged for far less long, and dropping that would be really disruptive. Adapt to the changed property handling. Remove work-arounds for shortcomings of earlier sshd versions. Use Orbit I20210203173513, which includes sshd 2.6.0. This also bumps apache.httpclient to 4.5.13 and apache.httpcore to 4.4.14. Change-Id: I2d24a1ce4cc9f616a94bb5c4bdaedbf20dc6638e Signed-off-by: David Ostrovsky <david@ostrovsky.org> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | LFSPointerTest: suppress errorprone error [SelfComparison]Matthias Sohn2021-02-041-0/+1
| | | | | | | | | | | | | | | | The test #testCompareToSame tests comparing against self intentionally. Suppress the error raised by errorprone. Change-Id: If8d70a51ab34ffb6d7f0c9d409746aee8b031408 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Fix bazel tests broken by classes moved in dbd05433Matthias Sohn2021-02-041-2/+2
| | | | | | | | | | Change-Id: I88a3547c4b52bcf28c0f0f548ba1bb41a7787704 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Merge branch 'stable-5.11'Matthias Sohn2021-02-030-0/+0
|\ \ | | | | | | | | | | | | | | | | | | | | | * stable-5.11: Prepare 5.11.0-SNAPSHOT builds JGit v5.11.0.202102031030-m2 Change-Id: I3cada72e1917e6349ee415e29987165692d65c4b
| * | Prepare 5.11.0-SNAPSHOT buildsMatthias Sohn2021-02-0388-121/+121
| | | | | | | | | | | | | | | Change-Id: I191674448c4a220e61ec5f0c181c0809eb873166 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | JGit v5.11.0.202102031030-m2v5.11.0.202102031030-m2Matthias Sohn2021-02-0388-121/+121
|/ / | | | | | | | | Change-Id: Ie14c162a7fc5e1e8f34bf4bbc944f4dbe13e4dd0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | IO: fix IO.readFully(InputStream, byte[], int)Thomas Wolf2021-01-312-3/+87
| | | | | | | | | | | | | | | | | | This would run into an endless loop if the offset given was not zero. Fix the logic to exit the read loop when the buffer is full. Luckily all existing uses of this method call it only with offset zero. Change-Id: I0ec2a4fb43efe4a605d06ac2e88cf155d50e2f1e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | LFS: make pointer parsing more robustThomas Wolf2021-01-312-15/+326
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parsing an LFS pointer must check the input more to not run into exceptions. LfsPoint.parseLfsPointer() is used in various places to determine whether a blob is a LFS pointer; it is not only called with valid LFS pointers. Tighten the validations and return null if they fail. All callers already do check for a null return value. Also, LfsPointer implemented Comparable but did not override equals(). This is rather unusual and actually warned against in the javadoc of Comparable. Implement equals() and hashCode(). Add more tests. Bug: 570744 Change-Id: I90ca264d0a250275cf1907e9dcfcee5eab80df0f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | [pgm] add option --timeout to clone commandMatthias Sohn2021-01-291-3/+5
| | | | | | | | Change-Id: I2ee74755045a8d9971ea0d9426db405829c7c679 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Merge "Move reachability checker generation into the ObjectReader object"Jonathan Nieder2021-01-2917-33/+137
|\ \
| * | Move reachability checker generation into the ObjectReader objectTerry Parker2021-01-2817-33/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reachability checkers are retrieved from RevWalk and ObjectWalk objects: * RevWalk.createReachabilityChecker() * ObjectWalk.createObjectReachabilityChecker() Since RevWalks and ObjectWalks are themselves directly instantiated in hundreds of places (e.g. UploadPack...) overriding them in a consistent way requires overloading 100s of methods, which isn't feasible. Moving reachability checker generation to a more central place solves that problem. The ObjectReader object seems a good place from which to get reachability checkers, because reachability checkers return information about relationships between objects. ObjectDatabases delegate many operations to ObjectReaders, and reachability bitmaps are attached to ObjectReaders. The Bitmapped and Pedestrian reachability checker objects were package private in the org.eclipse.jgit.revwalk package. This change makes them public and moves them to the org.eclipse.jgit.internal.revwalk package. Corresponding tests are also moved. Motivation: 1) Reachability checking algorithms need to scale. One of the internal Android repositories has ~2.4 million refs/changes/* references, causing bad long tail performance in reachability checks. 2) Reachability check performance is impacted by repository topography: number of refs, number of objects, amounts of related vs. unrelated history. 3) Reachability check performance is also affected by per-branch access (Gerrit branch permissions) since different users can see different branches. 4) Reachability check performance isn't affected by any state in a RevWalk or ObjectWalk. I don't yet know if a single algorithm will work for all cases in #2 and #3. We may need to evolve the ReachabilityChecker interfaces over time to solve the Gerrit branch permissions case, or use Gerrit-specific identity information to solve that in an efficient way. This change takes the existing public API and moves it to the ObjectReader/whole repository level, which is where we can do consistent customizations for #2 and #3. We intend to upstream the best of whatever works, but anticipate the need for multiple rounds of experimentation. Change-Id: I9185feff43551fb387957c436112d5250486833d Signed-off-by: Terry Parker <tparker@google.com>
* | | Add the "compression-level" option to all ArchiveCommand formatsYoussef Elghareeb2021-01-289-82/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Different archive formats support a compression level in the range [0-9]. The value 0 is for lowest compressions and 9 for highest. Highest levels produce output files of smaller sizes but require more memory to do the compression. This change allows passing a "compression-level" option to the git archive command and implements using it for different file formats. Change-Id: I5758f691c37ba630dbac24db67bb7da827bbc8e1 Signed-off-by: Youssef Elghareeb <ghareeb@google.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Merge changes I36d9b63e,I8c5db581,I2c02e89cJonathan Tan2021-01-2714-1/+635
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | * changes: Compare getting all refs except specific refs with seek and with filter Add getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabase Add seekPastPrefix method to RefCursor
| * | | Compare getting all refs except specific refs with seek and with filterGal Paikin2021-01-271-1/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are currently two ways to get all refs except a specific ref, we add two methods that perform both and compare the two different approaches. This change adds two methods that compares the two different approaches of such query: 1. Get all the refs, and then filter by refs that don't start with the prefix (current approach). 2. Get all refs until encountering a ref that is part of the prefix we should exclude, skip using seekPastPrefix, and continue (new approach). This works since the refs are sorted. Specifically in Gerrit, we often have thousands of refs that are not refs/changes, and millions of refs/changes, hence the second approach should be much faster. In Jgit in general it's still expected to provide a better result even if we're skipping a smaller chunk of the refs since the complexity here is O(logn) with a binary search, rather than O(number of skipped refs). We ran this benchmark on a big chunk of chromium/src's reftable. To run it, we first create the reftable: git ls-remote https://chromium.googlesource.com/chromium/src > lsr bazel build org.eclipse.jgit.pgm:jgit && rm -rf /tmp/reftable* && \ ./bazel-bin/org.eclipse.jgit.pgm/jgit debug-benchmark-reftable \ --test write_stack lsr /tmp/reftable Then, we actually test the created reftable. Note that we can't test all of them at once since there are multiple ones, but below is a good example. bazel build org.eclipse.jgit.pgm:jgit && \ ./bazel-bin/org.eclipse.jgit.pgm/jgit debug-benchmark-reftable \ --test get_refs_excluding_ref --ref refs/changes \ lsr /tmp/reftable/000000000001-0000001e0371.ref Result: total time the action took using seek: 36925 usec total time the action took using filter: 874382 usec number of refs that start with prefix: 4266. number of refs that don't start with prefix: 1962695. Similarly for Android's biggest repository, platform/frameworks/base (still only partial result): total time the action took using seek: 9020 usec total time the action took using filter: 143166 usec number of refs that start with prefix: 296. number of refs that don't start with prefix: 60400. In conclusion, it's easy to see an improvement of a factor of 15-20x for large Gerrit repositories! Signed-off-by: Gal Paikin <paiking@google.com> Change-Id: I36d9b63eb259804c774864429cf2c761cd099cc3
| * | | Add getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabaseGal Paikin2021-01-278-0/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We sometimes want to get all the refs except specific prefixes, similarly to getRefsByPrefix that gets all the refs of a specific prefix. We now create a new method that gets all refs matching a prefix except a set of specific prefixes. One use-case is for Gerrit to be able to get all the refs except refs/changes; in Gerrit we often have lots of refs/changes, but very little other refs. Currently, to get all the refs except refs/changes we need to get all the refs and then filter the refs/changes, which is very inefficient. With this method, we can simply skip the unneeded prefix so that we don't have to go over all the elements. RefDirectory still uses the inefficient implementation, since there isn't a simple way to use Refcursor to achieve the efficient implementation (as done in ReftableDatabase). Signed-off-by: Gal Paikin <paiking@google.com> Change-Id: I8c5db581acdeb6698e3d3a2abde8da32f70c854c
| * | | Add seekPastPrefix method to RefCursorGal Paikin2021-01-265-0/+327
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This method will be used by the follow-up change. This useful if we want to go over all the changes after a specific ref. For example, the new method allows us to create a follow-up that would go over all the refs until we reach a specific ref (e.g refs/changes/), and then we use seekPastPrefix(refs/changes/) to read the rest of the refs, thus basically we return all refs except a specific prefix. When seeking past a prefix, the previous condition that created the RefCursor still applies. E.g, if the cursor was created by seekRefsWithPrefix, we can skip some refs but we will not return refs that are not starting with this prefix. Signed-off-by: Gal Paikin <paiking@google.com> Change-Id: I2c02e89c877fe90da8619cb8a4a9a0c865f238ef
* | | | Wrap the Files.list returned Stream in a try-with-resources blockTerry Parker2021-01-263-5/+21
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | Adds a new FileUtils.hasFiles(Path) helper method to correctly handle the Files.list returned Stream. These errors were found by compiling the code using JDK11's javac compiler. Change-Id: Ie8017fa54eb56afc2e939a2988d8b2c5032cd00f Signed-off-by: Terry Parker <tparker@google.com>
* | | TemporaryBuffer: fix toByteArray(limit)Thomas Wolf2021-01-222-3/+97
| |/ |/| | | | | | | | | | | Heap always copied whole blocks, which leads to AIOOBEs. LocalFile didn't overwrite the method and thus caused NPEs. Change-Id: Ia37d4a875df9f25d4825e6bc95fed7f0dff42afb Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Correct the minimum required version of Apache httpclientThomas Wolf2021-01-185-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | org.eclipse.jgit.http.apache uses several features that exist only since httpclient 4.4, but its MANIFEST.MF still had a lower bound of 4.3.0. Bump this to 4.4.0 for all packages from httpclient. 4.3.0 for the packages from httpcore is fine. Do a similar clean-up in the other bundles using packages from Apache httpclient (http.test, lfs, lfs.server, lfs.server.test) Bug: 570451 Change-Id: Iffdde2a9bd0d65db2e5201a08cffbf03597e2866 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Merge "pgm: add missing dependency to org.apache.commons.logging"Matthias Sohn2021-01-181-0/+1
|\ \
| * | pgm: add missing dependency to org.apache.commons.loggingMatthias Sohn2021-01-171-0/+1
| | | | | | | | | | | | | | | | | | | | | Without this dependency I get class loading exceptions when trying to run org.eclipse.jgit.pgm.Clone in Eclipse. Change-Id: Ia9ecb385d3baccbcd041114287af5076fefd3d71 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Merge "[spotbugs]: Fix potential NPE in FileSnapshot constructor"Matthias Sohn2021-01-181-1/+1
|\ \ \ | |/ / |/| |
| * | [spotbugs]: Fix potential NPE in FileSnapshot constructorMatthias Sohn2021-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | File#getParent can return null which caused this spotbugs warning. FS.FileStoreAttributes#get already gets the parent directory if the passed File is not a directory and checks for null. Hence there is no need to get the parent directory in the FileSnapshot constructor. Change-Id: I77f71503cffb05970ab8d9ba55b69c96c53098b9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>