]> source.dussan.org Git - jgit.git/log
jgit.git
9 months agoMerge branch 'stable-6.7' into stable-6.8 28/1176928/1
Dariusz Luksza [Thu, 15 Feb 2024 10:43:11 +0000 (10:43 +0000)]
Merge branch 'stable-6.7' into stable-6.8

* stable-6.7:
  RefDirectory: Do not unlock until after deleting loose ref
  Add missing javadoc description for declared exception
  SnapshottingRefDirectory: Invalidate snapshot after locking ref for update
  SnapshottingRefDir: Replace lambas with method refs
  SnapshottingRefDir: Reduce casts with overrides
  [errorprone] Fix wrong comparison which always evaluated to false
  [errorprone] Remove unnecessary comparison

Change-Id: Ic6312bd3b2b1db38a287ebc7f31062251341438a

9 months agoMerge branch 'stable-6.6' into stable-6.7 27/1176927/1
Dariusz Luksza [Thu, 15 Feb 2024 10:36:41 +0000 (10:36 +0000)]
Merge branch 'stable-6.6' into stable-6.7

* stable-6.6:
  RefDirectory: Do not unlock until after deleting loose ref
  Add missing javadoc description for declared exception
  SnapshottingRefDirectory: Invalidate snapshot after locking ref for update
  SnapshottingRefDir: Replace lambas with method refs
  SnapshottingRefDir: Reduce casts with overrides

Change-Id: Ic5f3c46e5557d0bd143694bd6020b67b6ec8f22e

9 months agoRefDirectory: Do not unlock until after deleting loose ref 74/1176274/3
Nasser Grainawi [Fri, 26 Jan 2024 01:59:15 +0000 (18:59 -0700)]
RefDirectory: Do not unlock until after deleting loose ref

Fix a potential race condition where we would remove our loose ref lock
file before deleting the loose ref itself. This race could result in the
current thread deleting a loose ref newly written by another thread.

Other callers seem to be following the correct pattern, but improve the
method naming to try to help future callers.

Change-Id: I80cebe4788edd855e15381336d980c41498fca80
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
9 months agoAdd missing javadoc description for declared exception 31/1176831/1
Matthias Sohn [Tue, 13 Feb 2024 14:49:54 +0000 (15:49 +0100)]
Add missing javadoc description for declared exception

Change-Id: I16305bc15d2ddff1ce055772a711658ef81858e2

9 months agoSnapshottingRefDirectory: Invalidate snapshot after locking ref for 75/1176275/4
Nasser Grainawi [Thu, 25 Jan 2024 23:29:05 +0000 (16:29 -0700)]
SnapshottingRefDirectory: Invalidate snapshot after locking ref for
update

When using the SnapshottingRefDirectory, if a thread has already read
packed-refs, then another actor updates packed-refs, the original
thread may create an update that is based on the old cached/snapshotted
packed-refs content. That update could effectively perform a forced
update unintentionally because it is unaware of the new content.

This seems particularly likely to happen in a scenario where a loose
ref was just packed. If the ref was loose, our thread would see the
current ref value (because we don't snapshot loose refs and always read
them from disk), but since there is no loose ref, we expect to find the
current value in packed-refs. However, (before this change) we rely
on our snapshot of packed-refs which does not contain the updated ref
value.

Invalidating the cache after the loose ref is locked ensures that the
ref value does not change again before we read it to perform the update.

Bug: jgit-21
Change-Id: Id10900a99bfd0401a1b9c39d997093af0289649e
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
9 months agoSnapshottingRefDir: Replace lambas with method refs 89/1176789/2
Nasser Grainawi [Mon, 12 Feb 2024 23:32:30 +0000 (16:32 -0700)]
SnapshottingRefDir: Replace lambas with method refs

Method references are shorter and easier to read in this case.

Change-Id: Ia6809fa0e3f282acbe7b7f7e3813a34f3cf40c43
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
9 months agoSnapshottingRefDir: Reduce casts with overrides 88/1176788/2
Nasser Grainawi [Mon, 12 Feb 2024 23:29:47 +0000 (16:29 -0700)]
SnapshottingRefDir: Reduce casts with overrides

Overriding getRefDirectory() and getRefDatabase() lets us skip casting
to SnapshottingRefDirectory in several places.

