]> source.dussan.org Git - jgit.git/log
jgit.git
3 years agoFix SeparateClassloaderTestRunner on Java 9 or higher 26/174126/3
Matthias Sohn [Sat, 26 Dec 2020 01:28:03 +0000 (02:28 +0100)]
Fix SeparateClassloaderTestRunner on Java 9 or higher

Since Java 9 the SystemClassLoader is no longer a URLClassLoader.

Change-Id: I3aa834f1075e611c86fc4684fda6a50c684b3729
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoMerge "reftable: add random suffix to table names"
Matthias Sohn [Sat, 6 Feb 2021 00:43:42 +0000 (19:43 -0500)]
Merge "reftable: add random suffix to table names"

3 years agoTransportGitAnon: remove unnecessary socket bind to a local address 07/175907/2
Alina Djamankulova [Fri, 5 Feb 2021 18:12:25 +0000 (10:12 -0800)]
TransportGitAnon: remove unnecessary socket bind to a local address
before connecting.

A socket gets bound on connect in the next line.

Signed-off-by: Alina Djamankulova <adjama@google.com>
Change-Id: I69a423c592e2fdd582b3c40099137b4ef3d05b39

3 years agoMigrate to Apache MINA sshd 2.6.0 and Orbit I20210203173513 24/166824/21
David Ostrovsky [Sat, 25 Jul 2020 08:00:11 +0000 (10:00 +0200)]
Migrate to Apache MINA sshd 2.6.0 and Orbit I20210203173513

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>
3 years agoLFSPointerTest: suppress errorprone error [SelfComparison] 70/175770/1
Matthias Sohn [Thu, 4 Feb 2021 00:17:00 +0000 (01:17 +0100)]
LFSPointerTest: suppress errorprone error [SelfComparison]

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>
3 years agoFix bazel tests broken by classes moved in dbd05433 69/175769/1
Matthias Sohn [Thu, 4 Feb 2021 00:14:30 +0000 (01:14 +0100)]
Fix bazel tests broken by classes moved in dbd05433

Change-Id: I88a3547c4b52bcf28c0f0f548ba1bb41a7787704
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoMerge branch 'stable-5.11' 63/175763/1
Matthias Sohn [Wed, 3 Feb 2021 21:57:33 +0000 (22:57 +0100)]
Merge branch 'stable-5.11'

* stable-5.11:
  Prepare 5.11.0-SNAPSHOT builds
  JGit v5.11.0.202102031030-m2

Change-Id: I3cada72e1917e6349ee415e29987165692d65c4b

3 years agoPrepare 5.11.0-SNAPSHOT builds 52/175752/1
Matthias Sohn [Wed, 3 Feb 2021 20:17:22 +0000 (21:17 +0100)]
Prepare 5.11.0-SNAPSHOT builds

Change-Id: I191674448c4a220e61ec5f0c181c0809eb873166
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoJGit v5.11.0.202102031030-m2 24/175724/1 v5.11.0.202102031030-m2
Matthias Sohn [Wed, 3 Feb 2021 15:29:21 +0000 (16:29 +0100)]
JGit v5.11.0.202102031030-m2

Change-Id: Ie14c162a7fc5e1e8f34bf4bbc944f4dbe13e4dd0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoIO: fix IO.readFully(InputStream, byte[], int) 21/175521/2
Thomas Wolf [Fri, 29 Jan 2021 22:02:30 +0000 (23:02 +0100)]
IO: fix IO.readFully(InputStream, byte[], int)

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>
3 years agoLFS: make pointer parsing more robust 94/175494/3
Thomas Wolf [Fri, 29 Jan 2021 11:12:28 +0000 (12:12 +0100)]
LFS: make pointer parsing more robust

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>
3 years ago[pgm] add option --timeout to clone command 99/175499/1
Matthias Sohn [Fri, 29 Jan 2021 15:23:29 +0000 (16:23 +0100)]
[pgm] add option --timeout to clone command

Change-Id: I2ee74755045a8d9971ea0d9426db405829c7c679
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoMerge "Move reachability checker generation into the ObjectReader object"
Jonathan Nieder [Fri, 29 Jan 2021 06:52:13 +0000 (01:52 -0500)]
Merge "Move reachability checker generation into the ObjectReader object"

3 years agoMove reachability checker generation into the ObjectReader object 00/175300/6
Terry Parker [Mon, 25 Jan 2021 06:18:21 +0000 (22:18 -0800)]
Move reachability checker generation into the ObjectReader object

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>
3 years agoAdd the "compression-level" option to all ArchiveCommand formats 16/175216/9
Youssef Elghareeb [Fri, 22 Jan 2021 14:30:25 +0000 (15:30 +0100)]
Add the "compression-level" option to all ArchiveCommand formats

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>
3 years agoMerge changes I36d9b63e,I8c5db581,I2c02e89c
Jonathan Tan [Wed, 27 Jan 2021 18:36:43 +0000 (13:36 -0500)]
Merge changes I36d9b63e,I8c5db581,I2c02e89c

* changes:
  Compare getting all refs except specific refs with seek and with filter
  Add getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabase
  Add seekPastPrefix method to RefCursor

3 years agoCompare getting all refs except specific refs with seek and with filter 98/173498/13
Gal Paikin [Mon, 7 Dec 2020 14:18:34 +0000 (15:18 +0100)]
Compare getting all refs except specific refs with seek and with filter

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

