Commit Graph

8618 Commits

Author SHA1 Message Date
Matthias Sohn 4453a6e042 Prepare 6.1.0-SNAPSHOT builds
Change-Id: Ied07b1298bd32672a5025cec5079440ab9b9a100
2021-11-24 19:42:27 +01:00
Matthias Sohn 06eb6d0b73 Merge branch 'stable-6.0'
* stable-6.0:
  Prepare 6.0.0-SNAPSHOT builds
  JGit v6.0.0.202111241155-rc1

Change-Id: Icb4caf0809ac0c629cb4a05be293c61c669411db
2021-11-24 19:41:40 +01:00
Matthias Sohn e3707a6cea Prepare 6.0.0-SNAPSHOT builds
Change-Id: I4e06186cf62681767962e391331cc65bafddc205
2021-11-24 18:18:12 +01:00
Matthias Sohn ad8d89b9c0 JGit v6.0.0.202111241155-rc1
Change-Id: I35dc089a00ee12f83f506fb320d23762fa030063
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-11-24 17:54:51 +01:00
Matthias Sohn 751e3ad5d1 Merge branch 'master' into stable-6.0
* master:
  Add 4.22 target platform for 2021-12
  Update Orbit to R20211122181901 for 2021-12
  AppServer: fix keystore used to setup test SSL context factory
  [6.0 API cleanup] Public interface for PackLock
  [6.0 API cleanup] StoredObjectRepresentationNotAvailableException
  RepoCommand: Do not wrap GitApiExceptions in GitApiExceptions
  Set JSch global config values only if not set already
  Better git system config finding
  [6.0 API cleanup] CancelledException vs. CanceledException
  Javadoc fixes
  Better git system config finding
  HttpClientConnectionTest: organize imports
  Update Jetty to 10.0.6
  Fix missing @since 6.0 tag
  Support commit.template config property
  DFS block cache: harden against race over ref locks.

Change-Id: Id9814d92eb40b2ba63c5e753a86a4809826e7c81
2021-11-24 17:49:02 +01:00
Matthias Sohn fc60efff0d Add 4.22 target platform for 2021-12
Change-Id: Ie003dee8390cb609bd3352c23e88aeb0bf1bc68b
2021-11-24 10:52:26 +01:00
Matthias Sohn 009c043b02 Update Orbit to R20211122181901 for 2021-12
Change-Id: Ieddfe7938d0743ffbe74fa7bb366030e93fa010c
2021-11-24 10:36:56 +01:00
Matthias Sohn 791d3b0eb4 AppServer: fix keystore used to setup test SSL context factory
- configure dName
- add SANs ip:127.0.0.1, ip:[::1]

See jetty's own test setup in
1cd15e8d85/jetty-client/src/test/resources/readme_keystores.txt (L6)

and the fixes done in
1cd15e8d85

Change-Id: Ie3260db7a7090dfa92b43eb32bf247640ebf8482
2021-11-24 09:17:07 +01:00
Ivan Frade 32b1a1b3a3 Merge "RepoCommand: Do not wrap GitApiExceptions in GitApiExceptions" 2021-11-23 18:05:37 -05:00
Thomas Wolf 5154585439 [6.0 API cleanup] Public interface for PackLock
Provide a public interface PackLock exposing only the unlock() method.
Rename the internal PackLock class to PackLockImpl and have it implement
the new interface.

This way PackParser doesn't expose an internal class via its API
anymore, and client can still unlock pack locks that were created.

Bug: 576340
Change-Id: I976739f4ab28fe1f9ba7f35653a69a913aa68841
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-23 23:37:19 +01:00
Thomas Wolf 1e37438cb7 [6.0 API cleanup] StoredObjectRepresentationNotAvailableException
Remove the unused parameter, which had a non-API type anyway.

Bug: 576340
Change-Id: Id71c01a643e1f31a8ff61ff69f7915c373db3263
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-23 23:37:19 +01:00
Matthias Sohn 912a34fb7b Merge branch 'stable-5.13'
* stable-5.13:
  Set JSch global config values only if not set already
  Better git system config finding

