]> source.dussan.org Git - jgit.git/log
jgit.git
4 years agoMerge branch 'stable-5.10' 51/172851/1
Matthias Sohn [Wed, 25 Nov 2020 21:33:04 +0000 (22:33 +0100)]
Merge branch 'stable-5.10'

* stable-5.10:
  Prepare 5.10.0-SNAPSHOT builds
  JGit v5.10.0.202011251205-m3
  Prepare 5.10.0-SNAPSHOT builds
  JGit v5.10.0.202011041322-m2

Change-Id: Ifc188fec62d9ee86243d289a2595a92113c9dd0a

4 years agoPrepare 5.10.0-SNAPSHOT builds 50/172850/1
Matthias Sohn [Wed, 25 Nov 2020 21:30:34 +0000 (22:30 +0100)]
Prepare 5.10.0-SNAPSHOT builds

Change-Id: Iabc845edf565ac706344f68f854384faa63b6f43
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoJGit v5.10.0.202011251205-m3 37/172837/1 v5.10.0.202011251205-m3
Matthias Sohn [Wed, 25 Nov 2020 17:05:35 +0000 (18:05 +0100)]
JGit v5.10.0.202011251205-m3

Change-Id: Id58d8eb49f550e62b04053a71366f7eabd9f9a53
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoMerge branch 'master' into stable-5.10 30/172830/1
Matthias Sohn [Wed, 25 Nov 2020 16:39:25 +0000 (17:39 +0100)]
Merge branch 'master' into stable-5.10

* master:
  Update Orbit to S20201118210000 and add target for 4.18
  PacketLineIn: ensure that END != DELIM
  PacketLineIn: ensure that END != DELIM
  Allow to resolve a conflict by checking out a file
  Update Orbit to I20201111205634
  Document that setLastModified sets time of symlink target
  Fix bug in PerformanceLogContext
  Fix IOException occurring during gc

Change-Id: I2980552381d1ae61b9b2d81d7289de37d6bf4cae
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoUpdate Orbit to S20201118210000 and add target for 4.18 77/172577/1
Matthias Sohn [Fri, 20 Nov 2020 10:05:08 +0000 (11:05 +0100)]
Update Orbit to S20201118210000 and add target for 4.18

- replace target platform for 4.17 staging with final release
- add target platform for Eclipse 4.18 (2020-12)

Change-Id: I4fb60cc346e275b755bba8d32b1964c2673fb615
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoMerge branch 'stable-5.9' 76/172576/1
Matthias Sohn [Fri, 20 Nov 2020 09:56:12 +0000 (10:56 +0100)]
Merge branch 'stable-5.9'

* stable-5.9:
  PacketLineIn: ensure that END != DELIM

Change-Id: Ib2408d71b56080bb1fd1670f0cd62dc7f4cb6c4d

4 years agoPacketLineIn: ensure that END != DELIM 35/172535/1
Thomas Wolf [Thu, 19 Nov 2020 12:23:05 +0000 (13:23 +0100)]
PacketLineIn: ensure that END != DELIM

Just allocate the two string objects directly. The previously used
new StringBuilder(0).toString() returns the same object for both END
and DELIM when run on Java 15, which breaks the wire protocol since
then END and DELIM cannot be distinguished anymore.

Bug: 568950
Change-Id: I9d54d7bf484948c24b51a094256bd9d38b085f35
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
(cherry picked from commit 7da0f0a8f37e35e9c3108588f1e6f7a7381d8f77)

4 years agoPacketLineIn: ensure that END != DELIM 02/172502/1
Thomas Wolf [Thu, 19 Nov 2020 12:23:05 +0000 (13:23 +0100)]
PacketLineIn: ensure that END != DELIM

Just allocate the two string objects directly. The previously used
new StringBuilder(0).toString() returns the same object for both END
and DELIM when run on Java 15, which breaks the wire protocol since
then END and DELIM cannot be distinguished anymore.

Bug: 568950
Change-Id: I9d54d7bf484948c24b51a094256bd9d38b085f35
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoAllow to resolve a conflict by checking out a file 72/172372/1
Thomas Wolf [Sun, 15 Nov 2020 17:45:12 +0000 (18:45 +0100)]
Allow to resolve a conflict by checking out a file

DirCacheEditor unconditionally applied a PathEdit to all stages in the
index. This gives wrong results if one wants to check out a file from
some commit to resolve a conflict: JGit would update the working tree
file multiple times (once per stage), and set all stages to point to
the checked-out blob.

C git replaces the stages by the entry for the checked-out file.

To support this, add a DirCacheEntry.setStage() method so that
CheckoutCommand can force the stage to zero. In DirCacheEditor, keep
only the zero stage if the PathEdit re-set the stage.

Bug: 568038
Change-Id: Ic7c635bb5aaa06ffaaeed50bc5e45702c56fc6d1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoUpdate Orbit to I20201111205634 47/172247/1
Matthias Sohn [Sat, 14 Nov 2020 20:48:31 +0000 (21:48 +0100)]
Update Orbit to I20201111205634

and update
- org.apache.ant to 1.10.9.v20201106-1946
- org.slf4j.binding.log4j12 to 1.7.30.v20201108-2042

Change-Id: Id15d14dea3a61dabde974c3ea9332d47fb19f4d9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoDocument that setLastModified sets time of symlink target 17/167817/10
Matthias Sohn [Mon, 17 Aug 2020 12:23:29 +0000 (14:23 +0200)]
Document that setLastModified sets time of symlink target

Due to Java bug JDK-8220793 [1] Java cannot set timestamps of a symlink
but only of the symlink target. This bug was fixed in Java 13. Since we
don't have a use case to set the timestamp of the symlink itself simply
document the current behavior of setLastModified methods.

[1] https://bugs.openjdk.java.net/browse/JDK-8220793

Change-Id: Ibc28c1702a1b9845602bd257606fbd44803a43fb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoFix bug in PerformanceLogContext 01/171201/15
Alexa Panfil [Fri, 23 Oct 2020 17:23:23 +0000 (17:23 +0000)]
Fix bug in PerformanceLogContext

PerformanceLogContext threw NullPointerException when multiple threads
tried to add an event to the PerformanceLogContext. The cause for this
is that the ThreadLocal was initialized only in the class constructor
for the first thread; for subsequent threads it was null.

To fix this initialize eventRecords for each thread.

Change-Id: I18ef67dff8f0488e3ad28c9bbc18ce73d5168cf9
Signed-off-by: Alexa Panfil <alexapizza@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoFix IOException occurring during gc 62/171362/2
Nail Samatov [Tue, 27 Oct 2020 13:56:24 +0000 (16:56 +0300)]
Fix IOException occurring during gc

