Commit Graph

8335 Commits

Author SHA1 Message Date
Thomas Wolf 501fc0dadd ApplyCommand: add a base-85 codec
Add an implementation for base-85 encoding and decoding [1]. Git binary
patches use this format.

Base-85 encoding assembles bytes as 32-bit MSB values, then converts
these values to base-85 numbers (always 5 bytes) encoded as printable
ASCII characters. Decoding base-85 is the reverse operation. Note
that decoding may overflow on invalid input as 85^5 > 2^32. Encodings
always have a length that is a multiple of 5. If input length is not
divisible by 4, padding bytes are (logically) added, which are ignored
when decoding. The encoding for n bytes has thus always exactly length
(n + 3) / 4 * 5 in integer arithmetic (truncating division).

Includes tests.

[1] https://datatracker.ietf.org/doc/html/rfc1924

Bug: 371725
Change-Id: Ib5b9a503cd62cf70e080a4fb38c8cd1eeeaebcfe
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-26 00:37:45 +02:00
Thomas Wolf d2846cc8b2 ApplyCommand: convert to git internal format before applying patch
Applying a patch on Windows failed if the patch had the (normal)
single-LF line endings, but the file on disk had the usual Windows
CR-LF line endings.

Git (and JGit) compute diffs on the git-internal blob, i.e., after
CR-LF transformation and clean filtering. Applying patches to files
directly is thus incorrect and may fail if CR-LF settings don't
match, or if clean/smudge filtering is involved.

Change ApplyCommand to run the file content through the check-in
filters before applying the patch, and run the result through the
check-out filters. This makes patch application succeed even if the
patch has single-LFs, but the file has CR-LF and core.autocrlf is
true.

Add tests for various combinations of line endings in the file and in
the patch, and a test to verify the clean/smudge handling.

See also [1].

Running the file though clean/smudge may give strange results with
LFS-managed files. JGit's DiffFormatter has some extra code and
applies the smudge filter again after having run the file through
the check-in filters (CR-LF and clean). So JGit can actually produce
a diff on LFS-managed files using the normal diff machinery. (If it
doesn't run out of memory, that is. After all, LFS is intended for
_large_ files.) How such a diff would be applied with either C git
or JGit is entirely unclear; neither has any code for this special
case. Compare also [2].

Note that C git just doesn't know about LFS and always diffs after
the check-in filter chain, so for LFS files, it'll produce a diff
of the LFS pointers.

[1] https://github.com/git/git/commit/c24f3abac
[2] https://github.com/git-lfs/git-lfs/issues/440

Bug: 571585
Change-Id: I8f71ff26313b5773ff1da612b0938ad2f18751f5
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-18 17:23:34 +02:00
Thomas Wolf c718e6059c SSH config: fix whitespace handling
Use Character.isWhitespace() instead of Character.isSpaceChar() to
treat TABs as whitespace, too.

Change-Id: Iffc59c13357d981ede6a1e0feb6ea6ff03fb3064
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-17 08:31:41 +02:00
Thomas Wolf 87704b7736 SSH config: fix negated patterns
Negated patterns were handled wrongly. According to the OpenBSD
ssh_config man page,[1] a negated pattern never matches. Negated
patterns make only sense if there are positive patterns; the
negated pattern then can define exceptions for the positive
patterns.

OpenSshConfigFile did this wrongly. It handled "!foo" as "matching
everything but foo", but actually the semantics is "if the input is
"foo", this entry doesn't apply. If the input is anything else,
other patterns determine whether the entry may apply.".

[1] https://man.openbsd.org/ssh_config

Change-Id: I50f6e46581b7ece4c949eddf62f4a265573ec29e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-17 08:26:23 +02:00
Matthias Sohn cb65846722 Fix @since tag for introduction of PUBKEY_ACCEPTED_ALGORITHMS
This constant was shipped with 5.11.1.

Change-Id: I480dbefab1cccca78cefbc709b79e5405f8bf8cd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-14 09:02:46 +02:00
Matthias Sohn e537e29d78 Merge branch 'stable-5.11'
* stable-5.11:
  Prepare 5.11.2-SNAPSHOT builds
  JGit v5.11.1.202105131744-r

Change-Id: I940216261e25d7bb24e912a8971655198762703a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-14 08:39:14 +02:00
Matthias Sohn 93d3d481f8 Prepare 5.11.2-SNAPSHOT builds
Change-Id: Idfd81bd3bbcd99034f69fffb1a562bf07b0f8209
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-14 08:28:59 +02:00
Matthias Sohn 8dad905f20 JGit v5.11.1.202105131744-r
Change-Id: Id74eecbde63edbc58b6262ae01ef34d8bebc0f88
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-13 23:42:10 +02:00
Matthias Sohn fe3034d5b9 Merge branch 'stable-5.12'
* stable-5.12:
  Remove texts which were added by mistake in 00386272
  Fix formatting which was broken in 00386272

Change-Id: I1c936183e1fa17ea95ada7849a75bc76af275fa3
2021-05-12 08:58:09 +02:00
Matthias Sohn 4e290d389a Merge branch 'stable-5.11' into stable-5.12
* stable-5.11:
  Remove texts which were added by mistake in 00386272
  Fix formatting which was broken in 00386272