Change-Id: I79848eeb3cda795ecb80ad845aa1027e2e231d18
2021-11-23 23:25:07 +01:00
Ivan Frade cde3ed9ecf RepoCommand: Do not wrap GitApiExceptions in GitApiExceptions
While building the commit for the destination project, RepoCommand
catches GitApiExceptions and wraps them into ManifestErrorException
(a subclass of GitApiException). This hides the real exception from the
caller and prevent them to do a fine-grained catch.

Specifically this is problematic for gerrit's supermanifest plugin, that
won't see ConcurrentRefUpdate exceptions to detect lock-failures.

Use ManifestErrorException to wrap non-GitApiExceptions, let
GitApiExceptions pass through as they are.

Change-Id: Ia2cda244e65993bb07c89cd6435507d5d0754dd4
2021-11-23 11:30:25 -08:00
Thomas Wolf 9e4fe739c7 Merge branch 'stable-5.12' into stable-5.13
* stable-5.12:
  Better git system config finding

Change-Id: Iebbae08b6bb6ef510ca07329df77223bc2128ec1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-23 19:52:01 +01:00
Thomas Wolf 6fe66b7382 Set JSch global config values only if not set already
Bug: 576604
Change-Id: I04415f07bf2023bc8435c097d1d3c65221d563f1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
(cherry picked from commit f8b0c00e6a)
2021-11-23 19:52:01 +01:00
Thomas Wolf 6e0ac5840c Merge branch 'stable-5.11' into stable-5.12
* stable-5.11:
  Better git system config finding

Change-Id: I47946b91658cb2e38709179b7a8513b1211431e4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-23 19:46:39 +01:00
Thomas Wolf ecbe49efbd Merge branch 'stable-5.10' into stable-5.11
* stable-5.10:
  Better git system config finding

Change-Id: I460d855ea7878b279dbaffa6eb7ce5ca93f4c12c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-23 19:45:50 +01:00
Thomas Wolf e29325f064 Merge branch 'stable-5.9' into stable-5.10
* stable-5.9:
  Better git system config finding

Change-Id: I1022d003e0d3b9d452abfed9ac49663d0a93c6e6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-23 19:44:30 +01:00
Thomas Wolf 6aa29d1166 Better git system config finding
We've used "GIT_EDITOR=edit git config --system --edit" to determine
the location of the git system config for a long time. But git 2.34.0
always expects this command to have a tty, but there isn't one when
called from Java. If there isn't one, the Java process may get a
SIGTTOU from the child process and hangs.

Arguably it's a bug in C git 2.34.0 to unconditionally assume there
was a tty. But JGit needs a fix *now*, otherwise any application using
JGit will lock up if git 2.34.0 is installed on the machine.

Therefore, use a different approach if the C git found is 2.8.0 or
newer: parse the output of

  git config --system --show-origin --list -z

"--show-origin" exists since git 2.8.0; it prefixes the values with
the file name of the config file they come from, which is the system
config file for this command. (This works even if the first item in
the system config is an include.)

Bug: 577358
Change-Id: I3ef170ed3f488f63c3501468303119319b03575d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
(cherry picked from commit 9446e62733)
2021-11-23 19:42:34 +01:00
Thomas Wolf ce6826f506 [6.0 API cleanup] CancelledException vs. CanceledException
Use the GitAPIException CanceledException instead of IOException
CancelledException in the rename detector.

Change-Id: I5121719eb714a123ec57769fc113c84857bd3c6c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-22 17:57:26 -05:00
Thomas Wolf a4542d06bb Javadoc fixes
Skip javadoc generation for test bundles.

Use character entities &lt; and &gt; for < and > outside of
code-formatted spans.

Change-Id: I66e1a1dc98881c61f93c9e5561c5513896b2ba01
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-22 17:45:46 -05:00
Thomas Wolf 9446e62733 Better git system config finding
We've used "GIT_EDITOR=edit git config --system --edit" to determine
the location of the git system config for a long time. But git 2.34.0
always expects this command to have a tty, but there isn't one when
called from Java. If there isn't one, the Java process may get a
SIGTTOU from the child process and hangs.

Arguably it's a bug in C git 2.34.0 to unconditionally assume there
was a tty. But JGit needs a fix *now*, otherwise any application using
JGit will lock up if git 2.34.0 is installed on the machine.

Therefore, use a different approach if the C git found is 2.8.0 or
newer: parse the output of

  git config --system --show-origin --list -z