Fix IOException occurring when calling
GC on a repository with absent objects/pack folder.

Change-Id: I5be1333a0726f4d7491afd25ddac85451686c30a
Signed-off-by: Nail Samatov <sanail@yandex.ru>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoPrepare 5.10.0-SNAPSHOT builds 82/171782/1
Matthias Sohn [Wed, 4 Nov 2020 22:48:37 +0000 (23:48 +0100)]
Prepare 5.10.0-SNAPSHOT builds

Change-Id: Ie13f90948669c8cdebd14e74a91df9daf0387ccf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoJGit v5.10.0.202011041322-m2 63/171763/1 v5.10.0.202011041322-m2
Matthias Sohn [Wed, 4 Nov 2020 18:38:49 +0000 (19:38 +0100)]
JGit v5.10.0.202011041322-m2

Change-Id: Ia2709321f61f61208350eaa8aa48e56b88455146
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoRevert "Client-side protocol V2 support for fetching" 24/171724/2
Thomas Wolf [Tue, 3 Nov 2020 22:33:19 +0000 (23:33 +0100)]
Revert "Client-side protocol V2 support for fetching"

This reverts commit f802f06e7fd5a98f256b7b7727598491f563bf2f.

I had misunderstood how protocol V2 works. This implementation only
works if the negotiation during fetch is done in one round.

Fixing this is substantial work in BasePackFetchConnection. Basically
I think I'd have to change back negotiate to the V0 version, and have
a doFetch() that does

  if protocol V2
    doFetchV2()
  else
    doFetchV0()

with doFetchV0 the old code, and doFetchV2 completely new.

Plus there would need to be a HTTP test case requiring several
negotiation rounds.

This is a couple of days work at least, and I don't know when I will
have the time to revisit this. So although the rest of the code is
fine I prefer to back this out completely and not leave a only half
working implementation in the code for an indeterminate time.

Bug: 553083
Change-Id: Icbbbb09882b3b83f9897deac4a06d5f8dc99d84e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoClose Repository to fix tests failing on Windows 63/171363/2
Nail Samatov [Tue, 27 Oct 2020 14:37:24 +0000 (17:37 +0300)]
Close Repository to fix tests failing on Windows

Fix tests failing on Windows because Repository
instance is created but not closed on tear down.