3 years agoAdd getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabase 22/173022/20
Gal Paikin [Mon, 30 Nov 2020 14:57:06 +0000 (15:57 +0100)]
Add getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabase

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

3 years agoWrap the Files.list returned Stream in a try-with-resources block 48/175348/6
Terry Parker [Tue, 26 Jan 2021 02:46:25 +0000 (18:46 -0800)]
Wrap the Files.list returned Stream in a try-with-resources block

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>
3 years agoAdd seekPastPrefix method to RefCursor 21/173021/17
Gal Paikin [Thu, 19 Nov 2020 17:05:04 +0000 (18:05 +0100)]
Add seekPastPrefix method to RefCursor

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

3 years agoreftable: add random suffix to table names 27/175327/2
Han-Wen Nienhuys [Mon, 25 Jan 2021 15:54:52 +0000 (16:54 +0100)]
reftable: add random suffix to table names

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>
3 years agoTemporaryBuffer: fix toByteArray(limit) 47/175247/2
Thomas Wolf [Fri, 22 Jan 2021 21:45:48 +0000 (22:45 +0100)]
TemporaryBuffer: fix toByteArray(limit)

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>
3 years agoCorrect the minimum required version of Apache httpclient 99/174999/1
Thomas Wolf [Mon, 18 Jan 2021 15:05:58 +0000 (16:05 +0100)]
Correct the minimum required version of Apache httpclient

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>
3 years agoMerge "pgm: add missing dependency to org.apache.commons.logging"
Matthias Sohn [Mon, 18 Jan 2021 07:44:39 +0000 (02:44 -0500)]
Merge "pgm: add missing dependency to org.apache.commons.logging"

3 years agoMerge "[spotbugs]: Fix potential NPE in FileSnapshot constructor"
Matthias Sohn [Mon, 18 Jan 2021 07:44:13 +0000 (02:44 -0500)]
Merge "[spotbugs]: Fix potential NPE in FileSnapshot constructor"

3 years agopgm: add missing dependency to org.apache.commons.logging 90/174190/2
Matthias Sohn [Sun, 3 Jan 2021 01:06:24 +0000 (02:06 +0100)]
pgm: add missing dependency to org.apache.commons.logging

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>
3 years ago[pgm] Use Apache sshd by default 75/174875/2
Thomas Wolf [Fri, 15 Jan 2021 11:45:35 +0000 (12:45 +0100)]
[pgm] Use Apache sshd by default

Change-Id: I2a00059415fc2674469bc921827362801583af83
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoTransportHttp: support preemptive Basic authentication 20/173320/3
Thomas Wolf [Wed, 2 Dec 2020 22:07:01 +0000 (23:07 +0100)]
TransportHttp: support preemptive Basic authentication

If the caller knows already HTTP Basic authentication will be needed
and if it also already has the username and password, preemptive
authentication is a little bit more efficient since it avoids the
initial 401 response.

Add a setPreemptiveBasicAuthentication(username, password) method
to TransportHttp. Client code could call this for instance in a
TransportConfigCallback. The method throws an IllegalStateException
if it is called after an HTTP request has already been made.

Additionally, a URI can include userinfo. Although it is not
recommended to put passwords in URIs, JGit's URIish and also the
Java URL and URI classes still allow it. The underlying HTTP
connection may omit these fields though. If present, take these
fields as additional source for preemptive Basic authentication if
setPreemptiveBasicAuthentication() has not been called.

No preemptive authentication will be done if the connection is
redirected to a different host.

Add tests.

Bug: 541327
Change-Id: Id00b975e56a15b532de96f7bbce48106d992a22b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoTransportHttp: shared SSLContext during fetch or push 09/173009/5
Thomas Wolf [Mon, 30 Nov 2020 11:14:22 +0000 (12:14 +0100)]
TransportHttp: shared SSLContext during fetch or push

TransportHttp makes several HTTP requests. The SSLContext and socket
factory must be shared over these requests, otherwise authentication
information may not be propagated correctly from one request to the
next. This is important for authentication mechanisms that rely on
client-side state, like NEGOTIATE (either NTLM, if the underlying HTTP
library supports it, or Kerberos). In particular, SPNEGO cannot
authenticate on a POST request; the authentication must come from the
initial GET request, which implies that the POST request must use the
same SSLContext and socket factory that was used for the GET.

Change the way HTTPS connections are configured. Introduce the concept
of a GitSession, which is a client-side HTTP session over several HTTPS
requests. TransportHttp creates such a session and uses it to configure
all HTTP requests during that session (fetch or push). This gives a way
to abstract away the differences between JDK and Apache HTTP connections
and to configure SSL setup outside.

A GitSession can maintain state and thus give all HTTP requests in a
session the same socket factory.

Introduce an extension interface HttpConnectionFactory2 that adds a
method to obtain a new GitSession. Implement this for both existing
HTTP connection factories. Change TransportHttp to use the new
GitSession to configure HTTP connections.

The old methods for disabling SSL verification still exist to support
possibly external connection and connection factory implementations
that do not make use of the new GitSession yet.

Bug: 535850
Change-Id: Iedf67464e4e353c1883447c13c86b5a838e678f1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoTransportHttp: make the connection factory configurable 08/173008/4
Thomas Wolf [Sun, 29 Nov 2020 15:22:39 +0000 (16:22 +0100)]
TransportHttp: make the connection factory configurable