"--show-origin" exists since git 2.8.0; it prefixes the values with
the file name of the config file they come from, which is the system
config file for this command. (This works even if the first item in
the system config is an include.)

Bug: 577358
Change-Id: I3ef170ed3f488f63c3501468303119319b03575d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-22 21:17:14 +01:00
Matthias Sohn 2a8b9871b9 Merge changes I7e1f8627,Ibd0240cf
* changes:
  HttpClientConnectionTest: organize imports
  Update Jetty to 10.0.6
2021-11-22 15:15:13 -05:00
Matthias Sohn 84a6ac3b64 HttpClientConnectionTest: organize imports
Change-Id: I7e1f8627a9360c660adc6f00fe48afe005929150
2021-11-22 20:50:32 +01:00
Matthias Sohn f91e47f5b6 Update Jetty to 10.0.6
- this is the same version eclipse platform currently uses
- update servlet-api to 4.0
- configure keystore used by AppServer with Subject Alternative Names
  for host name and ip address to satisfy more strict SNI checking in
  Jetty 10. See https://github.com/eclipse/jetty.project/issues/5379
- add jetty bundles to JGit-dependency-bundles in the jgit p2 repository

Bug: 571932
Bug: 576100
Change-Id: Ibd0240cf7ad4dc201947fd69707f517c3c1fc1c8
2021-11-22 20:50:28 +01:00
Thomas Wolf dedb586042 Fix missing @since 6.0 tag
CommitConfig.getCommitTemplateContent() has changed API.

Change-Id: If72ed79c43c167b99f356b69cc095d6bbf4d66e8
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-22 09:00:55 +01:00
Julian Ruppel 00f6fe72a7 Support commit.template config property
Fixes an issue that commit template file could not be found if it has a
relative path instead of absolute path.

Relative path is probably common if git config --local is used.

Bug: 446355

Change-Id: I8ddf2be672647be825fd9c01af82809d31bb8356
2021-11-22 02:22:03 -05:00
Matthias Sohn 2e2a3642c3 Merge branch 'stable-6.0'
* stable-6.0:
  Prepare 6.0.0-SNAPSHOT builds
  JGit v6.0.0.202111161950-m3

Change-Id: I55413bc9e93503130b7900840f75bd9243e156c9
2021-11-17 22:40:48 +01:00
Matthias Sohn 6807661d39 Prepare 6.0.0-SNAPSHOT builds
Change-Id: Ibfc7fb21b039fe2a7669c8dee3c10f5ade33d520
2021-11-17 21:41:28 +01:00
Ivan Frade efbd0caa22 Merge "DFS block cache: harden against race over ref locks." 2021-11-17 11:58:24 -05:00
Matthias Sohn 400b5acae8 JGit v6.0.0.202111161950-m3
Change-Id: If6c36994be05848c567d3d664eb683d9bed26c48
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-11-17 01:50:01 +01:00
Matthias Sohn f684dc6f8b Merge branch 'master' into stable-6.0
* master:
  Make BinaryBlobException stackless
  Typo fix in o.e.j.ssh.{jsch,apache}/README.md
  ssh: Handle "ProxyJump none" from SSH config file
  ssh: use a single SecureRandom instance for hashing hostnames
  OpenSshConfigFile: line comments and quoted strings
  OpenSshConfigFile: update token replacements
  Add missing .gitignore in o.e.j.ssh.apache.agent
  Upgrade plexus-compiler version to 2.9.0
  [sshd agent] Introduce ConnectorDescriptor
  Update version of last release defining the API baseline to 5.13.0
  Update Orbit to S20211108222137
  Update README
  Update jetty to 9.4.44.v20210927
  Simplify SshdFtpChannel
  [test] test OpenSshConfigFile directly, not via the JSch config
  sshd: add support for ssh-agent
  sshd: prepare for using an SSH agent
  [releng] bazel: Enable errorprone on o.e.j.ssh.apache
  [releng] Make the bazel build use Java 11
  Fix target platforms
  [doc] Add README and package-info to the SSH bundles
  Binary and CR-LF detection: lone CRs -> binary
  Factor out parsing git-style size numbers to StringUtils
  Make the buffer size for text/binary detection configurable

