Commit Graph

8308 Commits

Author SHA1 Message Date
Matthias Sohn cc07a471dc Add TemporaryBuffer.toString(int limit)
Change-Id: I8603fcdfd0244088b3b217f002a78e7a646ea205
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-09 22:49:15 +02:00
Thomas Wolf a9579ba60c LockFile: create OutputStream only when needed
Don't create the stream eagerly in lock(); that may cause JGit to
exceed OS or JVM limits on open file descriptors if many locks need
to be created, for instance when creating many refs. Instead create
the output stream only when one really needs to write something.

Bug: 573328
Change-Id: If9441ed40494d46f594a896d34a5c4f56f91ebf4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-07 12:10:47 +02:00
Matthias Sohn 730b5d5009 Merge branch 'stable-5.12'
* stable-5.12:
  Prepare 5.12.0-SNAPSHOT builds
  JGit v5.12.0.202105051250-m2

Change-Id: I88e0e3d341f375d6c85d532e4f010ac20f81c3d1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-06 09:56:10 +02:00
Matthias Sohn 520b6d7dcf Prepare 5.12.0-SNAPSHOT builds
Change-Id: I2fc5305e7eaaa4593d418fc3b31d20e4b6e1e585
2021-05-06 09:53:25 +02:00
Matthias Sohn 92679d792f JGit v5.12.0.202105051250-m2
Change-Id: Ic7d86c91ec0ff9aa0678dcb971c197e62a4ca2dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-05 17:50:19 +02:00
Matthias Sohn f4069bb4ec Merge "[releng] Update eclipse-jarsigner-plugin to 1.3.1" 2021-04-26 17:07:56 -04:00
Matthias Sohn 87d2c82473 Update jetty to 9.4.40.v20210413
Change-Id: I5585b9a22bf20a49ad4bb9a24e053325792ec546
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-04-23 23:48:34 +02:00
Thomas Wolf 46b0f8a043 [releng] Update eclipse-jarsigner-plugin to 1.3.1
Up from 1.1.7. See [1] for the reason.

[1] https://www.eclipse.org/lists/cbi-dev/msg02374.html

Change-Id: Ia7c1c9f443793ce476acd6ddfe521ea488a1a60b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-04-19 22:48:06 +02:00
Thomas Wolf 8210f29fe4 Implement ours/theirs content conflict resolution
Git has different conflict resolution strategies:

* There is a tree merge strategy "ours" which just ignores any changes
  from theirs ("-s ours"). JGit also has the mirror strategy "theirs"
  ignoring any changes from "ours". (This doesn't exist in C git.)
  Adapt StashApplyCommand and CherrypickCommand to be able to use those
  tree merge strategies.
* For the resolve/recursive tree merge strategies, there are content
  conflict resolution strategies "ours" and "theirs", which resolve
  any conflict hunks by taking the "ours" or "theirs" hunk. In C git
  those correspond to "-Xours" or -Xtheirs". Implement that in
  MergeAlgorithm, and add API to set and pass through such a strategy
  for resolving content conflicts.
* The "ours/theirs" content conflict resolution strategies also apply
  for binary files. Handle these cases in ResolveMerger.

Note that the content conflict resolution strategies ("-X ours/theirs")
do _not_ apply to modify/delete or delete/modify conflicts. Such
conflicts are always reported as conflicts by C git. They do apply,
however, if one side completely clears a file's content.

Bug: 501111
Change-Id: I2c9c170c61c440a2ab9c387991e7a0c3ab960e07
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-04-19 01:52:19 +02:00
Thomas Wolf 983c25064e ssh: ensure list is modifiable before using Iterator.remove().
Bug: 572849
Change-Id: If6be0024d2069e2d85541d7e87c6b0371db4b3df
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-04-14 17:48:34 +02:00
Matthias Sohn 91b2e167a2 Update orbit to S20210406213021 and add 4.20-staging target
Change-Id: I465831b0edf359b504918009dd7fb03a77b06305
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-04-10 22:46:40 +02:00
Thomas Wolf fd03e40256 Fix typo in test method name
Change-Id: I34718829435daf8ded4ce596c824dd3cfbafbaf6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-04-09 11:31:56 +02:00
Matthias Sohn 04f1edc44e Merge "Upgrade ecj to 3.25.0" 2021-04-07 19:08:19 -04:00
Marija Savtchouk 7ceb61494b Allow file mode conflicts in virtual base commit on recursive merge.
Similar to https://git.eclipse.org/r/c/jgit/jgit/+/175166, ignore
path that have conflicts on attributes, so that the virtual base could
be used by RecursiveMerger.

Change-Id: I99c95445a305558d55bbb9c9e97446caaf61c154
Signed-off-by: Marija Savtchouk <mariasavtchouk@google.com>
2021-04-06 09:33:04 +01:00
Thomas Wolf 2345cc88d0 sshd: don't lock the known_hosts files on reading
Similar to git config file reading lock the file only when writing.
There may still be lock conflicts on writing, but those in the worst
case result in an entry not being added and thus being asked for later
again.

Because the OpenSshServerkeyDatabase and its HostKeyFiles may be (and
usually are) shared between different SSH sessions, we still need to
ensure in-process mutual exclusion.

Bug: 559548
Change-Id: I4af97628deff9eaac2520576917c856949f2680d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-04-01 19:01:32 +02:00
Thomas Wolf 0c91bf4e17 Allow info messages in UsernamePasswordCredentialsProvider
o.e.j.ssh.apache produces passphrase prompts containing
InformationalMessage items to show the fingerprint of the key
the passphrase is being asked for. Allow this so that the credentials
provider can be used with o.e.j.ssh.apache.

Change-Id: Ibc2ffd3a987d3118952726091b9b80442972dfd8
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-04-01 19:01:24 +02:00
Thomas Wolf 1de2a9fbe7 ssh config: do environment variable replacement
OpenSSH 8.4 has introduced simple environment variable substitution
for some keys. Implement that feature in our ssh config file parser,
too.

Bug: 572103
Change-Id: I360f2c5510eea4ec3329aeedf3d29dfefc9163f0
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-04-01 19:01:13 +02:00
Thomas Wolf 8edde18c8c sshd: implement server-sig-algs SSH extension (client side)
Apache MINA sshd has an implementation of this, but it doesn't comply
to RFC 8308 [1] and it is buggy. (See SSHD-1141 [2].)

Add a simpler KexExtensionHandler and if the server sends extension
server-sig-algs, use its value to re-order the chosen signature
algorithms such that the algorithms the server announced as supported
are at the front.

If the server didn't tell us anything, don't do anything. RFC 8308
suggests for RSA to default to ssh-rsa, but says once rsa-sha2-* was
"widely enough" adopted, defaulting to that might be OK.

Currently we seem to be in a transition phase; Fedora 33 has already
disabled ssh-rsa by default, and openssh is about to do so. Whatever
we might do without info from the server, it'd be good for some servers
and bad for others. So don't do anything and let the user re-order via
ssh config PubkeyAcceptedAlgorithms on a case-by-case basis.

[1] https://tools.ietf.org/html/rfc8308
[2] https://issues.apache.org/jira/browse/SSHD-1141

Bug: 572056
Change-Id: I59aa691a030ffe0fae54289df00ca5c6e165817b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-04-01 19:01:02 +02:00
Marco Miller 9c3db7a276 Upgrade ecj to 3.25.0
Change-Id: I09d018205564205b194de020941fd4152ae8b24e
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
2021-03-30 13:56:50 -04:00
David Ostrovsky c82818e0e0 Bazel: Remove unused dependencies flagged by unused_deps
Change-Id: I7fcb494fdce4bb3de203236fa51b188b099d842f
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2021-03-27 15:27:25 +01:00
David Ostrovsky f8eefdb003 Bazel: Format build file with buildifier
Change-Id: I4c0c7ffb04d7bed517faf1a4932d8c76738bff11
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2021-03-27 15:00:28 +01:00
Marco Miller 58dd6496eb Upgrade wagon-ssh to 3.4.3
Change-Id: Ibc3a9ea83e264920b4a995f6d22904fe3be97d5a
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
2021-03-26 12:58:35 +01:00
Matthias Sohn 7672f25948 Update spring-boot-maven-plugin to 2.4.4
Change-Id: I8ba1e544b2e80ad66aacd230c4a442bdc1d60375
2021-03-26 12:49:00 +01:00
Matthias Sohn afd5c61536 Update spotbugs-maven-plugin to 4.2.2
Change-Id: Ib522b66249e5493c3fd191b5c56e87f8941569c2
2021-03-26 12:32:55 +01:00
Matthias Sohn 60c32aa221 Update japicmp-maven-plugin to 0.15.3
Change-Id: I3b1b295e7f97182a5541b1912e0acbfffb981d71
2021-03-26 12:28:13 +01:00
Matthias Sohn beecca02bb Merge branch 'stable-5.11'
* stable-5.11:
  Refactor CommitCommand to improve readability
  CommitCommand: fix formatting
  CommitCommand: remove unncessary comment
  Ensure post-commit hook is called after index lock was released
  sshd: try all configured signature algorithms for a key
  sshd: modernize ssh config file parsing
  sshd: implement ssh config PubkeyAcceptedAlgorithms

Change-Id: Ic3235ffd84c9d7537a1fe5ff4f216578e6e26724
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-26 09:56:19 +01:00
Matthias Sohn 502bfff7db Refactor CommitCommand to improve readability
Change-Id: Id3cac81cd32c07f677b7f669d58e32b5290e1790
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-23 11:01:53 +01:00
Matthias Sohn 18c735c474 CommitCommand: fix formatting
Change-Id: I5efd1ffee4ebb08b3b5c27e29162493615727840
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-23 11:01:53 +01:00
Matthias Sohn b08c599fb8 CommitCommand: remove unncessary comment
Let the code speak for itself.

Change-Id: I6a6d6c327ffac23fc607295a7f4fd3131b3d1e58
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-23 11:01:52 +01:00
Matthias Sohn f43cb3605c Ensure post-commit hook is called after index lock was released
Otherwise a post-commit hook cannot modify the index.

Bug: 566934
Change-Id: I0093dccd93b2064f243544b516bdce198afdb18b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-23 11:01:52 +01:00
Thomas Wolf fd3edc7bfc sshd: try all configured signature algorithms for a key
For RSA keys, there may be several configured signature algorithms:
rsa-sha2-512, rsa-sha2-256, and ssh-rsa. Upstream sshd has bug
SSHD-1105 [1] and always and unconditionally uses only the first
configured algorithm. With the default order, this means that it cannot
connect to a server that knows only ssh-rsa, like for instance Apache
MINA sshd servers older than 2.6.0.

This affects for instance bitbucket.org or also AWS Code Commit.

Re-introduce our own pubkey authenticator that fixes this.

Note that a server may impose a penalty (back-off delay) for subsequent
authentication attempts with signature algorithms unknown to the server.
In such cases, users can re-order the signature algorithm list via the
PubkeyAcceptedAlgorithms (formerly PubkeyAcceptedKeyTypes) ssh config.

[1] https://issues.apache.org/jira/browse/SSHD-1105

Bug: 572056
Change-Id: I7fb9c759ab6532e5f3b6524e9084085ddb2f30d6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-03-19 17:28:24 +01:00
Thomas Wolf 6faee128f8 sshd: modernize ssh config file parsing
OpenSSH has changed some things in ssh config files. Update our parser
to implement some of these changes:

* ignore trailing comments on a line
* rename PubkeyAcceptedKeyTypes to PubkeyAcceptedAlgorithms

Note that for the rename, openSSH still accepts both names. We do the
same, translating names whenever we get or set values.

Change-Id: Icccca060e6a4350a7acf05ff9e260f2c8c60ee1a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-03-19 17:27:49 +01:00
Thomas Wolf ffc1f9b026 sshd: implement ssh config PubkeyAcceptedAlgorithms
Apache MINA sshd 2.6.0 appears to use only the first appropriate
public key signature algorithm for a particular key. See [1]. For
RSA keys, that is rsa-sha2-512. This breaks authentication at servers
that only know the older (and deprecated) ssh-rsa algorithm.

With PubkeyAcceptedAlgorithms, users can re-order algorithms in
the ssh config file per host, if needed. Setting

  PubkeyAcceptedAlgorithms ^ssh-rsa

will put "ssh-rsa" at the front of the list of algorithms, and then
authentication at such servers with RSA keys works again.

[1] https://issues.apache.org/jira/browse/SSHD-1105

Bug: 572056
Change-Id: I86c3b93f05960c68936e80642965815926bb2532
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-03-19 17:27:03 +01:00
Adithya Chakilam 41643dcb79 Optimize RevWalkUtils.findBranchesReachableFrom()
In [1], improved RevWalk.getMergedInto() is introduced to avoid repeated
work while performing RevWalk.isMergedInto() on many refs. Modify
findBranchesReachableFrom() to use it.

[1] I65de9873dce67af9c415d1d236bf52d31b67e8fe

Change-Id: I81d615241638d4093df64b449637af601843a5ed
Signed-off-by: Adithya Chakilam <quic_achakila@quicinc.com>
2021-03-14 13:38:49 -05:00
Adithya Chakilam 0bd2f4bf77 Introduce getMergedInto(RevCommit commit, Collection<Ref> refs)
In cases where we need to determine if a given commit is merged
into many refs, using isMergedInto(base, tip) for each ref would
cause multiple unwanted walks.

getMergedInto() marks the unreachable commits as uninteresting
which would then avoid walking that same path again.

Using the same api, also introduce isMergedIntoAny() and
isMergedIntoAll()

Change-Id: I65de9873dce67af9c415d1d236bf52d31b67e8fe
Signed-off-by: Adithya Chakilam <quic_achakila@quicinc.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-14 13:45:29 +01:00
Youssef Elghareeb 4a78d911c5 Skip detecting content renames for large files
There are two code paths for detecting renames: one on tree diffs
(using DiffFormatter#scan) and the other on single file diffs (using
DiffFormatter#format). The latter skips binary and large files
for rename detection - check [1], but the former doesn't.

This change skips content rename detection for the tree diffs case for
large files. This is essential to avoid expensive computations while
reading the file, especially for callers who don't want to pay that
cost. Content renames are those which involve files with slightly
modified content. Exact renames will still be identified.

The default threshold for file sizes is reused from
PackConfig.DEFAULT_BIG_FILE_THRESHOLD: 50 MB.

[1] 232876421d/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java (386)

Change-Id: Idbc2c29bd381c6e387185204638f76fda47df41e
Signed-off-by: Youssef Elghareeb <ghareeb@google.com>
2021-03-14 11:38:13 +01:00
Matthias Sohn 84ed57d2f6 Remove unused API problem filters
Change-Id: I34be8afa42971b94d86312ff8b672b133cd23d45
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-13 17:12:07 -05:00
Thomas Wolf 33a055e63b Document http options supported by JGit
Change-Id: I0af4f9991fdb4f09de25f743d1e0dca67ceaa18b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-03-13 17:05:47 +01:00
Thomas Wolf 808c4495ca HTTP cookies: do tilde expansion on http.cookieFile
Git config http.cookieFile must have ~ expansion, compare [1].

It also should be an absolute path. While a relative path is allowed,
C git just passes the value on to libcurl, so it'll be relative to the
current working directory and thus not work in all directories.

Log a warning if the path is relative.

(Alternatives would be to throw an exception, or to resolve the path
relative to the .git directory, or relative to the working tree root,
or relative to the config file it occurs in. But C git does not seem
to do either.)

[1] https://github.com/git/git/commit/e5a39ad8e

Bug: 571798
Change-Id: I5cdab6061d0613ac7d8cb7977e5b97f5b88f562d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-03-12 12:02:22 +01:00
Matthias Sohn 232876421d Prepare 5.12.0-SNAPSHOT builds
Change-Id: I736de7c3deb11da75777d459f47332df0b486443
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-10 16:34:28 +01:00
Matthias Sohn 9cf3a3e9b5 Merge branch 'stable-5.11'
* stable-5.11:
  Update Orbit to R20210223232630
  Prepare 5.11.1-SNAPSHOT builds
  JGit v5.11.0.202103091610-r
  Prepare 5.11.0-SNAPSHOT builds
  JGit v5.11.0.202103031150-rc1

Change-Id: I808e53a3c54a49d0dd62c69818ea2f5672e16a91
2021-03-10 16:05:18 +01:00
Matthias Sohn e5aa53fec9 Update Orbit to R20210223232630
Change-Id: I7577131b2c6e808b59f6c453233b261c64646d35
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-10 00:39:29 +01:00
Matthias Sohn 1f368f8867 Prepare 5.11.1-SNAPSHOT builds
Change-Id: I94628ccbb5099a65aa4345cfd28a141ff5555b68
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-09 23:42:31 +01:00
Matthias Sohn 30b6887d44 JGit v5.11.0.202103091610-r
Change-Id: I8e6855eaf7228459f492036feb4e34ca085698a7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-03-09 22:10:22 +01:00
Matthias Sohn 3aa142e7bf Merge branch 'master' into stable-5.11
* master:
  Manually set status of jmh dependencies
  Update DEPENDENCIES report for 5.11.0
  Add dependency to dash-licenses
  PackFile: Add id + ext based constructors
  GC: deleteOrphans: Use PackFile
  PackExt: Convert to Enum
  Restore preserved packs during missing object seeks
  Pack: Replace extensions bitset with bitmapIdx PackFile
  PackDirectory: Use PackFile to ensure we find preserved packs
  GC: Use PackFile to de-dup logic
  Create a PackFile class for Pack filenames

Change-Id: I1d56517cb6a95e10aed22cdb9e5f3e504872d110
2021-03-09 18:00:55 +01:00
Matthias Sohn 7a3f628180 Manually set status of jmh dependencies
The following jmh dependencies were approved as works-with:
- jmh-core/1.21 has GPL-2.0 license and was approved in CQ20517
- jmh-generator-annprocess/1.21 has GPL-2.0 license and was approved in
CQ20518

Change-Id: Ibbe28c6e8359c576b23f40281e74f2e0d4a0dee0
2021-03-07 18:52:16 +01:00
Matthias Sohn 8d712c8460 Update DEPENDENCIES report for 5.11.0
Computed by dash license-tool-plugin [1].

[1] https://github.com/eclipse/dash-licenses

Change-Id: I28727115914613cefdcf9a9f462c195b6af23156
2021-03-07 18:50:54 +01:00
Matthias Sohn 663f29e158 Add dependency to dash-licenses
This is required to run the license check using the license tool [1]
required by the Eclipse project handbook [2]:

mvn org.eclipse.dash:license-tool-plugin:license-check -Ddash.summary=DEPENDENCIES

Note: the tool still requires Java 11 hence it needs to be run in a
separate build step and is not yet integrated in the build which runs
on Java 8.

[1] https://github.com/eclipse/dash-licenses
[2] https://www.eclipse.org/projects/handbook/#ip-license-tool

Change-Id: Ib41d54de246c3c9499cc3be9f026294c39fdfd99
2021-03-07 18:35:38 +01:00
Nasser Grainawi 2a6b2eddcf PackFile: Add id + ext based constructors
Add new constructors to PackFile to improve a common use case where
callers know the directory, id, and extension, but previously needed to
construct a valid file name (with prefix, '.', etc) to create a
PackFile. Most callers can use the variant that has id as an ObjectId,
but provide an id as String variant too.

Change-Id: I39e4466abe8c9509f5916d5bfe675066570b8585
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
2021-03-07 00:02:56 +01:00
Nasser Grainawi 093020864f GC: deleteOrphans: Use PackFile
It's easier to follow the logic here when we can use our own objects
instead of Strings.

Change-Id: I6a166edcc67903fc1ca3544f458634c4cef8fde7
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
2021-03-04 16:37:08 -07:00