Previously, TransportHttp always used the globally set connection
factory. This is problematic if that global factory is changed in
the middle of a fetch or push operation. Initialize the factory to
use in the constructor, then use that factory for all HTTP requests
made through this transport. Provide a setter and a getter for it
so that client code can customize the factory, if needed, in a
TransportConfigCallback.

Once a factory has been used on a TransportHttp instance it cannot
be changed anymore.

Make the global static factory reference volatile.

Change-Id: I7c6ee16680407d3724e901c426db174a3125ba1c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoAdd target platform for eclipse 4.19 staging 12/174712/2
Matthias Sohn [Tue, 12 Jan 2021 21:39:51 +0000 (22:39 +0100)]
Add target platform for eclipse 4.19 staging

Change-Id: I172aa01203edc8cd069c93762c482a3f21950acc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate orbit to S20210105214148 and com.google.gson to 2.8.6 11/174711/2
Matthias Sohn [Tue, 12 Jan 2021 21:39:08 +0000 (22:39 +0100)]
Update orbit to S20210105214148 and com.google.gson to 2.8.6

Also fix target name of jgit-4.18 target.

Change-Id: Ib5a13281398e7c5589de2e4a34fae0d08346db9c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate spotbugs-maven-plugin to 4.2.0 11/174511/2
Marco Miller [Fri, 8 Jan 2021 21:11:30 +0000 (16:11 -0500)]
Update spotbugs-maven-plugin to 4.2.0

Change-Id: I094d92f95ec2ab1cefa8f1504f2a8c1aa6e28d96
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
3 years agoAdd org.eclipse.jetty.util.ajax to target platform and bazel deps 65/174665/3
Matthias Sohn [Mon, 11 Jan 2021 23:28:23 +0000 (00:28 +0100)]
Add org.eclipse.jetty.util.ajax to target platform and bazel deps

It is required by org.eclipse.jetty.servlet [1].

[1] https://search.maven.org/artifact/org.eclipse.jetty/jetty-servlet/9.4.35.v20201120/jar

Change-Id: I307ec8bad17f3a703bf25cc16c87ab9b524a84ff
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoTag message must not include the signature 05/174405/3
Thomas Wolf [Thu, 7 Jan 2021 16:10:45 +0000 (17:10 +0100)]
Tag message must not include the signature

Signatures on tags are just tacked onto the end of the message.
Getting the message must not return the signature. Compare [1]
and [2] in C git, which both drop a signature at the end of an
object body.

[1] https://github.com/git/git/blob/21bf933/builtin/tag.c#L173
[2] https://github.com/git/git/blob/21bf933/ref-filter.c#L1276

Change-Id: Ic8a1062b8bc77f2d7c138c3fe8a7fd13b1253f38
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoUpdate jetty to 9.4.35.v20201120 12/174212/2
Matthias Sohn [Mon, 4 Jan 2021 01:02:27 +0000 (02:02 +0100)]
Update jetty to 9.4.35.v20201120

Change-Id: I203778ea0536defffb720bcf7cdcbc6258540e65
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoProtocol V2: don't log spurious ACKs in UploadPack 18/174318/1
Thomas Wolf [Wed, 6 Jan 2021 11:13:48 +0000 (12:13 +0100)]
Protocol V2: don't log spurious ACKs in UploadPack

UploadPack may log ACKs in protocol V2 that it doesn't send (if it
got a "done" from the client), or may log ACKs twice. That makes
packet log analysis difficult.

Add a new constructor to PacketLineOut to omit all logging from an
instance, and use it in UploadPack.

Change-Id: Ic29ef5f9a05cbcf5f4858a4e1b206ef0e6421c65
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoMerge "Protocol V2: respect MAX_HAVES only once we got at least one ACK"
Thomas Wolf [Tue, 5 Jan 2021 22:59:27 +0000 (17:59 -0500)]
Merge "Protocol V2: respect MAX_HAVES only once we got at least one ACK"

3 years agoMerge "FileSnapshot: don't try to read file attributes twice"
Christian Halstrick [Tue, 5 Jan 2021 07:11:48 +0000 (02:11 -0500)]
Merge "FileSnapshot: don't try to read file attributes twice"

3 years agoProtocol V2: respect MAX_HAVES only once we got at least one ACK 95/174195/3
Thomas Wolf [Sun, 3 Jan 2021 22:07:18 +0000 (23:07 +0100)]
Protocol V2: respect MAX_HAVES only once we got at least one ACK

The negotiation in the git protocol contains a cutoff: if the client
has sent more than MAX_HAVES "have" lines without getting an ACK, it
gives up and sends a "done". MAX_HAVES is 256.

However, this cutoff must kick in only if at least one ACK has been
received. Otherwise the client may give up way too early, which makes
the server send all its history. See [1].

This was missed when protocol V2 was implemented for fetching in JGit
in commit 0853a241.

Compare also C git commit 0b07eecf6ed.[2] C git had the same bug.[3][4]

[1] https://github.com/git/git/blob/6c430a647cb9/Documentation/technical/pack-protocol.txt#L385
[2] https://github.com/git/git/commit/0b07eecf6ed
[3] https://lore.kernel.org/git/b7f5bfb9-61fb-2552-4399-b744428728e4@suse.cz/
[4] https://lore.kernel.org/git/20200422084254.GA27502@furthur.local/

Bug: 553083
Change-Id: I1f4e2cc16b5eed6971d981d472329185abb9e4a9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoRepositoryCache: declare schedulerLock final 25/174125/2
Matthias Sohn [Mon, 28 Dec 2020 01:21:17 +0000 (02:21 +0100)]
RepositoryCache: declare schedulerLock final