Change-Id: I5c78eeca3abfc3e0a659ed8a258c4e96e9469713
2021-11-17 01:44:52 +01:00
Alina Djamankulova 49d243b13c DFS block cache: harden against race over ref locks.
With change https://git.eclipse.org/r/c/jgit/jgit/+/186455 a thread
loading a bitmap index could hold two ref locks at the same time (one
for bitmap and one for either index or reverse index). So it is possible
that two threads loading bitmaps end up in a deadlock for ref locks e.g.
threadA has refLock[1] (for bitmap) and wants refLock[2] (for index or
revIndex) and threadB has refLock[2] (for bitmap) and wants refLock[1].

This change introduces separate pools of locks per pack extension
instead of a shared pool. So threads loading bitmap can hold two
locks but with different extensions and no overlap, e.g. threadA holds
refLock[BITMAP_INDEX][1] and refLock[INDEX][2] and threadB holds
refLock[BITMAP_INDEX][2] and refLock[INDEX][1].

More unit tests were added to cover various paralell loading scenarios.

Signed-off-by: Alina Djamankulova <adjama@google.com>
Change-Id: I89704b4721c21548929608d3798ef60925280755
2021-11-16 16:05:13 -08:00
Matthias Sohn ee28780bf2 Make BinaryBlobException stackless
We use BinaryBlobException to signal a binary blob was found and never
make use of its stack trace. Suppress filling in the stack trace to
avoid the performance penalty coming with that.

See https://shipilev.net/blog/2014/exceptional-performance/

Change-Id: Iae1f1c19a1fa8aef4f6569822557171130299958
2021-11-16 11:45:57 +01:00
Thomas Wolf 78b7d9e4fa Typo fix in o.e.j.ssh.{jsch,apache}/README.md
Change-Id: Ia7da92421f8fecb2a175eb23ecfd04a67e0ca8cc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-15 22:26:21 +01:00
Thomas Wolf 057f1d9123 ssh: Handle "ProxyJump none" from SSH config file
Since OpenSSH 7.8, the ProxyJump directive accepts the value "none"[1]
to override and clear a setting that might otherwise be contributed by
another (wildcard) host entry.

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=2869

Change-Id: Ia35e82c6f8c58d5c6b8040cda7a07b220f43fc21
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-15 22:26:20 +01:00
Thomas Wolf 180bc67e28 ssh: use a single SecureRandom instance for hashing hostnames
According to Spotbugs, that's better practice. It's questionable
whether it makes a big difference, though, especially since the
hash is the cryptographically weak SHA1.

Change-Id: Id293de2bad809d9cc19230bd720184786dc6c226
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-15 22:26:20 +01:00
Thomas Wolf af0126e1d0 OpenSshConfigFile: line comments and quoted strings
Bring our SSH config parser up-to-date with respect to changes in
OpenSSH. In particular, they fixed[1] the handling of line comments
such that #-characters inside strings are not considered. This means
that we have to parse strings with escaped quotes correctly.

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=3288

Change-Id: Ifbd9014127e8d51e7c8792e237f3fc2a9a0719d2
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-15 22:26:19 +01:00
Thomas Wolf c4b3ec72fa OpenSshConfigFile: update token replacements
It appears that the OpenSSH documentation[1] has changed; it now allows
more flags for a number of keys.

[1] https://man.openbsd.org/ssh_config.5#TOKENS

Change-Id: I55df174f86a3fd4a6ef22687dc433ac9f9ad181d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-15 22:26:19 +01:00
Matthias Sohn 2adbf91d8f Merge "Upgrade plexus-compiler version to 2.9.0" 2021-11-15 10:57:32 -05:00
Thomas Wolf ffb5cac361 Add missing .gitignore in o.e.j.ssh.apache.agent
Ignore /bin and /target.

Change-Id: I38f3748273b5243c54e010bfceac745084755f45
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-15 10:37:36 +01:00
Marco Miller d4296d96bb Upgrade plexus-compiler version to 2.9.0
Change-Id: I24ac698d3ccc01e79464b061068944ca82e8383b
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
2021-11-12 23:33:42 +01:00
Thomas Wolf e7838b9c08 [sshd agent] Introduce ConnectorDescriptor
Once a factory supports different SSH agents on the same platform,
which is planned for Windows once we use Apache MINA sshd 2.8.0,
client code may need to have a way to specify which SSH agent shall
be used when the SSH config doesn't define anything.