Change-Id: I61ba12fb6f066b1a9c4ea5ec9538978cbf040acd
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
9 months ago[errorprone] Fix wrong comparison which always evaluated to false 58/1176058/1
Matthias Sohn [Fri, 15 Sep 2023 09:48:05 +0000 (11:48 +0200)]
[errorprone] Fix wrong comparison which always evaluated to false

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/GraphObjectIndex.java:59:
error: [ComparisonOutOfRange] ints may have a value in the range
-2147483648 to 2147483647; therefore, this comparison to
Integer.MAX_VALUE will always evaluate to false
if (table[k] > Integer.MAX_VALUE) {
             ^

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

We need to check if variable `uint` of type `long` exceeds the maximum
possible int value before casting it to `int` below.

This was introduced in Ib5c0d6678cb242870a0f5841bd413ad3885e95f6

Change-Id: I675d594f523084be4c1678328cc343065e32d998
(cherry picked from commit 916200e278ebeaa2602b5dc23143c8eedf11858b)

9 months ago[errorprone] Remove unnecessary comparison 57/1176057/1
Matthias Sohn [Fri, 15 Sep 2023 09:44:09 +0000 (11:44 +0200)]
[errorprone] Remove unnecessary comparison

Raised by errorprone:

org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitConfig.java:406: error:
[ComparisonOutOfRange] chars may have a value in the range 0 to 65535;
therefore, this comparison to 0 will always evaluate to true
if (ch >= 0 && ch < inUse.length) {
       ^
see https://errorprone.info/bugpattern/ComparisonOutOfRange

Change-Id: I9625aa7894a34dbffd77d39a40c6e285c86b56d5
(cherry picked from commit cf5ec856bda907c0537ce5a80246b9ab18195c8b)

9 months agoMerge branch 'stable-6.7' into stable-6.8 47/1176747/1
Dariusz Luksza [Mon, 12 Feb 2024 09:58:41 +0000 (09:58 +0000)]
Merge branch 'stable-6.7' into stable-6.8

* stable-6.7:
  Improve handling of NFS stale handle errors
  Fix handling of missing pack index file
  Add tests for handling pack files removal during fetch

Change-Id: I409d1dc3354ad65c048d2c40f39071a1207246c6

9 months agoMerge branch 'stable-6.6' into stable-6.7 46/1176746/1
Dariusz Luksza [Mon, 12 Feb 2024 09:56:36 +0000 (09:56 +0000)]
Merge branch 'stable-6.6' into stable-6.7

* stable-6.6:
  Improve handling of NFS stale handle errors
  Fix handling of missing pack index file
  Add tests for handling pack files removal during fetch

Change-Id: Ie00984319d68beeffcbdb6bb323fbeb94a118e5c

9 months agoImprove handling of NFS stale handle errors 25/1176125/1
Dariusz Luksza [Mon, 20 Nov 2023 11:53:19 +0000 (11:53 +0000)]
Improve handling of NFS stale handle errors

Mark packfile as invalid when NFS stale handle error occurs.

This should fix broken fetch operations when the repo is located on the
NFS system and is GC'ed on a separate system (or process). Which may
result in the index, pack or bitmap file being removed when they are
accessed from the fetch operation.

Bug: 573770
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
Change-Id: I70217bfb93bf7421ea2c1d74cbe4f15c76d9c098
(cherry picked from commit c701c01b49d92993f1c3df0a0e26a2dd68b8cec1)

9 months agoFix handling of missing pack index file 24/1176124/1
Dariusz Luksza [Mon, 20 Nov 2023 11:00:51 +0000 (11:00 +0000)]
Fix handling of missing pack index file

As demonstrated in
`UploadPackHandleDeletedPackFile.testV2IdxFileRemovedDuringUploadPack`
the fetch operation will fail when the pack index file is removed.

This is due to a wrapping of `FileNotFoundException` (which is a
subclass of `IOExeption`) in an `IOException` at PackIndex L#68. This
is then changing the behaviour of error handling in
`Pack.file.getBitmapIndex()` where the `FileNotFoundException` is
swallowed and allows the fetch process to continue. With FNFE being
wrapped in IOE, this blows up and breaks the fetch operation.

Simply rethrowing `FileNotFoundException` from `PackFile.open()` fixes
the broken fetch operation. This will also mark the whole pack as
invalid in the `IOException` handler in `Pack.idx()` method.

Change-Id: Ibe321aa1af21d26500e1cb2eb3464cc99a6dbc62
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
(cherry picked from commit e0910eda3ea1c474b4cf9b00ac698f739a982f8c)

9 months agoAdd tests for handling pack files removal during fetch 23/1176123/1
Dariusz Luksza [Fri, 17 Nov 2023 19:28:53 +0000 (19:28 +0000)]
Add tests for handling pack files removal during fetch

Although this could sound like a corner case, it really can occur out
there in the real world. Especially in the Gerrit world where the
repositories could be GC'ed on a separate process or system.

The `FileNotFoundException` seems to be handled correctly in
`PackFile#doOpen` (line 671) and it will mark the pack as invalid. But
triggering that code path was not an easy task.

First of all, we need to add a new commit to the `master` branch of the
test repository after `UploadPack` object is created.

Secondly, in the refspec for fetch, commit id instead of "regular"
refspec must be used.

With both in place, we can see a warning log statement about deleted
pack file. And the fetch succeeds!

Also, tests for the removal of *.idx and *.bitmap files were added.

This unveiled a corner for the *.idx file deletion while fetching, as
the test will fail with "Unreachable pack index" IOException only
when the HEAD commit is empty.

Change-Id: If26c83f9b12993d1ab7d6bad6bd863c29520b062
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
(cherry picked from commit ba5adc4ce6f234cb300b0f73a1efdba9bba1b5d8)

10 months agoMerge branch 'stable-6.7' into stable-6.8 06/1174606/1
Matthias Sohn [Fri, 19 Jan 2024 23:40:42 +0000 (00:40 +0100)]
Merge branch 'stable-6.7' into stable-6.8

* stable-6.7:
  Introduce a PriorityQueue sorting RevCommits by commit timestamp
  Remove org.eclipse.jgit.benchmark/.factorypath
  Update jmh to 1.37 for org.eclipse.jgit.benchmark

Change-Id: I5d49a9dc7da17b83243229d4d8d3b9ee0a063e65

10 months agoMerge branch 'stable-6.6' into stable-6.7 05/1174605/1
Matthias Sohn [Fri, 19 Jan 2024 23:18:25 +0000 (00:18 +0100)]
Merge branch 'stable-6.6' into stable-6.7

* stable-6.6:
  Introduce a PriorityQueue sorting RevCommits by commit timestamp
  Remove org.eclipse.jgit.benchmark/.factorypath
  Update jmh to 1.37 for org.eclipse.jgit.benchmark

Change-Id: I76ebca527e523f124bfe81c821169c790eddccb6

10 months agoIntroduce a PriorityQueue sorting RevCommits by commit timestamp 40/194140/36
Luca Milanesio [Mon, 13 Jun 2022 22:09:55 +0000 (23:09 +0100)]
Introduce a PriorityQueue sorting RevCommits by commit timestamp

The DateRevQueue uses a tailor-made algorithm to keep
RevCommits sorted by reversed commit timestamp, which has a O(n*n/2)
complexity and caused the explosion of the Git fetch times to
tens of seconds.

The standard Java PriorityQueue provides a O(n*log(n)) complexity
and scales much better with the increase of the number of
RevCommits.

Introduce a new implementation DateRevPriorityQueue of the DateRevQueue
based on PriorityQueue.

Enable usage of the new DateRevPriorityQueue implementation by setting
the system property REVWALK_USE_PRIORITY_QUEUE=true. By default the old
implementation DateRevQueue is used.

Benchmark results:
```
(numCommits)  (usePriorityQueue)  Mode  Cnt     Score Error  Units
           5                true  avgt   10    39,4 ±   6,1  ns/op
           5               false  avgt   10    14,1 ±   2,2  ns/op
          10                true  avgt   10    29,7 ±   3,5  ns/op
          10               false  avgt   10    13,2 ±   2,0  ns/op
          50                true  avgt   10    50,4 ±   5,3  ns/op
          50               false  avgt   10    18,6 ±   0,2  ns/op
         100                true  avgt   10    58,3 ±   5,0  ns/op
         100               false  avgt   10    20,5 ±   0,8  ns/op
         500                true  avgt   10    51,7 ±   2,6  ns/op
         500               false  avgt   10    43,3 ±   0,5  ns/op
        1000                true  avgt   10    49,2 ±   2,4  ns/op
        1000               false  avgt   10    62,7 ±   0,2  ns/op
        5000                true  avgt   10    48,8 ±   1,5  ns/op
        5000               false  avgt   10   228,3 ±   0,5  ns/op
       10000                true  avgt   10    44,2 ±   0,9  ns/op
       10000               false  avgt   10   377,6 ±   2,7  ns/op
       50000                true  avgt   10    50,3 ±   1,6  ns/op
       50000               false  avgt   10   637,0 ± 111,8  ns/op
      100000                true  avgt   10    61,8 ±   4,4  ns/op
      100000               false  avgt   10   965,1 ± 268,0  ns/op
      500000                true  avgt   10   127,2 ±   7,9  ns/op
      500000               false  avgt   10  9610,2 ± 184,8  ns/op
```

Memory allocation results:
```
Number of commits loaded: 850 000
Custom implementation: 378 245 120 Bytes
Priority queue implementation: 340 495 616 Bytes
```

Bug: 580137
Change-Id: I8b33df6e9ee88933098ecc81ce32bdb189715041
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
10 months agoRemove org.eclipse.jgit.benchmark/.factorypath 04/1174604/1
Matthias Sohn [Fri, 19 Jan 2024 00:27:07 +0000 (01:27 +0100)]
Remove org.eclipse.jgit.benchmark/.factorypath

it's outdated and seems to be unused.

Change-Id: I4ac0f6d6427ee9f76a59296e991e4e03b25bcf05

10 months agoUpdate jmh to 1.37 for org.eclipse.jgit.benchmark 03/1174603/2
Matthias Sohn [Thu, 18 Jan 2024 12:35:01 +0000 (13:35 +0100)]
Update jmh to 1.37 for org.eclipse.jgit.benchmark

and
- fix org.eclipse.jgit.benchmark/.classpath

Change-Id: I66f81228f17ede5732fa43aa693b4cfddb5a71f6

10 months agoMerge branch 'stable-6.7' into stable-6.8
Matthias Sohn [Wed, 10 Jan 2024 22:47:13 +0000 (23:47 +0100)]
Merge branch 'stable-6.7' into stable-6.8

* stable-6.7:
  Silence API warnings
  Make sure ref to prune is in packed refs
  Checkout: better directory handling

Change-Id: Ie8c433e14d025055aa6ce674d6d1220fe1354785

10 months agoMerge branch 'stable-6.6' into stable-6.7 10/1174310/1
Matthias Sohn [Wed, 10 Jan 2024 22:45:20 +0000 (23:45 +0100)]
Merge branch 'stable-6.6' into stable-6.7

* stable-6.6:
  Silence API warnings
  Make sure ref to prune is in packed refs
  Checkout: better directory handling

Change-Id: Id3b01c7a583d45b4e67e3f993006a5646f77a41d

10 months agoMerge branch 'stable-6.5' into stable-6.6 09/1174309/1
Matthias Sohn [Wed, 10 Jan 2024 22:44:46 +0000 (23:44 +0100)]
Merge branch 'stable-6.5' into stable-6.6

* stable-6.5:
  Checkout: better directory handling

Change-Id: I1712191514b8c1b9ea048974376a6765ff7970c7

10 months agoMerge branch 'stable-6.4' into stable-6.5 08/1174308/1
Matthias Sohn [Wed, 10 Jan 2024 22:44:17 +0000 (23:44 +0100)]
Merge branch 'stable-6.4' into stable-6.5

* stable-6.4:
  Checkout: better directory handling

Change-Id: I68e11fb06a354961f4146de51d326b69be5b69d3

10 months agoMerge branch 'stable-6.3' into stable-6.4 07/1174307/1
Matthias Sohn [Wed, 10 Jan 2024 22:43:50 +0000 (23:43 +0100)]
Merge branch 'stable-6.3' into stable-6.4

* stable-6.3:
  Checkout: better directory handling

Change-Id: Ie0fefa8afc07f638ee05a46d272db7b7b0f8d464

10 months agoMerge branch 'stable-6.2' into stable-6.3 06/1174306/1
Matthias Sohn [Wed, 10 Jan 2024 22:43:17 +0000 (23:43 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Checkout: better directory handling

Change-Id: Id27612578f822cabc1a38ad1f8e859ae354045a9

10 months agoMerge branch 'stable-6.1' into stable-6.2 05/1174305/1
Matthias Sohn [Wed, 10 Jan 2024 22:42:47 +0000 (23:42 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Checkout: better directory handling

Change-Id: I2f8e5410f4962d38bc6e822b5cda42df68aef32b

10 months agoMerge branch 'stable-6.0' into stable-6.1
Matthias Sohn [Wed, 10 Jan 2024 22:42:07 +0000 (23:42 +0100)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Checkout: better directory handling

Change-Id: Ide9fb318b5fe413d73d73a19943c6dacdcf07f3d

10 months agoMerge branch 'stable-5.13' into stable-6.0 03/1174303/1
Matthias Sohn [Wed, 10 Jan 2024 19:56:19 +0000 (20:56 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Checkout: better directory handling

Revert commit 170244d05977491271a1cc234583d2e5ba75145d
"Checkout: better directory handling" which is the downport of the
original fix Ie12864c54c9f901a2ccee7caddec73027f353111 which was done
on stable-6.6. Merging this up to stable-6.6 would be a lot of work and
these branches aren't maintained anymore hence revert this change here.
This way the fix is available on stable-5.13 for those who still need
Java 8 and everybody else should upgrade to 6.6.1 or higher.

Change-Id: Iffe50a5e62c6655814265d9cc6c5c2996baa1a31

10 months agoSilence API warnings 02/1174302/1
Matthias Sohn [Mon, 8 Jan 2024 08:33:59 +0000 (09:33 +0100)]
Silence API warnings

Change-Id: I44084c45ed2c5e642021d1de4f37af769e4b317f

11 months agoMake sure ref to prune is in packed refs 31/1173231/9
Fabio Ponciroli [Wed, 6 Dec 2023 13:38:21 +0000 (14:38 +0100)]
Make sure ref to prune is in packed refs

RefDirectory:pack might raise an NPE when deleting loose
refs as final part of the RefDirectory.pack().

This is what the code does:
1) packed ref update: update the list of refs which will be
persisted in packed-refs
2) persit packed-refs: flush on file the refs computed in #1
3) prune loose refs: prune loose refs that have been packed in #2

The code correctly locks the packed-refs file during phases 1 to 3.
However, it makes the wrong assumption of considering
the loose refs set as immutable between phases 1 and 3.

The number and values of loose refs on the filesystem can mutate
at any time whilst the RefDirectory.pack() is in progress.
Assuming the contrary can lead to an NPE when retrieving refs
from the mutable loose refs list during phase #3.

Make sure that the ref is not null before dereferencing its
object-id value.

Bug: jgit-4
Change-Id: I2cd01f8a880f3c6561ad978a389ec2db45b6018b

11 months agoPrepare 6.8.1-SNAPSHOT builds 80/1172680/1
Matthias Sohn [Wed, 29 Nov 2023 15:53:24 +0000 (16:53 +0100)]
Prepare 6.8.1-SNAPSHOT builds

Change-Id: I56458c5345dcd9544868c948e90c9827d25c6850

11 months agoJGit v6.8.0.202311291450-r 78/1172678/1 v6.8.0.202311291450-r
Matthias Sohn [Wed, 29 Nov 2023 14:49:43 +0000 (15:49 +0100)]
JGit v6.8.0.202311291450-r

Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Change-Id: Iecfe3f628cfdc437ee0d63fe52653ef952c8c494

11 months agoRename method parameter to fix warning about hidden field 75/1172675/1
Matthias Sohn [Tue, 28 Nov 2023 23:21:31 +0000 (00:21 +0100)]
Rename method parameter to fix warning about hidden field

Change-Id: Id094ab022f82db0f3eb220052adc0aed1cde2d50

11 months agoFix warnings about empty control flow statements 74/1172674/1
Matthias Sohn [Tue, 28 Nov 2023 23:18:29 +0000 (00:18 +0100)]
Fix warnings about empty control flow statements

Change-Id: If1595ac148edf88a18efdd90c4f40d0ac719caab

11 months agoBitmapIndexImpl: externalize error message 73/1172673/1
Matthias Sohn [Tue, 28 Nov 2023 23:12:55 +0000 (00:12 +0100)]
BitmapIndexImpl: externalize error message

Change-Id: I5189e966aecc57fe7c3e6c3f7f8e6b16917ee27f

11 months agoSuppress not-externalized string warnings 72/1172672/1
Matthias Sohn [Tue, 28 Nov 2023 23:09:52 +0000 (00:09 +0100)]
Suppress not-externalized string warnings

Change-Id: I2a0a588227d451cb175e17eef20ecb6fe9e9ef80

11 months agoSilence API error for new method BitmapIndex#addBitmapLookupListener 71/1172671/1
Matthias Sohn [Tue, 28 Nov 2023 23:04:18 +0000 (00:04 +0100)]
Silence API error for new method BitmapIndex#addBitmapLookupListener

it has an empty default implementation.

Change-Id: I56b16c48992652a4ddaaf4c0435e08452c65749e

11 months agoUpdate Orbit to orbit-aggregation/2023-12 70/1172670/1
Matthias Sohn [Tue, 28 Nov 2023 22:53:29 +0000 (23:53 +0100)]
Update Orbit to orbit-aggregation/2023-12

Change-Id: Ifde28f60461e0a9d7b1278f8f178ceb2c4e1db7a

11 months agoMerge branch 'master' into stable-6.8 68/1172668/1
Matthias Sohn [Mon, 27 Nov 2023 22:34:02 +0000 (23:34 +0100)]
Merge branch 'master' into stable-6.8

* master:
  Adapt to type parameter added in commons-compress 1.25.0
  Improve footer parsing to allow multiline footers.
  Make the tests buildable by bazel test
  BitmapIndex: Add interface to track bitmaps found (or not)
  BitmapWalker: Remove BitmapWalkListener

Change-Id: Id2aeb0acd37bdd68a2f2c9f09f4d442fa40c9dd1

11 months agoMerge "Improve footer parsing to allow multiline footers."
Matthias Sohn [Sun, 26 Nov 2023 18:35:54 +0000 (18:35 +0000)]
Merge "Improve footer parsing to allow multiline footers."

11 months agoMerge "Make the tests buildable by bazel test"
Matthias Sohn [Sat, 25 Nov 2023 19:54:02 +0000 (19:54 +0000)]
Merge "Make the tests buildable by bazel test"

11 months agoAdapt to type parameter added in commons-compress 1.25.0 21/205521/3
Matthias Sohn [Fri, 17 Nov 2023 23:06:01 +0000 (00:06 +0100)]
Adapt to type parameter added in commons-compress 1.25.0

In 1.25.0 commons-compress added a generic type parameter to
ArchiveOutputStream to avoid unchecked/unconfirmed type casts in
subclasses.

Change-Id: Ib4c208fc1fb65f73ea57c5bf723fde71b0d6d9f7

11 months agoImprove footer parsing to allow multiline footers. 64/1172664/2
Kamil Musin [Fri, 24 Nov 2023 14:17:26 +0000 (15:17 +0100)]
Improve footer parsing to allow multiline footers.

According to the https://git-scm.com/docs/git-interpret-trailers the
CGit supports multiline trailers. Subsequent lines of such multiline
trailers have to start with a whitespace.

We also rewrite the original parsing code to make it easier to work
with. The old code had pointers moving both backwards and forwards at
the same time. In the rewritten code we first find the start of the last
paragraph and then do all the parsing.

Since all the getters of the FooterLine return String, I've considered
rewriting the parsing code to operate on strings. However the original
code seems to be written with the idea, that the data is only lazily
copied in getters and no extra allocations should be performed during
original parsing (ex. during RevWalk). The changed code keeps to this
idea.

Bug: Google b/312440626
Change-Id: Ie1e3b17a4a5ab767b771c95f00c283ea6c300220

12 months agoMake the tests buildable by bazel test 62/1172662/5
Kamil Musin [Thu, 23 Nov 2023 10:47:53 +0000 (11:47 +0100)]
Make the tests buildable by bazel test

All the errorprone checkers fail in many existing places of the
codebase, making it impossible to run bazel test. Downgrade all to
":WARN".

MergeToolTest is asserting a wrong error line, but the line seems
different between bazel and mvn test runs. Therefore we don't fix it and
simply run

```
bazel test -- //... -//org.eclipse.jgit.pgm.test:pgm
```

Change-Id: I44913ebc70dcc934cb69481cc3ff9ae0d8059707

12 months agoPrepare 6.8.0-SNAPSHOT builds 86/1172486/1
Matthias Sohn [Wed, 22 Nov 2023 00:41:02 +0000 (01:41 +0100)]
Prepare 6.8.0-SNAPSHOT builds

Change-Id: I89178175549541111cddb88da401899960c0ecac

12 months agoJGit v6.8.0.202311212206-rc1 83/1172483/1 v6.8.0.202311212206-rc1
Matthias Sohn [Tue, 21 Nov 2023 22:05:56 +0000 (23:05 +0100)]
JGit v6.8.0.202311212206-rc1

Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Change-Id: I6a40cdef68538fa769f4525eb2ff1ed4a810f11c

12 months agoMerge branch 'master' into stable-6.8 82/1172482/1
Matthias Sohn [Tue, 21 Nov 2023 22:04:27 +0000 (23:04 +0100)]
Merge branch 'master' into stable-6.8

* master:
  Update repository URLs in CONTRIBUTING.md
  Fix typo in FileUtils.isStaleFileHandle() javadoc
  Fix branch ref exist check
  gpg.bc: Supress errorprone InsecureCryptoUsage
  Adjust javadoc to pass errorprone checks
  Update org.apache.commons:commons-compress to 1.25.0
  Fix annotation of deprecated constant CONFIG_KEY_STREAM_FILE_TRESHOLD
  BitmapWalkListener: Use plain interface with noop instance
  BitmapWalkListener: Add method and rename for commits
  Update bouncycastle to 1.77
  PatchApplier: wrap output's TemporaryBuffer with a CountingOutputStream
  BitmapWalker: announce walked objects via listener interface
  Update jetty to 10.0.18
  SSH: bump org.apache.sshd to 2.11.0
  CommitGraphWriter: Remove unnecesary progress update call

Change-Id: I97574c4801ccafd4e808a1fcf6f8d079ff5709b3

12 months agoBitmapIndex: Add interface to track bitmaps found (or not) 13/1172413/2
Ivan Frade [Mon, 20 Nov 2023 20:01:12 +0000 (12:01 -0800)]
BitmapIndex: Add interface to track bitmaps found (or not)

We want to know what objects had bitmaps in the walk of the
request. We can check their position in the history and evaluate our
bitmap selection algorithm.

Introduce a listener interface to the BitmapIndex to report which
getBitmap() calls returned a bitmap (or not) and a method to the
bitmap index to set the listener.

Change-Id: Iac8fcc1539ddd2dd450e8a1cf5a5b1089679c378

12 months agoBitmapWalker: Remove BitmapWalkListener 12/1172412/2
Ivan Frade [Mon, 20 Nov 2023 18:25:03 +0000 (10:25 -0800)]
BitmapWalker: Remove BitmapWalkListener

We can track bitmaps queries that found a bitmap directly in the
BitmapIndex.

Remove the listener.

Change-Id: I5ad518a58b681bf327fee3ae5c5f6e4449d3da1f

12 months agoUpdate repository URLs in CONTRIBUTING.md 86/1172386/1
Matthias Sohn [Mon, 20 Nov 2023 21:03:32 +0000 (22:03 +0100)]
Update repository URLs in CONTRIBUTING.md

after the move to eclipse.gerrithub.io.

Change-Id: I8e7aac62c991b941def263d3d7585991f1355738

12 months agoMerge "Fix typo in FileUtils.isStaleFileHandle() javadoc"
Matthias Sohn [Fri, 17 Nov 2023 23:45:17 +0000 (18:45 -0500)]
Merge "Fix typo in FileUtils.isStaleFileHandle() javadoc"

12 months agoFix typo in FileUtils.isStaleFileHandle() javadoc 32/205532/2
Dariusz Luksza [Thu, 16 Nov 2023 15:52:38 +0000 (15:52 +0000)]
Fix typo in FileUtils.isStaleFileHandle() javadoc

Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
Change-Id: Iac431bbcb00f0a1fa36e2ba4af5fe33fcee69e04

12 months agoFix branch ref exist check 74/204974/3
florian.signoret [Mon, 16 Oct 2023 14:08:14 +0000 (16:08 +0200)]
Fix branch ref exist check

When a tag with the same name as the branch exists, the branch creation
process should work too. We should detect that the branch already
exists, and allow to force create it when the force option is used.

Bug: 582538
Change-Id: I3b350d03be8edcde10e97b2318343240ca896cb0

12 months agogpg.bc: Supress errorprone InsecureCryptoUsage 45/205545/1
Ivan Frade [Fri, 17 Nov 2023 18:14:26 +0000 (10:14 -0800)]
gpg.bc: Supress errorprone InsecureCryptoUsage

From errorprone doc: "Dynamically constructed transformation strings
are also flagged, as they may conceal an instance of ECB mode."

https://errorprone.info/bugpattern/InsecureCryptoUsage

Silence the message as a quick relief.

Change-Id: I348f0fff0e3b24ce1f11917e849b4095b186d1f0

12 months agoAdjust javadoc to pass errorprone checks 44/205544/1
Ivan Frade [Fri, 17 Nov 2023 18:11:17 +0000 (10:11 -0800)]
Adjust javadoc to pass errorprone checks

bazel build //org.eclipse.jgit.test:all doesn't build due to
errorprone errors. This leds to disabling the checks and find the
errors later in the jenkins builder.

Fix javadoc errors reported by errorprone. This doesn't fix completely
the build but it is a step towards it.

Change-Id: Ic4ec93a2d71d4628bf3a05277c60157881156393

12 months agoMerge "Update org.apache.commons:commons-compress to 1.25.0"
Matthias Sohn [Fri, 17 Nov 2023 07:34:54 +0000 (02:34 -0500)]
Merge "Update org.apache.commons:commons-compress to 1.25.0"

12 months agoMerge "Fix annotation of deprecated constant CONFIG_KEY_STREAM_FILE_TRESHOLD"
Matthias Sohn [Fri, 17 Nov 2023 00:41:46 +0000 (19:41 -0500)]
Merge "Fix annotation of deprecated constant CONFIG_KEY_STREAM_FILE_TRESHOLD"

12 months agoMerge "BitmapWalkListener: Use plain interface with noop instance"
Ivan Frade [Fri, 17 Nov 2023 00:22:16 +0000 (19:22 -0500)]
Merge "BitmapWalkListener: Use plain interface with noop instance"

12 months agoUpdate org.apache.commons:commons-compress to 1.25.0 16/205516/1
Matthias Sohn [Fri, 17 Nov 2023 00:05:25 +0000 (01:05 +0100)]
Update org.apache.commons:commons-compress to 1.25.0

Change-Id: Ic9c6910853ad00075501aa3e03888fefbe634bf6

12 months agoFix annotation of deprecated constant CONFIG_KEY_STREAM_FILE_TRESHOLD 10/205510/2
Matthias Sohn [Wed, 15 Nov 2023 23:24:29 +0000 (00:24 +0100)]
Fix annotation of deprecated constant CONFIG_KEY_STREAM_FILE_TRESHOLD

Change-Id: I71f067199c63aa1407f543f6d40ef05b928e9f95

12 months agoMerge "Update bouncycastle to 1.77"
Matthias Sohn [Fri, 17 Nov 2023 00:06:15 +0000 (19:06 -0500)]
Merge "Update bouncycastle to 1.77"

12 months agoBitmapWalkListener: Use plain interface with noop instance 39/205539/4
Ivan Frade [Thu, 16 Nov 2023 23:12:47 +0000 (15:12 -0800)]
BitmapWalkListener: Use plain interface with noop instance

In this new interface default methods are useful only to instantiate
noop instances. We rather reuse the same noop instance and save the
"default" to add backward compatible methods to existing interfaces.

Make the methods regular interface methods and provide a noop
instance.

Change-Id: Ie84ff17c8e9f16837245751739ee8c99463e76ee

12 months agoBitmapWalkListener: Add method and rename for commits 35/205535/2
Ivan Frade [Thu, 16 Nov 2023 18:46:07 +0000 (10:46 -0800)]
BitmapWalkListener: Add method and rename for commits

During the walk, the commit can be either
1. already in the walk bitmap
2. unvisited so far with bitmap in the bitmap index
3. unvisited so far without bitmap in the bitmap index

Expose these three states in the interface. This makes the interface
easier to explain: it reports the commits found during the walk.

As it is all about commits, rename the methods to onCommit***.

Change-Id: I661f303eb22d3e735b0e439f16df7ace612376d9

12 months agoMerge "CommitGraphWriter: Remove unnecesary progress update call"
Ivan Frade [Thu, 16 Nov 2023 19:53:13 +0000 (14:53 -0500)]
Merge "CommitGraphWriter: Remove unnecesary progress update call"

12 months agoUpdate bouncycastle to 1.77 85/205485/2
Matthias Sohn [Wed, 15 Nov 2023 20:32:20 +0000 (21:32 +0100)]
Update bouncycastle to 1.77

Change-Id: I2dc011247ace2eeea8c46587cae55a39be086f36

12 months agoMerge "PatchApplier: wrap output's TemporaryBuffer with a CountingOutputStream"
Jonathan Nieder [Thu, 16 Nov 2023 10:26:55 +0000 (05:26 -0500)]
Merge "PatchApplier: wrap output's TemporaryBuffer with a CountingOutputStream"

12 months agoPatchApplier: wrap output's TemporaryBuffer with a CountingOutputStream 72/205472/7
Nitzan Gur-Furman [Wed, 15 Nov 2023 20:04:00 +0000 (21:04 +0100)]
PatchApplier: wrap output's TemporaryBuffer with a CountingOutputStream

The documentation for TemporaryBuffer::length says:
"The length is only accurate after {@link #close()} has been invoked".
However, we need to have the stream open while accessing the length.

This prevents patches on large files to be applied correctly, as the
result get trimmed.

Bug: Google b/309500446
Change-Id: Ic1540f6d0044088f3b46f1fad5f6a28ec254b711

12 months agoMerge "BitmapWalker: announce walked objects via listener interface"
Ivan Frade [Wed, 15 Nov 2023 23:33:30 +0000 (18:33 -0500)]
Merge "BitmapWalker: announce walked objects via listener interface"

12 months agoBitmapWalker: announce walked objects via listener interface 03/205503/3
Ivan Frade [Wed, 15 Nov 2023 18:25:22 +0000 (10:25 -0800)]
BitmapWalker: announce walked objects via listener interface

We want to know what objects had a bitmap in the walk, to see where do
they sit in the commit history and evaluate our bitmap selection
algorithm.

Add a listener interface to the bitmap walker announcing the objects
walked and whether they had bitmap.

Change-Id: I956fe2ad927a500710d2cbe78ecd4d26f178c266

12 months agoMerge branch 'stable-6.8' 07/205507/1
Matthias Sohn [Wed, 15 Nov 2023 22:43:53 +0000 (23:43 +0100)]
Merge branch 'stable-6.8'

* stable-6.8:
  Prepare 6.8.0-SNAPSHOT builds
  JGit v6.8.0.202311151710-m2

Change-Id: I26603b974f0ccd5a6da3801988d925d73a692c0e

12 months agoPrepare 6.8.0-SNAPSHOT builds 06/205506/1
Matthias Sohn [Wed, 15 Nov 2023 22:42:56 +0000 (23:42 +0100)]
Prepare 6.8.0-SNAPSHOT builds

Change-Id: Id11a260db84aea6743f2e6edec8b8010693aab42

12 months agoUpdate jetty to 10.0.18 80/205480/1
Matthias Sohn [Wed, 15 Nov 2023 21:20:29 +0000 (22:20 +0100)]
Update jetty to 10.0.18

Change-Id: I34c9f7c062400bb69849812d57390dd2e7b04cac

12 months agoSSH: bump org.apache.sshd to 2.11.0 88/205088/2
Thomas Wolf [Sat, 21 Oct 2023 13:15:34 +0000 (15:15 +0200)]
SSH: bump org.apache.sshd to 2.11.0

Update maven build, bazel build, and target platform.

Also remove a file in a ./bin directory that got committed by mistake
in commit f5f4bf0ad.

Change-Id: Ia653c71643f8fad290874d723dacdafbef25c13f
Signed-off-by: Thomas Wolf <twolf@apache.org>
12 months agoJGit v6.8.0.202311151710-m2 78/205478/1 v6.8.0.202311151710-m2
Matthias Sohn [Wed, 15 Nov 2023 17:11:07 +0000 (18:11 +0100)]
JGit v6.8.0.202311151710-m2

Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Change-Id: I9d06bb08fc1f9a2a08d4bc5a4459ec7e7e8c1be4

12 months agoMerge branch 'master' into stable-6.8 76/205476/1
Matthias Sohn [Wed, 15 Nov 2023 17:05:54 +0000 (18:05 +0100)]
Merge branch 'master' into stable-6.8

* master: (42 commits)
  Fix typo in constant name CONFIG_KEY_STREAM_FILE_TRESHOLD
  Simplify StringUtils#commonPrefix
  Optimize RefDirectory.getRefsByPrefix(String...)
  Use try-with-resource to ensure UploadPack is closed
  Fix hiding field warning
  Fix warning for empty code blocks
  Fix boxing warnings
  errorprone: remove unnecessary parentheses
  Update mockito to 5.7.0 and bytebuddy to 1.14.9
  Enable Maven reproducible builds
  Upgrade bazlets to the latest revision
  Revert "Optimise Git protocol v2 `ref-prefix` scanning"
  Document GIT_TRACE_PERFORMANCE to show timings
  config-options.md: fix sort order
  ComboBitset: Add Javadoc
  CommitGraphWriter: Add progress monitor to bloom filter computation
  CommitGraphWriter: Use ProgressMonitor from the OutputStream
  CommitGraphWriter: Unnest generation-number progress
  Optimise Git protocol v2 `ref-prefix` scanning
  UploadPackTest: Cover using wanted-refs as advertised set
  ...

Change-Id: I5398f2342eac83ebdc823befe8e7de0cf8ba6d5b

12 months agoFix typo in constant name CONFIG_KEY_STREAM_FILE_TRESHOLD 73/205473/1
Matthias Sohn [Wed, 15 Nov 2023 15:02:43 +0000 (16:02 +0100)]
Fix typo in constant name CONFIG_KEY_STREAM_FILE_TRESHOLD

Since it's part of the API deprecate the wrong spelling and add the
correct one with the same value.

Change-Id: I0f6ea95a5e66c9e80142eb6d40eb7ec3a7aaf8e2

12 months agoSimplify StringUtils#commonPrefix 66/205466/2
Nasser Grainawi [Mon, 13 Nov 2023 23:12:24 +0000 (00:12 +0100)]
Simplify StringUtils#commonPrefix

By first checking for null-ness and then for the number of strings to
compare we can get rid of a redundant null check.

Change-Id: I0d9a088352c6c1ffea12bc2cded2c63e5293a8a7

12 months agoOptimize RefDirectory.getRefsByPrefix(String...) 87/205387/4
Dariusz Luksza [Thu, 9 Nov 2023 11:18:38 +0000 (11:18 +0000)]
Optimize RefDirectory.getRefsByPrefix(String...)

Currently for file-based repositories JGit will go over all refs in the
repository forach `ref-prefix` listed in the `ls-refs` command in git
protocol v2 request.

Native git, uses a different approach, where all refs are read once and
then for each ref, all `ref-prefix` filter values are checked in one
pass.

This change implements this approach in JGit only in the `RefDirectory`
backend. And makes `ref-prefix` filtering ~40% faster for repositories
with packed refs.

Different implementations were tested on a synthetic file repository
with 10k refs in `refs/heads/` and `290k` in `refs/changes`. Before
testing `git pack-refs` command was executed. All results are in
seconds.

Current Impl:               39.340   37.093   35.996
Nested for loops:           25.077   24.742   24.748
Nested streams:             24.827   24.890   27.525
Parallel stream + stream:   23.357   23.318   23.174
Nested parallel streams:    23.490   23.318   23.317
Stream + for loop:          23.147   23.210   23.126
Parallel stream + for loop: 23.317   23.423   22.847

The elapsed time was measured around `getRefByPrefix` call in
`Uploadapack.getFilteredRefs(Collection<String>)` (around lines 952 and
954). For testing a modified version of
`UploadPackTest.testV2LsRefsRefPrefix()` was used. The modifications
here included:
  * shadowing protected `repo` variable with `FileRepository` pointing
    to the synthetic repo with 300k refs described above,
  * mimicking the git client clone request by adding `ref-prefix HEAD`,
    `ref-prefix refs/heads/` and `ref-prefix refs/tags/`

Based on the above results, the implementation with parallel stream and
stream was selected.

Bug: 578550
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
Change-Id: I6416846c074b611ff6ec9d351dbafcfbcaf68e66

12 months agoCommitGraphWriter: Remove unnecesary progress update call 02/205402/1
Ivan Frade [Thu, 9 Nov 2023 22:45:32 +0000 (14:45 -0800)]
CommitGraphWriter: Remove unnecesary progress update call

Change [1] reduced the scope of the "writing commit graph" monitoring
task. This left some monitor#update() calls out of any task. When out
of a task, the #update call is a noop.

Delete this update calls as they are noops and misleading.

The affected chunks are usually small and quick to write, so probably
they don't need progress monitoring.

[1] https://git.eclipse.org/r/c/jgit/jgit/+/205339

Change-Id: I74d94e6e44e58816937dc8a84e5a10b340e54e0b

12 months agoMerge changes I0d10aeac,I9aced1b7,Ied394859,Ibb61f63f,I20498746, ...
Matthias Sohn [Fri, 10 Nov 2023 08:03:36 +0000 (03:03 -0500)]
Merge changes I0d10aeac,I9aced1b7,Ied394859,Ibb61f63f,I20498746, ...

* changes:
  Use try-with-resource to ensure UploadPack is closed
  Fix hiding field warning
  Fix warning for empty code blocks
  Fix boxing warnings
  errorprone: remove unnecessary parentheses
  Update mockito to 5.7.0 and bytebuddy to 1.14.9
  Enable Maven reproducible builds
  Upgrade bazlets to the latest revision

12 months agoMerge "Revert "Optimise Git protocol v2 `ref-prefix` scanning""
Ivan Frade [Wed, 8 Nov 2023 23:15:51 +0000 (18:15 -0500)]
Merge "Revert "Optimise Git protocol v2 `ref-prefix` scanning""

12 months agoUse try-with-resource to ensure UploadPack is closed 60/205360/1
Matthias Sohn [Wed, 8 Nov 2023 23:06:19 +0000 (00:06 +0100)]
Use try-with-resource to ensure UploadPack is closed

Change-Id: I0d10aeac959a49b3bf2e83b0c104699d1d21f5e9

12 months agoFix hiding field warning 59/205359/1
Matthias Sohn [Wed, 8 Nov 2023 22:41:16 +0000 (23:41 +0100)]
Fix hiding field warning

Change-Id: I9aced1b711901918667555a4cfff76992024e59c

12 months agoFix warning for empty code blocks 58/205358/1
Matthias Sohn [Wed, 8 Nov 2023 22:39:35 +0000 (23:39 +0100)]
Fix warning for empty code blocks

Change-Id: Ied394859e8c76bb1a2362d31962ab862b26b279f

12 months agoFix boxing warnings 57/205357/1
Matthias Sohn [Wed, 8 Nov 2023 22:38:09 +0000 (23:38 +0100)]
Fix boxing warnings

Change-Id: Ibb61f63f17e909ee0e6a781c9418f7c1ac2c7cd7

12 months agoerrorprone: remove unnecessary parentheses 56/205356/1
Matthias Sohn [Wed, 8 Nov 2023 22:36:54 +0000 (23:36 +0100)]
errorprone: remove unnecessary parentheses

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

Change-Id: I204987469d478c9cc887ac66c9ffc84c9977c400

12 months agoUpdate mockito to 5.7.0 and bytebuddy to 1.14.9 16/205216/3
Matthias Sohn [Tue, 31 Oct 2023 00:13:50 +0000 (01:13 +0100)]
Update mockito to 5.7.0 and bytebuddy to 1.14.9

Change-Id: I7c93847054050a0af0d2c16e724e5755f9fa33bf

12 months agoEnable Maven reproducible builds 85/204785/10
Matthias Sohn [Thu, 5 Oct 2023 23:10:40 +0000 (01:10 +0200)]
Enable Maven reproducible builds

- configure Maven to run build reproducibly [1]
- use UTC timestamp of checked out commit as build timestamp
- add git-describe, git-commit-id, git-commit-id, git-tags,
  git-remote-origin-url to MANIFEST.MF files
- configure cyclonedx-maven-plugin to also use UTC timestamp of
  checked out commit
- for packaging build use tycho-buildtimestamp-jgit [2] to ensure
  version uses the timestamp of the last commit
- SBOMs are not reproducible by design [3] they should have a build
  timestamp matching the time when the build was executed and a serial
  number which is a unique UUID per build run. Hence exclude them from
  comparison [4].
- Use gmavenplus-plugin to format build timestamps. Maven expects
  build timestamp in ISO-8601 format, to replace the qualifier in
  versions the timestamp format must be compatible with rules for OSGi
  version numbers. Didn't find a way to read the properties set by the
  git-commit-id-maven-plugin from another plugin. Hence use JGit in a
  groovy script to get the commit time of the current HEAD and provide
  it in these two formats.

TODO: packaging build (features and p2 repository) is not yet binary
reproducible since that's not yet supported by Tycho [5], artefacts have
reproducible version numbers but file lastModified timestamps are not
yet reproducible.

Test plan for Maven build:
- build using
  mvn clean install"
- verify second build is reproducible:
  mvn -T1 clean verify artifact:compare
  verification seems not to be thread-safe, hence run it with a single
  thread using option -T1

For packaging build (still fails due to non-reproducible file
timestamps):
- build using
  mvn -f org.eclipse.jgit.packaging/pom.xml clean install
- verify second build is reproducible:
  mvn -T1 -f org.eclipse.jgit.packaging/pom.xml clean verify artifact:compare

[1] https://maven.apache.org/guides/mini/guide-reproducible-builds.html
[2] https://wiki.eclipse.org/Tycho/Reproducible_Version_Qualifiers
[3] https://github.com/CycloneDX/cyclonedx-maven-plugin/issues/84
[4] https://maven.apache.org/plugins/maven-artifact-plugin/compare-mojo.html
[5] https://github.com/eclipse-tycho/tycho/issues/233

Change-Id: I0202f55a1b6ae0edd922cfef638beb39d2ce9417

12 months agoUpgrade bazlets to the latest revision 83/204983/2
David Ostrovsky [Tue, 17 Oct 2023 12:24:46 +0000 (14:24 +0200)]
Upgrade bazlets to the latest revision

Includes:
junit.bzl: Suppress default package warning flagged by error prone

Change-Id: Id8e8dd7cca7264328c4121ac3da4d9d5e8e407de

12 months agoRevert "Optimise Git protocol v2 `ref-prefix` scanning" 56/205256/1
Ivan Frade [Wed, 8 Nov 2023 22:48:08 +0000 (17:48 -0500)]
Revert "Optimise Git protocol v2 `ref-prefix` scanning"

This reverts commit 3937300f3eb4dd557ec2d195f21793f737d6cb4e.

Reason for revert: This kills performance on the DFS side, that relies on loading the minimal amount of refs and reftables for quick prefix searches.

Reverting as a safe option to keep master in good performance until we decide how to reintroduce this change.

Change-Id: I7b1a3f900d9c78ce95cf0972abb50b6becfe3bb1

12 months agoMerge "ComboBitset: Add Javadoc"
Matthias Sohn [Wed, 8 Nov 2023 07:49:06 +0000 (02:49 -0500)]
Merge "ComboBitset: Add Javadoc"

12 months agoDocument GIT_TRACE_PERFORMANCE to show timings 54/205354/1
Matthias Sohn [Wed, 8 Nov 2023 01:49:23 +0000 (02:49 +0100)]
Document GIT_TRACE_PERFORMANCE to show timings

Change-Id: I5a39b072c50e64a2d940680ed85866edfe9d0d28

12 months agoconfig-options.md: fix sort order 53/205353/1
Matthias Sohn [Wed, 8 Nov 2023 01:41:28 +0000 (02:41 +0100)]
config-options.md: fix sort order

Change-Id: Idf233e7b6ca41de9460b41b3d24c84f9e85472d6

12 months agoComboBitset: Add Javadoc 43/203443/3
Han-Wen Nienhuys [Mon, 31 Jul 2023 18:02:56 +0000 (20:02 +0200)]
ComboBitset: Add Javadoc

Change-Id: I799991327cadf646329eacbac40d41cb1b3391ad

12 months agoCommitGraphWriter: Add progress monitor to bloom filter computation 44/205344/1
Ivan Frade [Tue, 7 Nov 2023 22:30:15 +0000 (14:30 -0800)]
CommitGraphWriter: Add progress monitor to bloom filter computation

Bloom filter computation can be an expensive process and right now it
is invisible to the user.

Report progress while calculating bloom filters.

Log of GC with bloom filter enabled:

Computing commit-graph path bloom filters: 100% (9551/9551)
Computing commit-graph generation numbers: 100% (9551/9551)
Writing out commit-graph: 100% (9551/9551)

Change-Id: Ife65e63ac2c37d064d5f049a366cbb52c3ef6798

12 months agoCommitGraphWriter: Use ProgressMonitor from the OutputStream 43/205343/1
Ivan Frade [Tue, 7 Nov 2023 22:00:05 +0000 (14:00 -0800)]
CommitGraphWriter: Use ProgressMonitor from the OutputStream

The same progress monitor is passed around as parameter and inside the
output stream. The functions use one to start tasks and another to
report progress, which is confusing. The stream needs the monitor to
check cancellations so we cannot remove it from there.

Make all code take the monitor from the stream.

Change-Id: Id3cb9c1cb0bd47318b46ef934a9d4037341e25a7

12 months agoCommitGraphWriter: Unnest generation-number progress 39/205339/2
Ivan Frade [Tue, 7 Nov 2023 19:36:51 +0000 (11:36 -0800)]
CommitGraphWriter: Unnest generation-number progress

The ProgressMonitor task to track the calculation of generation
numbers is nested inside the task that follows the writing of all
lines in the commit-graph. ProgressMonitor doesn't support nested
tasks and this confuses the counting.

Move the start/end of the "writing commit graph" task to the
writeCommitData section, after calculating the generation
numbers. Make that task track by commits instead of by lines.

Moving the start/end of the progress task to the chunk-writing
functions is clearer and easier to extend.

Logging of GC before:
Writing out commit-graph in 3 passes:  51% ( 9807/19358)
Computing commit-graph generation numbers: 100% (9551/9551)

Logging of GC after:
Computing commit-graph generation numbers: 100% (9551/9551)
Writing out commit-graph: 100% (9551/9551)

Change-Id: I87d69c06c9a3c7e75be12b6f0d1a63b5924e298a

12 months agoOptimise Git protocol v2 `ref-prefix` scanning 10/204910/13
Dariusz Luksza [Fri, 3 Nov 2023 11:52:03 +0000 (11:52 +0000)]
Optimise Git protocol v2 `ref-prefix` scanning

Currenty JGit will go over all refs in the repository for each
`ref-prefix`. This means that refs will be read multiple
times, which leads to subpar performance.

Native git, uses a different approach, where all refs are read once
and then for each ref, all `ref-prefix` filter values are checked in
one pass.

This change implements this approach in JGit. And makes `ref-prefix`
filtering ~28% faster for a repository with fully packed refs
and ~5% when RefTable is used instead of refdir.

Different implementations were tested on a synthetic file repository
with 300k refs. Different implementations were tested for unpacked and
fully packed refs (results are in seconds).

Unpacked refs:
 Current Impl:               54.838   57.234   56.138
 Nested for loops:           36.094   37.025   36.502
 Nested stream's:            36.154   35.989   37.262
 Parallel stream + stream:   36.923   37.272   35.362
 Nested parallel stream's:   35.512   38.395   36.745
 Stream + for loop:          34.950   36.164   37.191
 Parallel stream + for loop: 37.695   35.511   35.378

Packed refs:
 Current Impl:               39.713   39.954   38.653
 Nested for loops:           29.891   29.753   29.377
 Nested stream's:            30.340   29.637   30.412
 Parallel stream + stream:   28.653   28.254   29.138
 Nested parallel stream's:   29.942   28.850   31.030
 Stream + for loop:          29.405   29.576   30.539
 Parallel stream + for loop: 29.012   29.215   29.380

RefTable:
 Current Impl:               0.273   0.294   0.330
 Nested for loops:           0.252   0.169   0.215
 Nested stream's:            0.252   0.228   0.213
 Parallel stream + stream:   0.233   0.259   0.247
 Nested parallel stream's:   0.416   0.309   0.340
 Stream + for loop:          0.224   0.247   0.242
 Parallel stream + for loop: 0.347   0.246   0.346

The elapsed time was measured around `getRefsByPrefix` call in
`UploadPack.getFilteredRefs(Collection<String>)` (around lines 952 and
954).

Based on the above results, the implementation with parallel stream and
stream was selected.

Bug: 578550
Change-Id: Iac3a3aacf897b87b3448c1d528cdac64ad312199
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
12 months agoUploadPackTest: Cover using wanted-refs as advertised set 81/205181/2
Ivan Frade [Tue, 24 Oct 2023 16:37:13 +0000 (09:37 -0700)]
UploadPackTest: Cover using wanted-refs as advertised set

Parent change introduced using "wanted-refs" as advertised set during
fetchV2, but it tested only a request without wantIds (only
wanted-refs).

Add a second where the request has wanted-refs AND wantId (which
disables the optimization). Change the test to measure the amount of
refs considered advertised, instead of relying in calls to the
refdb.

Change-Id: Id64ec933fd737bae1bfd429c7b8cc05b51a83870

12 months agoUploadPack: use want-refs as advertised set in fetch v2 30/193330/12
Patrick Hiesel [Fri, 13 May 2022 11:49:02 +0000 (13:49 +0200)]
UploadPack: use want-refs as advertised set in fetch v2

Protocol v2 introduced refs-in-wants and ls-remote with
prefixes. UploadPack already uses prefixes provided by the client
during a v2 ref advertisement (ls-refs). However, when the client
consequently sends another request to fetch a previously advertised
ref (with want-ref lines), the server uses the whole set of advertised
refs to compute reachability.

In repos with many refs, this slows down the reachability checks
setting up and walking through unnecessary refs. For gerrit it can
also break valid requests because in gerrit "all" means "recent" and
the wanted-ref could fall out of the "recent" range when reloading all
refs at fetch time.

Treat wanted-refs like a ref-prefix when calculating the advertised
refs on v2 fetch command. Less refs means a faster setup and less walk
for the reachability checks. Note that wanted-refs filters only over
the refs visible to the user, so this doesn't give any extra
visibility to the caller.

If the request contains also "want <oid>" lines, we cannot use this
optimization. Those objects could be reachable from any visible
branch, not necessarily in the wanted-refs.

Google-Bug: b/122888978
Change-Id: I2a4ae171d4fc5d4cb30b020cb073ad23dd5a66c4