This fixes errorprone error [SynchronizeOnNonFinalField]: Synchronizing
on non-final fields is not safe: if the field is ever updated, different
threads may end up locking on different objects.

Change-Id: I42fe5bde825151693e2da2d5b6cd6e1d34038dbc

3 years agoEnable git wire protocol version 2 on server side per default 16/163216/6
David Ostrovsky [Tue, 19 May 2020 05:17:24 +0000 (07:17 +0200)]
Enable git wire protocol version 2 on server side per default

Bug: 563145
Change-Id: Id5030c2b85466da0a8ccf3d78ae78df16d64ffc5
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
3 years ago[spotbugs]: Fix potential NPE in FileSnapshot constructor 91/174191/1
Matthias Sohn [Sun, 3 Jan 2021 15:08:24 +0000 (16:08 +0100)]
[spotbugs]: Fix potential NPE in FileSnapshot constructor

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>
3 years agoFileSnapshot: don't try to read file attributes twice 88/174188/1
Matthias Sohn [Sun, 3 Jan 2021 14:33:36 +0000 (15:33 +0100)]
FileSnapshot: don't try to read file attributes twice

If file doesn't exist set state to MISSING_FILE immediately. Doing that
by calling File#lastModified and File#length effectively does the same
since they set the value to 0 if the file doesn't exist.

Log an error if a different exception than NoSuchFileException is
caught.

Change-Id: I0d4396b9f80446692a088d17522d64f735ce6708

3 years agoClient-side protocol V2 support for fetching 95/172595/9
Thomas Wolf [Sun, 2 Aug 2020 17:22:05 +0000 (19:22 +0200)]
Client-side protocol V2 support for fetching

Make all transports request protocol V2 when fetching. Depending on
the transport, set the GIT_PROTOCOL environment variable (file and
ssh), pass the Git-Protocol header (http), or set the hidden
"\0version=2\0" (git anon). We'll fall back to V0 if the server
doesn't reply with a version 2 answer.

A user can control which protocol the client requests via the git
config protocol.version; if not set, JGit requests protocol V2 for
fetching. Pushing always uses protocol V0 still.

In the API, there is only a new Transport.openFetch() version that
takes a collection of RefSpecs plus additional patterns to construct
the Ref prefixes for the "ls-refs" command in protocol V2. If none
are given, the server will still advertise all refs, even in protocol
V2.

BasePackConnection.readAdvertisedRefs() handles falling back to
protocol V0. It newly returns true if V0 was used and the advertised
refs were read, and false if V2 is used and an explicit "ls-refs" is
needed. (This can't be done transparently inside readAdvertisedRefs()
because a "stateless RPC" transport like TransportHttp may need to
open a new connection for writing.)

BasePackFetchConnection implements the changes needed for the protocol
V2 "fetch" command (stateless protocol, simplified ACK handling,
delimiters, section headers).

In TransportHttp, change readSmartHeaders() to also recognize the
"version 2" packet line as a valid smart server indication.

Adapt tests, and run all the HTTP tests not only with both HTTP
connection factories (JDK and Apache HttpClient) but also with both
protocol V0 and V2. The SSH tests are much slower and much more
focused on the SSH protocol and SSH key handling. Factor out two
very simple cloning and pulling tests and make those run with
protocol V2.

Bug: 553083
Change-Id: I357c7f5daa7efb2872f1c64ee6f6d54229031ae1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoUse Map interface instead of ConcurrentHashMap class 51/174151/2
Thomas Wolf [Wed, 30 Dec 2020 16:17:44 +0000 (17:17 +0100)]
Use Map interface instead of ConcurrentHashMap class

On Android, the co-variant override of ConcurrentHashMap.keySet()
introduced in Java 8 was undone. [1] If compiled Java code calls that
co-variant override directly, one gets a NoSuchMethodError exception
at run-time on Android.

Making the code call that method via Map.keySet() side-steps this
problem.

This is similar to bug 496262, where the same problem cropped up when
compiling with Java 8 against a Java 7 target, but here we cannot use
bootclasspath. We build against Java 8, not against the Android version
of it.

Recent Android versions should have some bytecode "magic" that adds the
co-variant override in bytecode (see the commit referenced in [1]), but
on older Android version this problem may still occur. (Or perhaps the
"magic" is ineffective...) There are two pull requests on Github for
this problem, both from 2020, [2][3] while the Android commit [1] is
from March 2018. Apparently people still occasionally run into this
problem in the wild.

[1] https://android.googlesource.com/platform/libcore/+/0e8b937ded4de39f1d1cea5f04800d67dd2ec570/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#1244
[2] https://github.com/eclipse/jgit/pull/104
[3] https://github.com/eclipse/jgit/pull/100

Change-Id: I7c07e0cc59871cb7fe60795e22867827fa9c2458
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoFix NPE in DirCacheCheckout 43/174143/3
Thomas Wolf [Wed, 30 Dec 2020 09:12:34 +0000 (10:12 +0100)]
Fix NPE in DirCacheCheckout

If a file exists in head, merge, and the working tree, but not in
the index, and we're doing a force checkout, the checkout must be
an "update", not a "keep".

This is a follow-up on If3a9b9e60064459d187c7db04eb4471a72c6cece.