Add a mechanism by which a ConnectorFactory can tell what Connectors
it may provide. Client code can use this to set the identityAgent
parameter of ConnectorFactory.create() to the wanted default if it
would be null otherwise.

A ConnectorDescriptor is a pair of strings: an internal name, and a
display name. The latter is included because client code might want to
communicate agent names to the user, be it in error messages or in some
chooser dialog where a user could define which of several alternative
SSH agents should be used as default. The internal name is intended to
be used in the IdentityAgent directive in ~/.ssh/config.

Also make the ConnectorFactory discovered via the ServiceLoader
accessible and overrideable. Provide static get/setDefault() methods,
similar to the SshSessionFactory itself.

Change-Id: Ie3d077395d32dfddc72bc8627e92b23636938182
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-10 13:57:01 -05:00
Matthias Sohn b84738c369 Update version of last release defining the API baseline to 5.13.0
Change-Id: I48e0d677a466a364fdd699cdb00014a9a65d082a
2021-11-10 15:56:36 +01:00
Matthias Sohn a74dfb0901 Update Orbit to S20211108222137
and update dependencies:
- com.google.gson to 2.8.8.v20211029-0838
- com.googlecode.javaewah to 1.1.13.v20211029-0839
- net.i2p.crypto.eddsa to 0.3.0.v20210923-1401
- org.apache.ant to 1.10.12.v20211102-1452
- org.apache.commons.compress to 1.21.0.v20211103-2100
- org.bouncycastle.bcprov to 1.69.0.v20210923-1401
- org.junit to 4.13.2.v20211018-1956

Change-Id: I90ca64f6d9f2a15c9a5d9a27d48956182f1698b4
2021-11-10 14:51:29 +01:00
Thomas Wolf 5cbf70fd97 Update README
* Java 11 now
* Mention new bundle org.eclipse.jgit.ssh.apache.agent
* Be honest about missing features: there are quite a few

Change-Id: Ie08a2b4581024febe1983a59414cf69845ebff96
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-07 23:21:39 +01:00
Matthias Sohn a92ff5369b Update jetty to 9.4.44.v20210927
Change-Id: Iaa1478af0fe0ccfa1daf1cf44e4eef609e7ad8bb
2021-11-05 15:50:45 +01:00
Thomas Wolf 3a7db8b782 Simplify SshdFtpChannel
Apache MINA sshd has simpler API for reading directories, and it has a
functional interface suitable for us. So no need to use our own
interface, or to deal with low-level abstractions like CloseableHandle.

Change-Id: Ic125c587535670504983f157a696b41ed6a76bb7
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-04 20:20:37 +01:00
Thomas Wolf c6d48ab2f8 [test] test OpenSshConfigFile directly, not via the JSch config
This is a prerequisite for removing the JSch support bundle; otherwise
OpenSshConfigFile would be left without tests.

Copy OpenSshConfigTest from the JSch support bundle and adapt all tests
to perform the equivalent checks on OpenSshConfigFile directly. Add a
new lookupDefault() method to the SshConfigStore interface and implement
it so that it behaves the same and the tests work identically.

Change-Id: I046abd9197a8484003e77005024e5d973456f1a3
2021-11-04 10:54:36 -04:00
Thomas Wolf 634302d2da sshd: add support for ssh-agent
Add a simple SSH agent connector using JNA. Include com.sum.jna and
com.sun.jna.platform in the target platform.

JNA is used to communicate through Unix domain sockets with ssh-agent,
and if on Windows, to communicate via shared memory with Pageant.

The new bundle o.e.j.ssh.apache.agent is an OSGi fragment so that
the java.util.ServiceLoader can find the provided factory without
further ado in OSGi environments.

Adapt both maven and bazel builds to include the new bundle.

Manually tested on OS X, CentOS 7, and Win10 with Pageant 0.76. Tested
by installing JGit built from this change into freshly downloaded
Eclipse 2021-12 M1, and then doing git fetches via SSH with different
~/.ssh/config settings (explicit IdentityFile, without any but a key in
the agent, with no keys and a key in the agent and IdentitiesOnly=yes
(must fail)).

Bug: 541274
Bug: 541275
Change-Id: I34e85467293707dbad1eb44d1f40fc2e70ba3622
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-11-03 23:46:54 +01:00