Change-Id: I6184772bdeca1b9ccecf6e400ae15604ab4f5a69
2021-05-12 08:57:20 +02:00
Matthias Sohn 618d8c4784 Merge branch 'stable-5.10' into stable-5.11
* stable-5.10:
  Remove texts which were added by mistake in 00386272
  Fix formatting which was broken in 00386272

Change-Id: I0f1511be5375716d41565e72b271cb956c3e847b
2021-05-12 08:56:27 +02:00
Matthias Sohn 3d156790e9 Merge branch 'stable-5.9' into stable-5.10
* stable-5.9:
  Remove texts which were added by mistake in 00386272
  Fix formatting which was broken in 00386272

Change-Id: Ifa135077d8d07d2317df3b479822e30d87eca950
2021-05-12 08:55:44 +02:00
Matthias Sohn 73f8acdc5c Merge branch 'stable-5.8' into stable-5.9
* stable-5.8:
  Remove texts which were added by mistake in 00386272
  Fix formatting which was broken in 00386272

Change-Id: I9ca7a0237f87d1d4bcaba81e709eaa67902f27e5
2021-05-12 08:50:18 +02:00
Matthias Sohn adc1fc645f Merge branch 'stable-5.7' into stable-5.8
* stable-5.7:
  Remove texts which were added by mistake in 00386272
  Fix formatting which was broken in 00386272

Change-Id: I7ed3f47cb46e6c1bf483702c8925a24e88658e47
2021-05-11 23:34:30 +02:00
Matthias Sohn 26dee2d984 Merge branch 'stable-5.6' into stable-5.7
* stable-5.6:
  Remove texts which were added by mistake in 00386272
  Fix formatting which was broken in 00386272

Change-Id: I45d444b360485564744bf3dfad2c2f5a5e7fcdf6
2021-05-11 23:32:22 +02:00
Matthias Sohn 37436cc933 Remove texts which were added by mistake in 00386272
Change-Id: Iaed25dac0bc9af8f3fda6138a5f9fe553bff5d39
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-11 21:41:02 +02:00
Matthias Sohn 70e250c356 Fix formatting which was broken in 00386272
Change-Id: I10a3e2b117e790f64386a8e9e7663db8e59230d9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-11 18:36:05 +02:00
Matthias Sohn cf76a92e04 Merge branch 'stable-5.12'
* stable-5.12:
  LockFile: create OutputStream only when needed
  Remove ReftableNumbersNotIncreasingException

Change-Id: I9d85187d00771beef908f1136015d059024f4118
2021-05-11 01:00:31 +02:00
Matthias Sohn 1aff4369b0 Merge branch 'stable-5.11' into stable-5.12
* stable-5.11:
  LockFile: create OutputStream only when needed
  Remove ReftableNumbersNotIncreasingException

Change-Id: I7adb5c4fc28e0043a985b5136424f3f756b2f84f
2021-05-11 00:59:10 +02:00
Matthias Sohn 1ccdf83fbd Merge branch 'stable-5.10' into stable-5.11
* stable-5.10:
  LockFile: create OutputStream only when needed
  Remove ReftableNumbersNotIncreasingException

Change-Id: Id6e0a78caf12c19a01a88d1ddb8a7df2b3590f98
2021-05-11 00:57:46 +02:00
Matthias Sohn c557eea782 Merge branch 'stable-5.9' into stable-5.10
* stable-5.9:
  LockFile: create OutputStream only when needed
  Remove ReftableNumbersNotIncreasingException
  Fix stamping to produce stable file timestamps

Change-Id: I056382d1d93f3e0a95838bdd1f0be89711c8a722
2021-05-11 00:56:57 +02:00
Matthias Sohn 587c7eab45 Merge branch 'stable-5.8' into stable-5.9
* stable-5.8:
  LockFile: create OutputStream only when needed
  Remove ReftableNumbersNotIncreasingException

Change-Id: I3274c97cf560398c3c4c27d6759500452f315db0
2021-05-11 00:55:54 +02:00
Matthias Sohn f2e5bace48 Merge branch 'stable-5.7' into stable-5.8
* stable-5.7:
  LockFile: create OutputStream only when needed
  Remove ReftableNumbersNotIncreasingException

Change-Id: Ib3f280e0741f87a0ff615d857a5ea39b35527e74
2021-05-11 00:51:21 +02:00
Matthias Sohn 0616016c83 Merge branch 'stable-5.6' into stable-5.7
* stable-5.6:
  LockFile: create OutputStream only when needed

Change-Id: I7c0e37d2cee0923662a7e39df5a802a84c017e4f
2021-05-11 00:31:58 +02:00
Thomas Wolf 0038627226 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-10 23:58:07 +02:00
Matthias Sohn e6192c56af Add a cgit interoperability test for LockFile
Change-Id: I30cacd1f50f8f4ff4dd91ad291bf279980e3c4b5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-09 22:49:19 +02:00
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