Bug: 569962
Change-Id: I59a7ac41898ddc1dd90e86b09b621a41fdf45667
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoMerge "Added check for null on DirCacheEntry in checkoutEntry method"
Christian Halstrick [Wed, 30 Dec 2020 08:05:00 +0000 (03:05 -0500)]
Merge "Added check for null on DirCacheEntry in checkoutEntry method"

3 years agoGPG user ID matching: use case-insensitive matching 35/174135/1
Thomas Wolf [Tue, 29 Dec 2020 09:15:20 +0000 (10:15 +0100)]
GPG user ID matching: use case-insensitive matching

Although not mentioned in the GPG documentation at [1], GPG uses
case-insensitive matching also for the '<' (exact e-mail) and '@'
(partial e-mail) operators. Matching for '=' (full exact match) is
case-sensitive. Compare [2].

[1] https://www.gnupg.org/documentation/manuals/gnupg/Specify-a-User-ID.html
[2] https://dev.gnupg.org/source/gnupg/browse/master/g10/keyring.c;22f7dddc34446a8c3e9eddf6cb281f16802351d7$890

Bug: 547789
Change-Id: I2f5ab65807d5dde3aa00ff032894701bbd8418c9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoDon't export package from test bundle 33/174133/1
Thomas Wolf [Mon, 28 Dec 2020 21:53:50 +0000 (22:53 +0100)]
Don't export package from test bundle

Do not export the test-only package org.eclipse.jgit.transport from
bundle org.eclipse.jgit.ssh.jsch.test. Doing so can confuse the build
in Eclipse: other bundles that import this package may then also pick
up this test package, leading to non-test sources depending on test
sources and to build cycles.

Change-Id: I9f73b7a8d13bc4a2fe58bd2f1d33068164a13991
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
3 years agoUpdate eclipse-jarsigner-plugin to 1.1.7 09/174109/1
Matthias Sohn [Thu, 24 Dec 2020 15:09:40 +0000 (16:09 +0100)]
Update eclipse-jarsigner-plugin to 1.1.7

Change-Id: I6ac33e662aac68a01455113d8abbe0bcdd725ca2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate build-helper-maven-plugin to 3.2.0 08/174108/1
Matthias Sohn [Thu, 24 Dec 2020 15:08:20 +0000 (16:08 +0100)]
Update build-helper-maven-plugin to 3.2.0

Change-Id: I41e5645fe6eb9f477ec9e0653a75279d927a64f8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate maven-enforcer-plugin to 3.0.0-M3 07/174107/1
Matthias Sohn [Thu, 24 Dec 2020 14:35:18 +0000 (15:35 +0100)]
Update maven-enforcer-plugin to 3.0.0-M3

Change-Id: I5121415523b01994338c4097a8437a677d08b954
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate maven-shade-plugin to 3.2.4 06/174106/1
Matthias Sohn [Thu, 24 Dec 2020 14:27:02 +0000 (15:27 +0100)]
Update maven-shade-plugin to 3.2.4

Change-Id: Id3eb7c8ab5ce37b6079bbf9a4cb1974ba70ace8a

3 years agoRequire latest Maven version 3.6.3 05/174105/1
Matthias Sohn [Thu, 24 Dec 2020 14:40:12 +0000 (15:40 +0100)]
Require latest Maven version 3.6.3

Change-Id: Iab08ddcdb7edc3c9ac55343d3d40012e19792ea0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate spring-boot-maven-plugin to 2.4.1 04/174104/1
Matthias Sohn [Thu, 24 Dec 2020 14:10:01 +0000 (15:10 +0100)]
Update spring-boot-maven-plugin to 2.4.1

Change-Id: I68a6c04a5c7e674410736a45ef0031a2c369a321
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate maven-surefire plugins to 3.0.0-M5 03/174103/1
Matthias Sohn [Thu, 24 Dec 2020 14:05:42 +0000 (15:05 +0100)]
Update maven-surefire plugins to 3.0.0-M5

Change-Id: I0425029eac630f4e8fb47d112d086e74283b2ebd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate japicmp-maven-plugin to 0.14.4 02/174102/1
Matthias Sohn [Thu, 24 Dec 2020 14:02:25 +0000 (15:02 +0100)]
Update japicmp-maven-plugin to 0.14.4

Change-Id: I33ba5388153e6941713b9c9425cd917e9769a177
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate spotbugs-maven-plugin to 4.1.4 01/174101/1
Matthias Sohn [Thu, 24 Dec 2020 14:00:06 +0000 (15:00 +0100)]
Update spotbugs-maven-plugin to 4.1.4

Change-Id: Ie231dc03051f3c8d799f037eeeed8dcaad258fe0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpgrade ecj to 3.24.0 31/173931/2
Marco Miller [Thu, 17 Dec 2020 17:17:24 +0000 (12:17 -0500)]
Upgrade ecj to 3.24.0

Change-Id: I81c03c5f916e97f91cf06dbe3ce355e430b2981a
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
3 years agoUpgrade wagon-ssh to 3.4.2; align maven-site-plugin 15/173315/3
Marco Miller [Thu, 3 Dec 2020 14:12:01 +0000 (09:12 -0500)]
Upgrade wagon-ssh to 3.4.2; align maven-site-plugin

Upgrade wagon-ssh to 3.4.2 in all pom files, thus align
maven-site-plugin versions to 3.9.1 across as well, consistently.