Change-Id: I72488ba5efeec95110926b1fbd56b7d96fca0d37
Signed-off-by: Nail Samatov <sanail@yandex.ru>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoClient-side protocol V2 support for fetching 04/167204/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 (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. Do the same for the SSH transport tests.

Bug: 553083
Change-Id: Ice9866aa78020f5ca8f397cde84dc224bf5d41b4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoUpdate slf4j to 1.7.30 94/171394/2
Matthias Sohn [Wed, 28 Oct 2020 10:29:35 +0000 (11:29 +0100)]
Update slf4j to 1.7.30

Bug: 566475
Change-Id: Ia3e5b72d53ead435e4677e46c73a3ff45a606b41
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoUpdate Orbit to S20201027182932 (2020-12 M2) 93/171393/1
Matthias Sohn [Wed, 28 Oct 2020 10:04:53 +0000 (11:04 +0100)]
Update Orbit to S20201027182932 (2020-12 M2)

Change-Id: I24add2e8133f5c83675ab3ade58d7d6db29771ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoFix formatting of config option values 71/169071/5
Matthias Sohn [Wed, 9 Sep 2020 09:47:24 +0000 (11:47 +0200)]
Fix formatting of config option values

Change-Id: If9a4bb44c4b348cbb94127207566471105267a53

4 years agoDocument options in core section supported by JGit 46/169046/6
Matthias Sohn [Tue, 8 Sep 2020 22:05:31 +0000 (00:05 +0200)]
Document options in core section supported by JGit

Change-Id: I25af04112cf219405718b5c3e8e103156fb30fa5

4 years agoEnsure .gitmodules is loaded when accessing submodule name 63/168663/3
John Dallaway [Wed, 2 Sep 2020 13:15:23 +0000 (14:15 +0100)]
Ensure .gitmodules is loaded when accessing submodule name

This problem occurred when calling SubmoduleWalk#getModuleName if the
first submodule processed has a name and a path which do not match
SubmoduleWalk#getModuleName returned the module path instead of the
module name. In order to fix this SubmoduleWalk#getModuleName needs to
ensure that the modules config is loaded.

Bug: 565776
Change-Id: I36ce1fbc64c4849f9d8e39864b825c6e28d344f8
Signed-off-by: John Dallaway <john@dallaway.org.uk>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoExport new package org.eclipse.jgit.logging and import it where used 66/171266/1
Matthias Sohn [Sun, 25 Oct 2020 12:40:32 +0000 (13:40 +0100)]
Export new package org.eclipse.jgit.logging and import it where used

Change-Id: Ib81b8733e184e75c2cba21ab27c4bbe8dbe0b04d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoEnsure GC.deleteOrphans() can delete read-only orphaned files on Windows 02/171102/1
Matthias Sohn [Thu, 22 Oct 2020 07:25:55 +0000 (09:25 +0200)]
Ensure GC.deleteOrphans() can delete read-only orphaned files on Windows

Reported in https://www.eclipse.org/lists/jgit-dev/msg04005.html

Change-Id: I140a49a7f65a76aa2b67ec8d286a3d2506ae499a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoMerge "Add new performance logging"
Terry Parker [Wed, 21 Oct 2020 15:53:35 +0000 (11:53 -0400)]
Merge "Add new performance logging"

4 years agoAdd new performance logging 87/170887/5
Alexa Panfil [Mon, 12 Oct 2020 08:55:46 +0000 (08:55 +0000)]
Add new performance logging

Add new performance logging to register events of type duration.
The proposed logging is similar to the performance logging
in OS Gerrit https://gerrit-review.googlesource.com/c/gerrit/+/225628:
a global Singleton (LoggingContext in Gerrit) is
collecting the performance logs in a thread-safe events list,
and at the end of the monitored command the list of events is
retrieved and written to a log, after which it is cleared.

What this patch does:
The main component is the Singleton (PerformanceLogContext), which
is used to collect the records (PerformanceLogRecord) in one place
(ThreadLocal eventsList) from anywhere using
PerformanceLogContext.getInstance().addEvent().

Reason why this change is needed:
The current monitoring in JGit has several issues:
1. git fetch and git push events are handled separately
(PackStatistics and ReceivedPackStatistics), with no unified way
of writing or reading the statistics.
2. PostUploadHook is only invoked on the event of sending the
pack, which means that the PackStatistics is not available for
the fetch requests that did not end with sending the pack
(negotiation requests).
3. The way the logs are created is different from the performance
log approach, so the long-running operations need to be collected
from both performance log (for JGit DFS overridden operations and
Gerrit operations) and gitlog (for JGit ones).

The proposed performance logging is going to solve the above
mentioned issues: it collects all of the performance logs in one
place, thus accounting for the commands that do not result in
sending a pack. The logs are compatible with the ones on Gerrit.
Moreover, the Singleton is accessible anywhere in the call stack,
which proved to be successful in other projects like Dapper
(https://research.google/pubs/pub36356/).

Signed-off-by: Alexa Panfil <alexapizza@google.com>
Change-Id: Iabfe667a3412d8a9db94aabb0f39b57f43469c41

4 years agoMerge "Compute time differences with Duration"
Jonathan Tan [Mon, 19 Oct 2020 16:25:57 +0000 (12:25 -0400)]
Merge "Compute time differences with Duration"

4 years agoMerge "Implement git describe --all"
Christian Halstrick [Tue, 13 Oct 2020 12:14:14 +0000 (08:14 -0400)]
Merge "Implement git describe --all"

4 years agoImplement git describe --all 92/170292/2
Jason Yeo [Mon, 5 Oct 2020 05:07:22 +0000 (13:07 +0800)]
Implement git describe --all

This enables jgit to use any refs in the refs/ namespace when describing
commits.

Signed-off-by: Jason Yeo <jasonyeo88@gmail.com>
Change-Id: I1fa22d1c39c0e2f5e4c2938c9751d8556494ac26

4 years agoCompute time differences with Duration 62/170562/3
Alexa Panfil [Fri, 9 Oct 2020 16:52:04 +0000 (16:52 +0000)]
Compute time differences with Duration

Reason why this change is needed:
Currently the durations of fetch events are computed by
registering time instants with System.currentTimeMillis()
and calculating the differences with simple minus operation,
but multiple sources suggest that the best practice is to use
the Java 8 Duration and Instant objects.

What this patch does:
Get time measurements with Instant.now() instead of
System.currentTimeMillis() and calculate the duration of fetch
events (Reachability checks and Negotiation) using
Duration.between().toMillis().

Signed-off-by: Alexa Panfil <alexapizza@google.com>
Change-Id: I573a0a0562070083cf5a5a196d9710f69a7fa587

4 years agoOverride config http.userAgent from environment GIT_HTTP_USER_AGENT 19/170319/2
Thomas Wolf [Mon, 5 Oct 2020 10:32:38 +0000 (12:32 +0200)]
Override config http.userAgent from environment GIT_HTTP_USER_AGENT

According to [1], environment variable GIT_HTTP_USER_AGENT can
override a git config http.userAgent.

[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-httpuserAgent

Change-Id: I996789dc49faf96339cd7b4e0a682b9bcafb6f70
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoUpgrade spotbugs-maven-plugin to 4.1.3 48/170248/2
Marco Miller [Fri, 2 Oct 2020 17:28:07 +0000 (13:28 -0400)]
Upgrade spotbugs-maven-plugin to 4.1.3

Since 4.0.4, aligns with spotbugs 4.1.3 [1]. Also, "fixes copy of repo
being put until target" and "reduces logging output below threshold".

[1] https://github.com/spotbugs/spotbugs-maven-plugin/releases

Change-Id: Idb7127ba7b5fc40bf85a13bb193760bbf6ec0f7c
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years agoFix OperatorPrecedence warning flagged by error prone 46/170246/1
David Ostrovsky [Fri, 2 Oct 2020 16:49:21 +0000 (18:49 +0200)]
Fix OperatorPrecedence warning flagged by error prone

Building with Bazel is failing with this error message:

HttpSupport.java:480: error: [OperatorPrecedence] Use grouping
parenthesis to make the operator precedence explicit
    if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') {
                             ^
    (see https://errorprone.info/bugpattern/OperatorPrecedence)
Did you mean 'if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {'?

Change-Id: I96089d3158d06ba981cfdf2b03865261b328de23

4 years agoUploadPackTest#testUploadRedundantBytes: ensure test repo is closed 87/170187/1
Matthias Sohn [Thu, 1 Oct 2020 23:17:37 +0000 (01:17 +0200)]
UploadPackTest#testUploadRedundantBytes: ensure test repo is closed

This fixes a resource leak warning.

Change-Id: I65166eeefc719ea577963c84ce2059e2d7e6c1d7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoObjectDirectory#selectObjectRepresentation: fix formatting 86/170186/1
Matthias Sohn [Thu, 1 Oct 2020 22:55:04 +0000 (00:55 +0200)]
ObjectDirectory#selectObjectRepresentation: fix formatting

Change-Id: I3872f3001bb11e29a526ed90184ccb0c991b8567
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoUpgrade ecj to 3.23.0 73/169673/2
Marco Miller [Mon, 21 Sep 2020 15:52:44 +0000 (11:52 -0400)]
Upgrade ecj to 3.23.0

Change-Id: Ifca682c4aff0cfcd827986a02580e70dcfcad5c0
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years agoSupport "http.userAgent" and "http.extraHeader" from the git config 70/132970/8
James Wynn [Mon, 31 Aug 2020 20:32:13 +0000 (15:32 -0500)]
Support "http.userAgent" and "http.extraHeader" from the git config

Validate the extra headers and log but otherwise ignore invalid
headers. An empty http.extraHeader starts the list afresh.

The http.userAgent is restricted to printable 7-bit ASCII, other
characters are replaced by '.'.

Moves a support method from the ssh.apache bundle to HttpSupport in
the main JGit bundle.

Bug:541500
Change-Id: Id2d8df12914e2cdbd936ff00dc824d8f871bd580
Signed-off-by: James Wynn <james@jameswynn.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agosshd: better error report when user cancels authentication 62/169262/4
Thomas Wolf [Sun, 13 Sep 2020 19:46:46 +0000 (21:46 +0200)]
sshd: better error report when user cancels authentication

Use a dedicated exception class to be able to detect this case in the
SshdSessionFactory and skip the generic SshException in that case.

Change-Id: I2a0bacf47bae82f154a0f4e79efbb2af2a17d0cf
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoAPI filters for PackStatistics.Accumulator 46/169946/1
Thomas Wolf [Sat, 26 Sep 2020 17:56:46 +0000 (19:56 +0200)]
API filters for PackStatistics.Accumulator

Change-Id: Iaafb766aa76f0e8f837bd37c0729b1262e7ac1f6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoAdd TypedConfigGetter.getPath() 56/169856/2
Thomas Wolf [Thu, 24 Sep 2020 19:34:29 +0000 (21:34 +0200)]
Add TypedConfigGetter.getPath()

This enables EGit to override with a lenient variant that logs the
problem and continues with the default value. EGit needs this because
otherwise a corrupt core.excludesFile entry can render the whole UI
unusable (until the git config is fixed) because any use of the
WorkingTreeIterator will throw an InvalidPathException.

This is not a problem on OS X, where all characters are allowed in
file names. But on Windows some characters are forbidden... see bug
567296. The message of the InvalidPathException is not helpful since
it doesn't point to the origin of the problem. EGit can log a much
better message indicating the offending config file and entry in the
Eclipse error log, where the user can see it.

Bug: 567309
Change-Id: I4e57afa715ff3aaa52cd04b5733f69e53af5b1e0
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoMake Javadoc consistent for PackStatistics fields 55/169855/2
Alexa Panfil [Thu, 24 Sep 2020 19:28:52 +0000 (19:28 +0000)]
Make Javadoc consistent for PackStatistics fields

Change-Id: I53d4072174e9fec92bff7c0225aa7470d8d39d05

4 years agoMeasure time taken for reachability checks 79/168079/16
Alexa Panfil [Thu, 24 Sep 2020 12:25:56 +0000 (12:25 +0000)]
Measure time taken for reachability checks

Reason why this change is needed:
Getting this metric will help estimate how much time will be saved once
the reachability checks get optimized

What this patch does:
Measure time spent by requestValidator.checkWants() in parseWants() and save
it in an instance of PackStatistics.Accumulator.

Signed-off-by: Alexa Panfil <alexapizza@google.com>
Change-Id: Id7fe4016f96549d9511a2c24052dad93cfbb31a4

4 years agoMerge "Measure time taken for negotiation in protocol V2"
Terry Parker [Tue, 22 Sep 2020 15:34:24 +0000 (11:34 -0400)]
Merge "Measure time taken for negotiation in protocol V2"

4 years agoMeasure time taken for negotiation in protocol V2 85/168985/7
Alexa Panfil [Fri, 11 Sep 2020 09:34:23 +0000 (09:34 +0000)]
Measure time taken for negotiation in protocol V2

Reason why this change is needed:
Getting this metric will help estimate how much time is spent
on negotiation in fetch V2.

What this patch does:
Measure time spent on negotiation rounds in UploadPack.fetchV2()
and save it in an instance of PackStatistics.Accumulator.
This is the same way the statistics are already gathered for
protocol V0/V1.

Change-Id: I14e55dd6ff743cb0b21b4953b533269ef069abb1

4 years agoIndexDiffFilter: handle path prefixes correctly 70/169170/2
Thomas Wolf [Thu, 10 Sep 2020 21:39:07 +0000 (23:39 +0200)]
IndexDiffFilter: handle path prefixes correctly

When comparing git directory paths to check whether one is a prefix
of another, one must add a slash to avoid false prefix matches when
one directory name is a prefix of another. The path "audio" is not
a prefix of the path "audio-new", but would be a prefix of a path
"audio/new".

Bug: 566799
Change-Id: I6f671ca043c7c2c6044eb05a71dc8cca8d0ee040
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agosshd: support the ProxyJump ssh config 68/166868/16
Thomas Wolf [Sun, 26 Jul 2020 18:37:57 +0000 (20:37 +0200)]
sshd: support the ProxyJump ssh config

This is useful to access git repositories behind a bastion server
(jump host).

Add a constant for the config; rewrite the whole connection initiation
to parse the value and (recursively) set up the chain of hops. Add
tests for a single hop and two different ways to configure a two-hop
chain.

The connection timeout applies to each hop in the chain individually.

Change-Id: Idd25af95aa2ec5367404587e4e530b0663c03665
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoUpgrade jacoco-maven-plugin to 0.8.6 72/169472/1
Marco Miller [Wed, 16 Sep 2020 12:34:08 +0000 (08:34 -0400)]
Upgrade jacoco-maven-plugin to 0.8.6

Change-Id: Ifd4e8fc60844690d144a0872db4f740f45226ff9
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years agoMerge "ReceivePackStats: Add size and count of unnecessary pushed objects"
Terry Parker [Mon, 14 Sep 2020 13:53:43 +0000 (09:53 -0400)]
Merge "ReceivePackStats: Add size and count of unnecessary pushed objects"

4 years agoReceivePackStats: Add size and count of unnecessary pushed objects 04/160004/31
Yunjie Li [Wed, 25 Mar 2020 17:59:06 +0000 (10:59 -0700)]
ReceivePackStats: Add size and count of unnecessary pushed objects

Since there is no negotiation for a push, the client is probably sending
redundant objects and bytes which already exist in the server.

Add more metrics in the stats to quantify it. Duplicated size and number
to measure the size and the number of duplicated objects which should
not be pushed.

Change-Id: Iaacd4761ee9366a0a7ec4e26c508eff45c8744de
Signed-off-by: Yunjie Li <yunjieli@google.com>
4 years agoMerge branch 'stable-5.9' into master 47/169047/1
Matthias Sohn [Tue, 8 Sep 2020 22:12:45 +0000 (00:12 +0200)]
Merge branch 'stable-5.9' into master

* stable-5.9:
  Prepare 5.9.1-SNAPSHOT builds
  JGit v5.9.0.202009080501-r
  [releng] Enable japicmp for the fragments added in 5.8.0
  GitlinkMergeTest: fix boxing warnings
  Remove unused API problem filters
  Add missing since tag on BundleWriter#addObjectsAsIs
  GPG: include signer's user ID in the signature

Change-Id: Iaa96f9228752540f446fc232a49f31a738fd8d30
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoUpgrade maven-project-info-reports-plugin to 3.1.1 34/169034/2
Marco Miller [Tue, 8 Sep 2020 18:01:42 +0000 (14:01 -0400)]
Upgrade maven-project-info-reports-plugin to 3.1.1

Change-Id: I1a3c68e8ebab79e1a23616d1f56f75981c56a7f3
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years agoPrepare 5.9.1-SNAPSHOT builds 20/169020/1
Matthias Sohn [Tue, 8 Sep 2020 15:45:20 +0000 (17:45 +0200)]
Prepare 5.9.1-SNAPSHOT builds

Change-Id: I9006e7961111982943ffef496d15bd525959b3e4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoJGit v5.9.0.202009080501-r 99/168999/1 v5.9.0.202009080501-r
Matthias Sohn [Tue, 8 Sep 2020 11:01:43 +0000 (13:01 +0200)]
JGit v5.9.0.202009080501-r

Change-Id: Ic98ae61b3f327ef72256fd9b2e28510e3a481de7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years ago[releng] Enable japicmp for the fragments added in 5.8.0 68/168968/1
Thomas Wolf [Mon, 7 Sep 2020 21:42:51 +0000 (23:42 +0200)]
[releng] Enable japicmp for the fragments added in 5.8.0

Uncomment the japicmp configurations in the pom.xmls of the fragments
org.eclipse.jgit.gpg.bc and org.eclipse.jgit.ssh.jsch.

Change-Id: I7c884be014cb48387f97a300043b04aeb712fbba
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoGitlinkMergeTest: fix boxing warnings 64/168864/1
Matthias Sohn [Sat, 5 Sep 2020 21:28:06 +0000 (23:28 +0200)]
GitlinkMergeTest: fix boxing warnings

Change-Id: I4bdf1ab3e7d7e9d96318e2b16b792aa98ebd2ecd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoRemove unused API problem filters 63/168863/1
Matthias Sohn [Sat, 5 Sep 2020 21:25:58 +0000 (23:25 +0200)]
Remove unused API problem filters

Change-Id: Ice154340e3377e89dc51d40587c8a4c5caec2bcf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoAdd missing since tag on BundleWriter#addObjectsAsIs 62/168862/1
Matthias Sohn [Sat, 5 Sep 2020 21:25:02 +0000 (23:25 +0200)]
Add missing since tag on BundleWriter#addObjectsAsIs

Change-Id: Ia07c0ede31e280831869db77b70b43874d8ba3ac
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoMerge branch 'master' into stable-5.9 61/168861/1
Matthias Sohn [Sat, 5 Sep 2020 20:51:02 +0000 (22:51 +0200)]
Merge branch 'master' into stable-5.9

* master:
  SshdSession: close channel gracefully
  jgit: Add DfsBundleWriter
  Prepare 5.10.0-SNAPSHOT builds
  ResolveMerger: do not content-merge gitlinks on del/mod conflicts
  ResolveMerger: Adding test cases for GITLINK deletion
  ResolveMerger: choose OURS on gitlink when ignoreConflicts
  ResolveMerger: improving content merge readability
  ResolveMerger: extracting createGitLinksMergeResult method
  ResolveMerger: Adding test cases for GITLINK merge

Back out the version change to 5.10.0-SNAPSHOT which was done on master
already.

Change-Id: I1a6b1f0b8f5773be47823d74f593d13b16a601d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoSshdSession: close channel gracefully 37/168537/2
Thomas Wolf [Mon, 31 Aug 2020 19:22:26 +0000 (21:22 +0200)]
SshdSession: close channel gracefully

Close the channel gracefully to give the server a chance to clean up
properly on its side.

Bug: 565854
Change-Id: Iedda5af3b97c8321f08f7ce854274cbb30e401de
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoGPG: include signer's user ID in the signature 78/165078/2
Thomas Wolf [Wed, 17 Jun 2020 16:43:32 +0000 (18:43 +0200)]
GPG: include signer's user ID in the signature

Signing a commit with command line git and gpg 2.2.20 includes the
e-mail part of the key's user ID as a "Signer's User ID" subpacket
on the signature.

Implement this for signing via Bouncy Castle.

Bug: 564386
Change-Id: I68906b895349359596cf3451d65f2840c60df856
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoMerge branch 'stable-5.9' 40/168840/1
Marco Miller [Fri, 4 Sep 2020 16:06:49 +0000 (12:06 -0400)]
Merge branch 'stable-5.9'

* stable-5.9:
  Bump Bazel version to 3.5.0

Change-Id: Ic96a2918c34696d31af5104305201e8426989a9d
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years agojgit: Add DfsBundleWriter 90/156490/3
Masaya Suzuki [Fri, 24 Jan 2020 00:47:40 +0000 (16:47 -0800)]
jgit: Add DfsBundleWriter

DfsBundleWriter writes out the entire repository to a Git bundle file.
It packs all objects included in the packfile by concatenating all pack
files. This makes the bundle creation fast and cheap. Useful for backing
up a repository as-is.

Change-Id: Iee20e4b1ab45b2a178dde8c72093c0dd83f04805
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
4 years agoMerge changes from topic "fix_ui"
Terry Parker [Thu, 3 Sep 2020 22:35:24 +0000 (18:35 -0400)]
Merge changes from topic "fix_ui"

* changes:
  ResolveMerger: do not content-merge gitlinks on del/mod conflicts
  ResolveMerger: Adding test cases for GITLINK deletion
  ResolveMerger: choose OURS on gitlink when ignoreConflicts
  ResolveMerger: improving content merge readability
  ResolveMerger: extracting createGitLinksMergeResult method
  ResolveMerger: Adding test cases for GITLINK merge

4 years agoBump Bazel version to 3.5.0 73/168773/1
Marco Miller [Thu, 3 Sep 2020 17:49:38 +0000 (13:49 -0400)]
Bump Bazel version to 3.5.0

This latest release includes cherry picks, a new feature and some
important changes [1].

[1] https://github.com/bazelbuild/bazel/releases/tag/3.5.0

Change-Id: Ie6966b0b56a351f98cb20b25daf3412740e68562
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years agoMerge branch 'stable-5.9' 94/168694/1
Marco Miller [Wed, 2 Sep 2020 20:49:41 +0000 (16:49 -0400)]
Merge branch 'stable-5.9'

* stable-5.9:
  Upgrade maven-resources-plugin to 3.2.0
  Upgrade plexus-compiler version to 2.8.8
  [bazel] Add missing dependency to slf4j-api
  [errorprone] DirCacheEntry: make clear operator precedence
  [errorprone] PackWriter#parallelDeltaSearch: avoid suppressed exception
  [errorprone] Declare DirCache#version final
  Add jgit-4.17-staging target platform for 2020-09
  Update target platform to R20200831200620

Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Change-Id: I2e2f41cf6ebbcb45b8978b519db3f1c8f7afb5f4

4 years agoMerge changes Ib0b2dc7c,I827da397 into stable-5.9
Matthias Sohn [Wed, 2 Sep 2020 11:58:47 +0000 (07:58 -0400)]
Merge changes Ib0b2dc7c,I827da397 into stable-5.9

* changes:
  Upgrade maven-resources-plugin to 3.2.0
  Upgrade plexus-compiler version to 2.8.8

4 years agoUpgrade maven-resources-plugin to 3.2.0 10/168610/1
Marco Miller [Tue, 25 Aug 2020 20:42:56 +0000 (16:42 -0400)]
Upgrade maven-resources-plugin to 3.2.0

Change-Id: Ib0b2dc7c5b781dbc4ce26782c508b8c7e11641ed
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years agoUpgrade plexus-compiler version to 2.8.8 09/168609/1
Marco Miller [Tue, 25 Aug 2020 20:34:50 +0000 (16:34 -0400)]
Upgrade plexus-compiler version to 2.8.8

Change-Id: I827da3973f489b03f9321b065dfb96ad7c29e270
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
4 years ago[bazel] Add missing dependency to slf4j-api 53/168453/3
Matthias Sohn [Mon, 31 Aug 2020 07:20:06 +0000 (09:20 +0200)]
[bazel] Add missing dependency to slf4j-api

Change-Id: I8a6b0cc8892ff4ba83d0f4a0d5801b1de27401f4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years ago[errorprone] DirCacheEntry: make clear operator precedence 52/168452/3
Matthias Sohn [Mon, 31 Aug 2020 00:22:37 +0000 (02:22 +0200)]
[errorprone] DirCacheEntry: make clear operator precedence

See https://errorprone.info/bugpattern/OperatorPrecedence

Change-Id: I96f2c844a7b3d9d5605122118d9420bde31ec2f0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years ago[errorprone] PackWriter#parallelDeltaSearch: avoid suppressed exception 51/168451/3
Matthias Sohn [Mon, 31 Aug 2020 00:18:43 +0000 (02:18 +0200)]
[errorprone] PackWriter#parallelDeltaSearch: avoid suppressed exception

See https://errorprone.info/bugpattern/Finally

Change-Id: Ic2ad0d1e1ba7552b5a5c6238f83c0e13a94254d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years ago[errorprone] Declare DirCache#version final 50/168450/3
Matthias Sohn [Sun, 30 Aug 2020 22:51:08 +0000 (00:51 +0200)]
[errorprone] Declare DirCache#version final

Enums values should be immutable, see
https://errorprone.info/bugpattern/ImmutableEnumChecker.

Change-Id: Ib0a358d3a5f1560ca73ec3153ca8088fe7a35eb6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoAdd jgit-4.17-staging target platform for 2020-09 40/168440/2
Matthias Sohn [Sun, 30 Aug 2020 22:41:41 +0000 (00:41 +0200)]
Add jgit-4.17-staging target platform for 2020-09

Change-Id: Ic3d3f7d1a4d13b40426675d29d8c521f1437f845
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoUpdate target platform to R20200831200620 39/168439/2
Matthias Sohn [Sun, 30 Aug 2020 22:37:03 +0000 (00:37 +0200)]
Update target platform to R20200831200620

and update to new Orbit version of the following libraries
- org.apache.commons.codec to 1.14.0.v20200818-1422
- org.apache.httpcomponents.httpclient to 4.5.10.v20200830-2311
- org.bouncycastle.bcpg [1.65.0.v20200527-1955
- org.bouncycastle.bcpkix [1.65.0.v20200527-1955
- org.bouncycastle.bcprov [1.65.1.v20200529-1514

Fix minor issues in target platforms and rename 4.16-staging to 4.16
since that version was released already.

Change-Id: Ifea2600e445e783807a5d94ea23ac3c6550956b5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoPrepare 5.10.0-SNAPSHOT builds 38/168338/1
Matthias Sohn [Thu, 27 Aug 2020 14:14:36 +0000 (16:14 +0200)]
Prepare 5.10.0-SNAPSHOT builds

Change-Id: I9a2b39e9e85f27179ceb3b1709d75c466089a3bc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoMerge branch 'stable-5.9' into master 37/168337/1
Matthias Sohn [Thu, 27 Aug 2020 12:47:52 +0000 (14:47 +0200)]
Merge branch 'stable-5.9' into master

* stable-5.9:
  Prepare 5.9.0-SNAPSHOT builds
  JGit v5.9.0.202008260805-m3

Change-Id: I2fdd289a14cebea02125711bd47a2cb9ad292b0d

4 years agoPrepare 5.9.0-SNAPSHOT builds 04/168304/1
Matthias Sohn [Thu, 27 Aug 2020 08:22:51 +0000 (10:22 +0200)]
Prepare 5.9.0-SNAPSHOT builds

Change-Id: Ia3e8382ec503150979d8acb6161031ccfb7fd921
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoResolveMerger: do not content-merge gitlinks on del/mod conflicts 91/164491/13
Demetr Starshov [Wed, 12 Aug 2020 22:01:10 +0000 (15:01 -0700)]
ResolveMerger: do not content-merge gitlinks on del/mod conflicts

Previously ResolveMerger tried to make a fulltext merge entry in case
one of sides got deleted regardless of file mode. This is not
applicable for GITLINK type of entry. After this change it is
rendering appropriate merge result.

Signed-off-by: Demetr Starshov <dstarshov@google.com>
Change-Id: Ibdb4557bf8781bdb48bcee6529e37dc80582ed7e

4 years agoResolveMerger: Adding test cases for GITLINK deletion 91/168291/1
Demetr Starshov [Thu, 27 Aug 2020 01:32:39 +0000 (18:32 -0700)]
ResolveMerger: Adding test cases for GITLINK deletion

Add test cases which cover content-merge resolve logic for deletion.

Sign-off-by: Demetr Starshov <dstarshov@google.com>
Change-Id: I2f2b37e29adc973a5a0cfcc5c8bc32a2c38efdfa

4 years agoResolveMerger: choose OURS on gitlink when ignoreConflicts 20/162920/20
Demetr Starshov [Wed, 12 Aug 2020 21:47:15 +0000 (14:47 -0700)]
ResolveMerger: choose OURS on gitlink when ignoreConflicts

Option ignoreConflicts is used when a caller want to create a virtual
commit and use it in a future merge (recursive merge) or show it on
UI (e.g. Gerrit). According to contract in case of ignoreConflicts
ResolveMerger should populate only stage 0 for entries with merge
conflicts as if there is no conflict. Current implementation breaks
this contract for cases when gitlink revision is ambiguous.

Therefore, always select 'ours' when we merge in ignoreConflicts mode.
This will satisfy the contract contract, so recursive merge can
succeed, however it is an arbitrary decision, so it is not guaranteed
to select best GITLINK in all cases.

GITLINK merging is a special case of recursive merge because of
limitations of GITLINK type of entry. It can't contain more than 1 sha-1
so jgit can't write merge conflicts in place like it can with a blob.
Ideally we could signal the conflict with a special value (like
'0000...'), but that must be supported by all tooling (git fsck, c-git)."

Signed-off-by: Demetr Starshov <dstarshov@google.com>
Change-Id: Id4e9bebc8e828f7a1ef9f83259159137df477d89

4 years agoResolveMerger: improving content merge readability 65/167565/5
Demetr Starshov [Wed, 12 Aug 2020 01:30:49 +0000 (18:30 -0700)]
ResolveMerger: improving content merge readability

Separate "GITLINK conflict" and "attributes can't be content merged"
cases.

Signed-off-by: Demetr Starshov <dstarshov@google.com>
Change-Id: I29424e13ea1738af750196e7bf4315256a6095b6

4 years agoResolveMerger: extracting createGitLinksMergeResult method 64/167564/5
Demetr Starshov [Wed, 12 Aug 2020 01:24:33 +0000 (18:24 -0700)]
ResolveMerger: extracting createGitLinksMergeResult method

Signed-off-by: Demetr Starshov <dstarshov@google.com>
Change-Id: Ibc8b954266b1b4b9b9f404e3433f0d7cdae107e8

4 years agoResolveMerger: Adding test cases for GITLINK merge 63/167563/5
Demetr Starshov [Wed, 12 Aug 2020 00:57:10 +0000 (17:57 -0700)]
ResolveMerger: Adding test cases for GITLINK merge

Add test cases which cover content-merge resolve logic.

Git clients try to agressively merge blobs by content, but GITLINK types
of entries can't be merged with each other or with blobs. This change
ensures all possible permutations which can trigger blob and GITLINK
content merge are covered.

Signed-off-by: Demetr Starshov <dstarshov@google.com>
Change-Id: I7e83a28a14d4d2f9e0ba2b1cffbf3224fb7f3fef

4 years agoJGit v5.9.0.202008260805-m3 47/168247/1 v5.9.0.202008260805-m3
Matthias Sohn [Wed, 26 Aug 2020 12:05:07 +0000 (14:05 +0200)]
JGit v5.9.0.202008260805-m3

Change-Id: Ic4de8340f3ab038e38b239b725b8bd6d6dbee413
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
4 years agoFix possible NegativeArraySizeException in PackIndexV1 89/167589/3
Marc Strapetz [Wed, 12 Aug 2020 12:50:20 +0000 (14:50 +0200)]
Fix possible NegativeArraySizeException in PackIndexV1

Due to an integer overflow bug, the current "Index file is too large
for jgit" check did not work properly and subsequently a
NegativeArraySizeException was raised.

Change-Id: I2736efb28987c29e56bc946563b7fa781898a94a
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
4 years agoFS: use binary search to determine filesystem timestamp resolution 06/167706/3
Thomas Wolf [Fri, 14 Aug 2020 12:54:38 +0000 (14:54 +0200)]
FS: use binary search to determine filesystem timestamp resolution

Previous code used a minimum granularity of 1 microsecond and would
iterate 233 times on a system where the resolution is 1 second (for
instance, Java 8 on Mac APFS).

New code uses a binary search between the maximum we care about (2
seconds) and zero, with a minimum granularity of also 1 microsecond.
This takes at most 19 iterations (guaranteed). For a file system with 1
second resolution, it takes 4 iterations (1s, 0.5s, 0.8s, 0.9s). With
an up-front check at 1 microsecond and at 1 millisecond this performs
equally well as the old code on file systems with a fine resolution.
(For instance, Java 11 on Mac APFS.)

Also handle obscure cases where the file timestamp implementation may
yield bogus values (as observed on HP NonStop). If such an error case
occurs, log a warning and abort the measurement at the last good value.

Bug: 565707
Change-Id: I82a96729b50c284be7c23fbdf3d0df1bddf60e41
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoDo not prematurely create directory of jgit's XDG config file 96/168096/2
Matthias Sohn [Sat, 22 Aug 2020 19:19:57 +0000 (21:19 +0200)]
Do not prematurely create directory of jgit's XDG config file

LockFile.lock() will create it anyway when the config file is created.

Bug: 565637
Change-Id: I078b89a695193fd76f130f6de7ac1cf26d2f8f0f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoFS: write to JGit config in a background thread 42/168042/1
Thomas Wolf [Thu, 20 Aug 2020 20:43:13 +0000 (22:43 +0200)]
FS: write to JGit config in a background thread

Otherwise locking problems may ensue if the JGit config itself is
on a different file system. Since the internal is already updated,
it is not really important when exactly the value gets persisted.
By queueing up separate Runnables executed by a single thread we
avoid concurrent write access to the JGit config, and nested calls
to getFileStoreAttributes(Path) result in serialized attempts to
write.

The thread for writing the config must not be a daemon thread. If
it were, JVM shutdown might kill it anytime, which may lead to
the config not being written, or worse, a config.lock file being
left behind.

Bug: 566170
Change-Id: I07e3d4c5e029d3cec9ab5895002fc4e0c7948c40
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoFS: don't cache fallback if running in background 41/168041/1
Thomas Wolf [Thu, 20 Aug 2020 20:15:11 +0000 (22:15 +0200)]
FS: don't cache fallback if running in background

If the background job is a little late, the true result might
arrive and be cached later. So make sure we don't cache the large
fallback resolution in the per-directory cache. Otherwise we'd work
with the large fallback until the next restart.

Bug: 566170
Change-Id: I7354a6cfddfc0c05144bb0aa41c23029bd4f6af0
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoKeep line endings for text files committed with CR/LF on text=auto 55/166755/10
Thomas Wolf [Tue, 21 Jul 2020 22:51:24 +0000 (00:51 +0200)]
Keep line endings for text files committed with CR/LF on text=auto

Git never converts line endings if the version in the repository is a
text file with CR/LF and text=auto. See [1]: "When the file has been
committed with CRLF, no conversion is done."

Because the sentence just before is about converting line endings on
check-in, I had understood that in commit 60cf85a [2] to mean that no
conversion on check-in was to be done. However, as bug 565048 and a
code inspection of the C git code showed it really means no conversion
is done on check-in *or check-out*.

If the text attribute is not set but core.autocrlf = true, this is
the same as text=auto eol=crlf. C git does not convert on check-out
even on text=auto eol=lf if the index version is a text file with
CR/LF.

For check-in, one has to look at the intended target, which is done
in WorkingTreeIterator since commit 60cf85a. For check-out, it can
be done by looking at the source and can thus be done in the
AutoLFOutputStream.

Additionally, provide a constructor for AutoLFInputStream to do
the same; for cases where the equivalent of a check-out is done via
an input stream obtained from a blob. (EGit does that in its
GitBlobStorage for the Eclipse compare framework; it's more efficient
than using a TemporaryBuffer and DirCacheCheckout.getContent(), and
it avoids the need for a temporary file.)

Adapt existing tests, and add new checkout and merge tests to verify
the resulting files have the correct line endings.

EGit's GitBlobStorage will need to call the new version of
EolStreamTypeUtil.wrapInputStream().

[1] https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-Settostringvalueauto
[2] https://git.eclipse.org/r/c/jgit/jgit/+/127324

Bug: 565048
Change-Id: If1282ef43e2abd00263541bd10a01fe1f5c619fc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoDelay WindowCache statistics JMX MBean registration 63/167263/2
Thomas Wolf [Tue, 4 Aug 2020 22:58:00 +0000 (00:58 +0200)]
Delay WindowCache statistics JMX MBean registration

The WindowCache is configured statically with a default
WindowCacheConfig. The default config says (for backwards
compatibility reasons) to publish the MBean. As a result,
the MBean always gets published.

By delaying the MBean registration until the first call to
getInstance() or get(PackFile, long) we can avoid the forced
registration and do it only if not re-configured in the meantime
not to publish the bean. (As is done by Egit, to avoid a very
early costly access to the user and system config during plug-in
activation.)

Bug: 563740
Change-Id: I8a941342c0833acee2107515e64299aada7e0520
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years ago[releng] Update plexus-compiler to 2.8.7 29/167729/2
Thomas Wolf [Sat, 15 Aug 2020 09:12:31 +0000 (11:12 +0200)]
[releng] Update plexus-compiler to 2.8.7

Change-Id: Idc00c877544af7434c3a71c9ab0b2bd6a2b8fb66
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoDirCache: support index V4 03/167503/4
Thomas Wolf [Mon, 10 Aug 2020 19:38:50 +0000 (21:38 +0200)]
DirCache: support index V4

Index format version 4 was introduced in C git in 2012. It's about
time that JGit can deal with it.

Version 4 added prefix path compression. Instead of writing the full
path for each index entry to disk, only the difference to the previous
entry's path is written: a variable-encoded int telling how many bytes
to remove from the previous entry's path to get the common prefix,
followed by the new suffix.

Also, cache entries in a version 4 index are not padded anymore.

Internally, version 3 and version 4 index entries are identical; it's
only the stored format that changes.

Implement this path compression, and make sure we write an index file
that we read previously in the same format. (Only changing from version
2 to version 3 if there are extended flags.)

Add support for the "feature.manyFiles" and the "index.version" git
configs, and honor them when writing a new index file.

Add tests, including a compatibility test that verifies that JGit can
read a version 4 index generated by C git and write an identical
version 4 index.

Bug: 565774
Change-Id: Id83241cf009e50f950eb42f8d56b834fb47da1ed
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoUpdate javadoc for RemoteSession and SshSessionFactory 18/167418/4
Thomas Wolf [Sat, 8 Aug 2020 09:53:43 +0000 (11:53 +0200)]
Update javadoc for RemoteSession and SshSessionFactory

The timeout on RemoteSession.exec() cannot be a timeout for the
whole command. It can only be a timeout for setting up the process;
after that it's the application's responsibility to implement some
timeout for the execution of the command, for instance by calling
Process.waitFor(int, TimeUnit) or through other means.

Sessions returned by an SshSessionFactory are already connected and
authenticated -- they must be, because RemoteSession offers no
operations for connecting or authenticating a session.

Change the implementation of SshdExecProcess.waitFor() to wait
indefinitely. The original implementation used the timeout from
RemoteSession.exec() because of that erroneous javadoc.

Change-Id: I3c7ede24ab66d4c81f72d178ce5012d383cd826e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoFix JSchProcess.waitFor() with time-out 70/167370/13
Thomas Wolf [Thu, 6 Aug 2020 21:43:40 +0000 (23:43 +0200)]
Fix JSchProcess.waitFor() with time-out

SshSupport.runSshCommand() had a comment that wait with time-out
could not be used because JSchProcess.exitValue() threw the wrong
unchecked exception when the process was still running.

Fix this and make JSchProcess.exitValue() throw the right exception,
then wait with a time-out in SshSupport.

The Apache sshd client's SshdExecProcess has always used the correct
IllegalThreadStateException.

Add tests for SshSupport.runCommand().

Change-Id: Id30893174ae8be3b9a16119674049337b0cf4381
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agosshd: work around a race condition in Apache MINA sshd 2.4.0/2.5.x 83/167183/6
Thomas Wolf [Mon, 3 Aug 2020 14:22:37 +0000 (16:22 +0200)]
sshd: work around a race condition in Apache MINA sshd 2.4.0/2.5.x

When exceptions occur very early in the SSH connection setup, it's
possible that an exception gets lost. A subsequent authentication
attempt may then never be notified of the failure, and then wait
indefinitely or until its timeout expires.

This is caused by race conditions in sshd. The issue has been reported
upstream as SSHD-1050,[1] but will be fixed at the earliest in sshd
2.6.0.

[1] https://issues.apache.org/jira/projects/SSHD/issues/SSHD-1050

Bug: 565394
Change-Id: If9b62839db38f9e59a5e1137c2257039ba82de98
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agosshd: store per-session data on the sshd session object 67/166867/3
Thomas Wolf [Sat, 25 Jul 2020 08:20:29 +0000 (10:20 +0200)]
sshd: store per-session data on the sshd session object

Don't store session properties on the client but in a dedicated
per-session object that is attached to the sshd session.

Also make sure that each sshd session gets its own instance of
IdentityPasswordProvider that asks for passphrases of encrypted
private keys, and also store it on the session itself.

Bug: 563380
Change-Id: Ia88bf9f91cd22b5fd32b5972d8204d60f2de56bf
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
4 years agoMerge changes from topic "sshd"
Thomas Wolf [Wed, 5 Aug 2020 06:50:31 +0000 (02:50 -0400)]
Merge changes from topic "sshd"

* changes:
  sshd: use PropertyResolver in test
  Remove dependency on JSch from SSH test framework

4 years agoFilterSpec: Use BigInteger.ZERO instead of valueOf(0) 40/167140/1
Jonathan Nieder [Sat, 1 Aug 2020 02:01:35 +0000 (19:01 -0700)]
FilterSpec: Use BigInteger.ZERO instead of valueOf(0)

This just simplifies a bit by avoiding an unneeded method call.

Change-Id: I6d8d2fc512d8f8a82da73c355017d0abf833a13b