Change-Id: I38f7a6ded3517d1b116169dee1c12deb86eed3a1
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
3 years ago[spotbugs] Fix incorrect lazy initialization in SystemReader 29/173429/6
Matthias Sohn [Sat, 5 Dec 2020 00:34:33 +0000 (01:34 +0100)]
[spotbugs] Fix incorrect lazy initialization in SystemReader

This fixes two warnings of type LI_LAZY_INIT_STATIC.

Change-Id: I26a7a48aed9d0a0547e908a56b7014a7620fadd8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Don't use class from java.util.concurrent for locking 27/173427/6
Matthias Sohn [Fri, 4 Dec 2020 23:39:09 +0000 (00:39 +0100)]
[spotbugs] Don't use class from java.util.concurrent for locking

Use a dedicated Lock object to lock the scheduler in
RepositoryCache#configureEviction to fix spotbugs warning
JLM_JSR166_UTILCONCURRENT_MONITORENTER.

Change-Id: I003dcf0ed1a0a3f4eea5d8a2f51a07473d28a928
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in OpenSshServerKeyDatabase 26/173426/6
Matthias Sohn [Fri, 4 Dec 2020 23:23:15 +0000 (00:23 +0100)]
[spotbugs] Fix potential NPE in OpenSshServerKeyDatabase

If oldLine is null #updateModifiedServerKey shouldn't be called since it
would derefence it. Spotbugs raised this as problem
RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE. Fix it by checking if
oldLine is null before calling #updateModifiedServerKey.

Change-Id: I8a2000492986e52ce7dbe25f48b321c05fd371e4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in FS.FileStoreAttributes#get 25/173425/6
Matthias Sohn [Fri, 4 Dec 2020 22:41:19 +0000 (23:41 +0100)]
[spotbugs] Fix potential NPE in FS.FileStoreAttributes#get

Path#getParent can return null, return fallback filestore attributes in
that case.

Change-Id: Ic09484d527bc87b27964b625e07373b82412f2da
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Silence CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE in jgit tests 79/173379/7
Matthias Sohn [Fri, 4 Dec 2020 10:38:44 +0000 (11:38 +0100)]
[spotbugs] Silence CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE in jgit tests

We want complete control over clone behavior and don't want to use
Object's clone implementation.

Change-Id: I34a4e967f8aa3879c69a4978768bd35712c4105c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Silence NP_BOOLEAN_RETURN_NULL in FakeUserAuthGSS#doAuth 78/173378/7
Matthias Sohn [Fri, 4 Dec 2020 10:27:47 +0000 (11:27 +0100)]
[spotbugs] Silence NP_BOOLEAN_RETURN_NULL in FakeUserAuthGSS#doAuth

Also mark the return value @Nullable to enable null analysis in Eclipse.

Change-Id: Ib954b231d743da6ea122adb2cc4880b5f99824cc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix FileReftableStack#equals to check for null 77/173377/7
Matthias Sohn [Fri, 4 Dec 2020 10:21:08 +0000 (11:21 +0100)]
[spotbugs] Fix FileReftableStack#equals to check for null

This fixes spotbugs warning NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT.

This implementation violated the contract defined by
java.lang.Object.equals() because it did not check for null being passed
as the argument. All equals() methods should return false if passed a
null value.

Change-Id: I607f6979613d390aae2f3546b587f63133d6d73c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] FileReftableDatabase: extract lock to local variable 76/173376/7
Matthias Sohn [Fri, 4 Dec 2020 10:15:35 +0000 (11:15 +0100)]
[spotbugs] FileReftableDatabase: extract lock to local variable

This fixes UL_UNRELEASED_LOCK_EXCEPTION_PATH raised by spotbugs in
#compactFully.

Change-Id: I370578ad9a027c5c9709d60a1dfafdac0cfca908
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] DfsReftableDatabase: extract lock to local variable 75/173375/7
Matthias Sohn [Fri, 4 Dec 2020 10:12:27 +0000 (11:12 +0100)]
[spotbugs] DfsReftableDatabase: extract lock to local variable

This fixes UL_UNRELEASED_LOCK_EXCEPTION_PATH raised by spotbugs in
#DfsReftableDatabase and #clearCache.

Change-Id: Ifd3189288d2a8e64139c02cd105eb335fa2f68cf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Silence NP_BOOLEAN_RETURN_NULL in IgnoreNode#checkIgnored 74/173374/7
Matthias Sohn [Fri, 4 Dec 2020 10:01:06 +0000 (11:01 +0100)]
[spotbugs] Silence NP_BOOLEAN_RETURN_NULL in IgnoreNode#checkIgnored

Also mark the return value @Nullable to enable null analysis in Eclipse.

Change-Id: I5b286d657d432f4b32afd4dd370f76892b115422
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Silence warning DLS_DEAD_LOCAL_STORE in generated classes 73/173373/7
Matthias Sohn [Fri, 4 Dec 2020 09:42:11 +0000 (10:42 +0100)]
[spotbugs] Silence warning DLS_DEAD_LOCAL_STORE in generated classes

Change-Id: I714f5fa48a2443d1a8e2c640b204d3e32438910e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Silence warning about unwritten field written by gson 72/173372/7
Matthias Sohn [Fri, 4 Dec 2020 09:33:59 +0000 (10:33 +0100)]
[spotbugs] Silence warning about unwritten field written by gson

It seems spotbugs does not recognize that this data is written by gson.

Change-Id: I0704d489971c0ab6ec398083f211c409061e7661
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoMerge branch 'stable-5.10' 50/174050/1
Matthias Sohn [Tue, 22 Dec 2020 09:52:24 +0000 (10:52 +0100)]
Merge branch 'stable-5.10'

* stable-5.10:
  Update jgit-4.18 target platform to use release repository

Change-Id: I1bc7b6d38085ba31fa65ad882a4f991da27bbf72
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoRevert "Remove unused API problem filters" 49/174049/1
Matthias Sohn [Tue, 22 Dec 2020 09:50:59 +0000 (10:50 +0100)]
Revert "Remove unused API problem filters"

This reverts commit 022b02dea10612cb01f9694212b72bd1bbd69cb9.

Removing this API warning filter was wrong since we intentionally
removed the config constant CONFIG_REFSTORAGE_REFTREE.

Change-Id: Ie068e539157cc2312efc8a07feabeb0dd2f75096
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoUpdate jgit-4.18 target platform to use release repository 45/173945/1
Matthias Sohn [Thu, 17 Dec 2020 21:26:46 +0000 (22:26 +0100)]
Update jgit-4.18 target platform to use release repository

Change-Id: I62aaf1cb823e05f277b16b156d0f9a4928efe213

3 years agoRemove unused API problem filters 71/173371/5
Matthias Sohn [Fri, 4 Dec 2020 08:42:32 +0000 (09:42 +0100)]
Remove unused API problem filters

Change-Id: Id533cf598cd37c277b4de06fdd8ae74cfeede4d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in FS#write 70/173370/5
Matthias Sohn [Fri, 4 Dec 2020 08:40:47 +0000 (09:40 +0100)]
[spotbugs] Fix potential NPE in FS#write

Path#getParent can return null.

Change-Id: I01f13ac426dda4c007cc5caab546a0c9be62ce76
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in PackFileSnapshotTest 69/173369/5
Matthias Sohn [Fri, 4 Dec 2020 00:51:37 +0000 (01:51 +0100)]
[spotbugs] Fix potential NPE in PackFileSnapshotTest

Path#getFileName can return null. Fix the warning by asserting the file
name isn't null.

Change-Id: I7f2fe75b46113d8be1d14e3f18dd77da27df25ed
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPEs in FileReftableStackTest 68/173368/5
Matthias Sohn [Fri, 4 Dec 2020 00:26:23 +0000 (01:26 +0100)]
[spotbugs] Fix potential NPEs in FileReftableStackTest

File#listFiles can return null. Use Files#list instead to fix the
problem.

Change-Id: I74e0b49aa6dae370219507c64aa43be4d8aa7b82
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in WorkingTreeIterator#isModified 67/173367/4
Matthias Sohn [Thu, 3 Dec 2020 01:04:36 +0000 (02:04 +0100)]
[spotbugs] Fix potential NPE in WorkingTreeIterator#isModified

File#list can return null. Fix the potential NPE by using Files#list
which is also faster since it retrieves directory entries lazily while
File#list retrieves them eagerly.

Change-Id: Idf4bda398861c647587e357326b8bc8b587a2584
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in FileBasedConfigTest 66/173366/4
Matthias Sohn [Thu, 3 Dec 2020 00:54:25 +0000 (01:54 +0100)]
[spotbugs] Fix potential NPE in FileBasedConfigTest

Path#getParent can return null. Fix the warning by implementing a helper
method which asserts the parent is not null.

Change-Id: Ib4f8dff0674b74bc891f15f08bd9755c5ea728dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in GcPruneNonReferencedTest 65/173365/4
Matthias Sohn [Thu, 3 Dec 2020 00:49:18 +0000 (01:49 +0100)]
[spotbugs] Fix potential NPE in GcPruneNonReferencedTest

File#listFiles can return null, assert it is not null to fix the
warning.

Change-Id: I28fc668fee760d39965e6e039003ac9f85fd461b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] Fix potential NPE in FileRepository#convertToReftable 64/173364/3
Matthias Sohn [Thu, 3 Dec 2020 00:44:58 +0000 (01:44 +0100)]
[spotbugs] Fix potential NPE in FileRepository#convertToReftable

File#listFiles can return null. Use Files#list which does not return
null and should be faster since it's returning directory entries lazily
while File#listFiles fetches them eagerly.

Change-Id: I3bfe2a52278244fc469143692c06b05d9af0d0d4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] silence warnings for intended use of == to compare strings 87/172987/4
Matthias Sohn [Sun, 29 Nov 2020 21:03:42 +0000 (22:03 +0100)]
[spotbugs] silence warnings for intended use of == to compare strings

Change-Id: Ib6967ad4deb5cf233d1f1d714cd094da5fad48e3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] silence short-circuit warning in PackOutputStream#write 86/172986/4
Matthias Sohn [Sun, 29 Nov 2020 20:46:09 +0000 (21:46 +0100)]
[spotbugs] silence short-circuit warning in PackOutputStream#write

Change-Id: I47b7a7991afae0dd1e678bd5e1f8e81599791e5f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[spotbugs] parse time using thread-safe DateTimeFormatter 85/172985/4
Matthias Sohn [Sun, 29 Nov 2020 20:43:51 +0000 (21:43 +0100)]
[spotbugs]  parse time using thread-safe DateTimeFormatter

LfsConnectionFactory used a static SimpleDateFormat which isn't
thread-safe. Use DateTimeFormatter instead to fix this.

Change-Id: Id580251c999e1e412c269f37b29860d310124c89
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoFetchProcess#execute: fix formatting 71/172971/5
Matthias Sohn [Sun, 29 Nov 2020 00:24:08 +0000 (01:24 +0100)]
FetchProcess#execute: fix formatting

Change-Id: I133af64e6b165bdc58b8d7c805f0c68b6919baf2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[errorprone] FetchProcess: ensure exception isn't suppressed 70/172970/5
Matthias Sohn [Sat, 28 Nov 2020 23:34:41 +0000 (00:34 +0100)]
[errorprone] FetchProcess: ensure exception isn't suppressed

If TransportException is thrown in the finally block of execute()
ensure that the exception handled in the previous catch block isn't
suppressed.

Change-Id: I670acdfb4d36e7a419a9a79ae9faab2e085a43ee
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years ago[errorprone] WalkFetchConnection: ensure exception isn't suppressed 69/172969/5
Matthias Sohn [Sat, 28 Nov 2020 23:29:08 +0000 (00:29 +0100)]
[errorprone] WalkFetchConnection: ensure exception isn't suppressed

If TransportException is thrown in the finally block of
downloadPackedObject() ensure that the exception handled in the previous
catch block isn't suppressed.

Change-Id: I23982a2b215e38f681cc1719788985e60232699a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoRemove unused API problem filters 95/173795/1
Matthias Sohn [Tue, 15 Dec 2020 00:47:23 +0000 (01:47 +0100)]
Remove unused API problem filters

Change-Id: I982f21dfaec4e35818eca7a4793e24a2cec4e467
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoRemove reftree and ketch 41/152841/2
Han-Wen Nienhuys [Sun, 17 Nov 2019 17:51:14 +0000 (09:51 -0800)]
Remove reftree and ketch

This was experimental code and never used in production.

Change-Id: Ia3da7f2b82d9e365cec2ccf9397cbc47439cd150
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoLsRemote: suppress warning for non-externalized string 94/173794/1
Matthias Sohn [Tue, 15 Dec 2020 00:53:01 +0000 (01:53 +0100)]
LsRemote: suppress warning for non-externalized string

Change-Id: Ic1d8f2eef4a8de0a75d5b523b584b1ac275a8811
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoLooseObjects: fix formatting 93/173793/1
Matthias Sohn [Tue, 15 Dec 2020 01:00:17 +0000 (02:00 +0100)]
LooseObjects: fix formatting

Change-Id: I992e5066d1dc4603e5bae991b26605d319f5cdc2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoSplit out loose object handling from ObjectDirectory 60/122060/6
Martin Fick [Thu, 26 Apr 2018 16:53:57 +0000 (10:53 -0600)]
Split out loose object handling from ObjectDirectory

The ObjectDirectory class manages the interactions for the entire object
database, this includes loose objects, packfiles, alternates, and
shallow commits. To help reduce the complexity of this class, abstract
some of the loose object specific details into a class which understands
just this, leaving the ObjectDirectory to focus more on the interactions
between the different mechanisms.

Change-Id: I39f3a74d6308f042a2a2baa57769f4acde5ba5e0
Signed-off-by: Martin Fick <mfick@codeaurora.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoMerge branch 'stable-5.9' 56/173756/1
Matthias Sohn [Mon, 14 Dec 2020 15:03:00 +0000 (16:03 +0100)]
Merge branch 'stable-5.9'

* stable-5.9:
  Fix stamping to produce stable file timestamps

Change-Id: Icd092cd9b883556fcbd115c17346a9d88dc172ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoFix stamping to produce stable file timestamps 23/173523/3
David Ostrovsky [Sat, 5 Dec 2020 13:48:23 +0000 (14:48 +0100)]
Fix stamping to produce stable file timestamps

Change-Id: I628ab5feb4a70f81ec832f1b81d1ad3a9caca615

3 years agoPackDirectory: fix formatting 27/173727/1
Matthias Sohn [Sat, 12 Dec 2020 22:32:09 +0000 (23:32 +0100)]
PackDirectory: fix formatting

Change-Id: I10586981323529c7e9041110ebb58033e7180194
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoSplit out packfile handling from ObjectDirectory 59/122059/6
Martin Fick [Wed, 25 Apr 2018 17:59:21 +0000 (11:59 -0600)]
Split out packfile handling from ObjectDirectory

The ObjectDirectory class manages the interactions for the entire object
database, this includes loose objects, packfiles, alternates, and
shallow commits. To help reduce the complexity of this class, abstract
some of the packfile specific details into a class which understands
just this, leaving the ObjectDirectory to focus more on the interactions
between the different mechanisms.

Change-Id: I5cc87b964434b0afa860b3fe23867a77b3c3a4f2
Signed-off-by: Martin Fick <mfick@codeaurora.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
3 years agoTagCommand: propagate NO_CHANGE information 38/173538/2
Thomas Wolf [Tue, 8 Dec 2020 14:45:35 +0000 (15:45 +0100)]
TagCommand: propagate NO_CHANGE information

Some clients may wish to allow NO_CHANGE lightweight tag updates
without setting the force flag. (For instance EGit does so.)
Command-line git does not allow this.

Propagate the RefUpdate result via the RefAlreadyExistsException.
That way a client has the possibility to catch it and check the
failure reason without having to parse the exception message, and
take appropriate action, like ignoring the exception on NO_CHANGE.

Change-Id: I60e7a15a3c309db4106cab87847a19b6d24866f6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>