]> source.dussan.org Git - jgit.git/log
jgit.git
9 months agoAdd SystemReader.Delegate to reduce boiler-plate code needed to subclass 71/1177071/2
Matthias Sohn [Tue, 20 Feb 2024 00:12:55 +0000 (01:12 +0100)]
Add SystemReader.Delegate to reduce boiler-plate code needed to subclass

Original implementation by Han-Wen Nienhuys in Gerrit [1].

[1] https://gerrit-review.googlesource.com/c/gerrit/+/235169

Bug: jgit-24
Change-Id: I745f8c1c07de013a68168b91c2d9962d530d07bf

9 months agostorage.file: Do not throw NSFE when deleting tmp files 70/205470/2
Nasser Grainawi [Tue, 14 Nov 2023 20:55:48 +0000 (13:55 -0700)]
storage.file: Do not throw NSFE when deleting tmp files

If we try to delete a tmp file and it already doesn't exist, then
there's no problem and we don't need to throw an exception. This is
especially true for these existing cases using FileUtils.RETRY because
any missing files on retries are already considered successes. Not
throwing the exception quiets some logs and improves overall exception
handling.

Change-Id: Ia6e06ba042c5920d5cd9f8db2e1d829affa3d796
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
9 months agoFS.detectSymlinkSupport: fix a race 54/1174154/4
Motiejus Jakštys [Thu, 28 Dec 2023 14:33:28 +0000 (16:33 +0200)]
FS.detectSymlinkSupport: fix a race

When multiple JGit clients are instantiated concurrently, they may try
to create the same symlink at the same time. When that happens, the
second thread will return an error (because the symlink already exists)
and that `FS` instance will think that symlinks are not supported,
causing havoc.

Change-Id: I362b933ff63a1471e3a5d70cc8c35eb2f25cc0dd
Signed-off-by: Motiejus Jakštys <motiejus@jakstys.lt>
9 months agoMerge changes I8e577a23,Ic8e8b288
Matthias Sohn [Mon, 19 Feb 2024 23:13:18 +0000 (23:13 +0000)]
Merge changes I8e577a23,Ic8e8b288

* changes:
  Errorprone EscapedEntity: Do not use HTML entities inside @code javadoc
  ChangedPathFilter: Suppress warning about backing array (errorprone)

9 months agoMerge changes I9225d6a3,I9cf093ca,Id5a80635
Matthias Sohn [Mon, 19 Feb 2024 23:02:20 +0000 (23:02 +0000)]
Merge changes I9225d6a3,I9cf093ca,Id5a80635

* changes:
  RawParseUtils.nextLfSkippingSplitLines: fulfil contract as stated
  [gpg] Refactor the GpgSignatureVerifier
  RawParseUtils: utility method to get a header value

9 months agoMerge branch 'stable-6.8' into master 29/1176929/1
Dariusz Luksza [Thu, 15 Feb 2024 10:48:55 +0000 (10:48 +0000)]
Merge branch 'stable-6.8' into master

* stable-6.8:
  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: I1d65c41292779dd5f8f46bc0adefbfc9a62ba2ce

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.8' into master 48/1176748/1
Dariusz Luksza [Mon, 12 Feb 2024 10:14:29 +0000 (10:14 +0000)]
Merge branch 'stable-6.8' into master

* stable-6.8:
  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: Icae170f85d71e65c308078648ae85dfc8308176d

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 agoErrorprone EscapedEntity: Do not use HTML entities inside @code javadoc 53/1176853/1
Ivan Frade [Fri, 9 Feb 2024 17:31:57 +0000 (09:31 -0800)]
Errorprone EscapedEntity: Do not use HTML entities inside @code javadoc

Change-Id: I8e577a23e7fbe22a3024ad62144e7f19eec465c3

9 months agoChangedPathFilter: Suppress warning about backing array (errorprone) 52/1176852/1
Ivan Frade [Fri, 9 Feb 2024 17:18:37 +0000 (09:18 -0800)]
ChangedPathFilter: Suppress warning about backing array (errorprone)

Errorprone warns about direct access to the underlying array.

That is the intention of this code, and those ByteBuffers are created
with ByteBuffer#wrap() so it should be safe.

Change-Id: Ic8e8b288f08ac794cf7f09dfccfefcba0a4685bf

9 months agoPackWriterBitmapPreparer: Do not generate bitmaps for excessive branch tips. 70/1176570/8
jackdt@google.com [Wed, 7 Feb 2024 19:12:46 +0000 (19:12 +0000)]
PackWriterBitmapPreparer: Do not generate bitmaps for excessive branch tips.

In https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1174407, I changed the bitmap selection algorithm to cap the number of branches included in the bitmap.

There was a bug in that change. When the selection algorithm iterates
over the commits in a branch B, it automatically includes a bitmap for
the tip of any other branch C that happens to be on B. So even though we never iterated over C, we would still index the tip commit of C.

Keep a list of the "excessive" branch tips and check that the commit is not in there before generating a bitmap. We only skip tips that would be selected as a result of being a tip.  If it would be selected for some other reason (e.g. it is one of the first 100 commits in master) then it is not skipped.

Change-Id: Ic8b4f82e816eac649a47c8918a41ed4ff0d877cd

9 months agoDon't use localized String during JVM shutdown 56/1176056/1
Matthias Sohn [Tue, 6 Feb 2024 09:23:37 +0000 (10:23 +0100)]
Don't use localized String during JVM shutdown

During shutdown the JGitText class may already be unloaded causing
NoClassDefFoundError.

Bug: jgit-17
Change-Id: I657b5a508efc8b3778be346d640f4e4d69abd5c5

9 months agoRawParseUtils.nextLfSkippingSplitLines: fulfil contract as stated 28/1176328/1
Thomas Wolf [Thu, 1 Feb 2024 18:24:15 +0000 (19:24 +0100)]
RawParseUtils.nextLfSkippingSplitLines: fulfil contract as stated

If there is no newline after the last header, the method is supposed to
return the buffer length, but it returned buffer.length - 1.

Change-Id: I9225d6a35a002244c246bc8781ceaf4369fb9a60

9 months ago[gpg] Refactor the GpgSignatureVerifier 27/1176327/1
Thomas Wolf [Thu, 1 Feb 2024 18:09:50 +0000 (19:09 +0100)]
[gpg] Refactor the GpgSignatureVerifier

Add a new method verify(GpgConfig, byte[], byte[]) and deprecate the
existing verify(byte[], byte[]). Some implementations of the interface
may need the GpgConfig.

Factor out extracting the raw armored signature from commits or tags
into an abstract AbstractGpgSignatureVerifier class so that different
implementations don't have to re-implement that bit. Call the new verify
method, passing along the GpgConfig.

This makes the GPG interfaces more versatile and facilitates
implementing an alternate GpgSignatureVerifier.

Change-Id: I9cf093caa9fdebede801d665f2591cd9b275e1fd

9 months agoRawParseUtils: utility method to get a header value 26/1176326/1
Thomas Wolf [Fri, 19 Jan 2024 16:37:43 +0000 (17:37 +0100)]
RawParseUtils: utility method to get a header value

The new method takes care of removing the leading blanks on continuation
lines in multi-line headers.

Change-Id: Id5a8063512a2abc3177c104d6ba8fa50d0dc6352

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)

9 months agoRebaseCommand: fix stopping on root commit conflicts 94/1174394/2
Thomas Wolf [Wed, 10 Jan 2024 17:36:50 +0000 (18:36 +0100)]
RebaseCommand: fix stopping on root commit conflicts

If rebasing runs into a conflict when applying a root commit from an
independent branch, there is no parent commit. Write an empty patch
file in that case like C git does.

Bug: jgit-6
Change-Id: I315313673d2abf29639d7d96c958d599961ba276
Signed-off-by: Thomas Wolf <twolf@apache.org>
9 months agoImprove handling of NFS stale handle errors 53/205553/5
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

9 months agoFix handling of missing pack index file 52/205552/4
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>
9 months agoCherryPick: add ability to customise cherry-picked commit message 14/1172614/7
Dmitrii Naumenko [Wed, 22 Nov 2023 18:11:17 +0000 (19:11 +0100)]
CherryPick: add ability to customise cherry-picked commit message

Originally I wanted to support a feature similar to `-x` options from
https://git-scm.com/docs/git-cherry-pick#_options.
The idea was to append original commit hash in this format:
```
my original commit message

(cherry picked from commit 75355897dc28e9975afed028c1a6d8c6b97b2a3c)
```
This can be useful information in some integrations.
I decided to make it in a more generic way
and pass custom `CherryPickCommitMessageProvider` implementation.
One of the two default implementations can append original commit hash

Change-Id: Id664e8438b0b76c5cb9b58113887eec04aa6f611

10 months agoRawParseUtils: Add missing @since tag for new API method 54/1176054/1
Matthias Sohn [Mon, 22 Jan 2024 21:43:31 +0000 (22:43 +0100)]
RawParseUtils: Add missing @since tag for new API method

This method was introduced in 8116f66b9c.

Change-Id: Ifd3341a03464a1d7164c176cf3a6cf83f45a2747

10 months agoSilence API warning for new constant 53/1176053/1
Matthias Sohn [Mon, 22 Jan 2024 21:40:52 +0000 (22:40 +0100)]
Silence API warning for new constant

and remove unused API problem filters.

Change-Id: Ia6f4fcc98b786e3e4b65f9e42cc60bbf6ca7c289

10 months ago[ssh] Bump Apache MINA sshd 2.11.0 -> 2.12.0 76/1174776/2
Thomas Wolf [Fri, 12 Jan 2024 20:23:47 +0000 (21:23 +0100)]
[ssh] Bump Apache MINA sshd 2.11.0 -> 2.12.0

This includes the upstream fix for CVE-2023-48795[1] ("strict KEX"
protocol extension mitigating the "Terrapin attack"[2]) in JGit.

[1] https://nvd.nist.gov/vuln/detail/CVE-2023-48795
[2] https://www.terrapin-attack.com/

Bug: jgit-16
Change-Id: Ie9aa5b903ea6795bd1511afea0bebdb537b56148
Signed-off-by: Thomas Wolf <twolf@apache.org>
10 months agoMerge branch 'stable-6.8' 07/1174607/1
Matthias Sohn [Sat, 20 Jan 2024 00:03:52 +0000 (01:03 +0100)]
Merge branch 'stable-6.8'

* stable-6.8:
  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: Ifdd88eed34be3a1f4897b468392fd86bbc3f3a64

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 agoAdd tests for handling pack files removal during fetch 46/205546/6
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>
10 months agoMerge "Remove invalid/unnecessary Maven settings"
Matthias Sohn [Tue, 16 Jan 2024 22:14:04 +0000 (22:14 +0000)]
Merge "Remove invalid/unnecessary Maven settings"

10 months agoMerge "PackWriterBitmapPreparer: Set limit on excessive branch count"
Ivan Frade [Fri, 12 Jan 2024 23:40:21 +0000 (23:40 +0000)]
Merge "PackWriterBitmapPreparer: Set limit on excessive branch count"

10 months agoPackWriterBitmapPreparer: Set limit on excessive branch count 07/1174407/21
Jackson Toeniskoetter [Wed, 10 Jan 2024 21:34:48 +0000 (21:34 +0000)]
PackWriterBitmapPreparer: Set limit on excessive branch count

If there are too many branches then the bitmap
indexing selects only the tip commits of the least active
branches to reduce the amount of bitmaps to load on request.
This can still be a problem if the number of inactive branches
rival or exceed the total number of commits selected
for the active branches.

Limit the number of branches that receive only-tip bitmaps.
This reduces the memory pressure of loading all the bitmaps,
and allows us to model the size of the bitmap index without
considering the number of branches.

Bitmaps are generated for branches in order of most recent commit,
and follow these rules:

* The first {@code DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT} most active
  branches have full bitmap coverage.
* The {@code DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT} to {@code
  DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT} most active branches have
  only the tip commit covered.
* The remaining branches have no bitmap coverage.

To prevent effecting existing repositories, the default value is set
at Integer.MAX_VALUE.

Change-Id: I7cc53c898cdc04953b95669be0b069543e10c6f8

10 months agoUpdate jna to 5.14.0 90/1173390/5
Matthias Sohn [Fri, 15 Dec 2023 23:23:47 +0000 (00:23 +0100)]
Update jna to 5.14.0

Change-Id: Ie60f618fabd1c35815a7fe2775b7fe059baba8b4

10 months agoMerge "DfsInserter/PackParser: keep min size for index in the inserter"
Ivan Frade [Thu, 11 Jan 2024 21:29:58 +0000 (21:29 +0000)]
Merge "DfsInserter/PackParser: keep min size for index in the inserter"

10 months agoDfsInserter/PackParser: keep min size for index in the inserter 19/1174419/3
Ivan Frade [Wed, 10 Jan 2024 23:36:24 +0000 (15:36 -0800)]
DfsInserter/PackParser: keep min size for index in the inserter

Both, inserter and packparser read the minimum size for the object
size index. The writing is invoked from both classes but done only by
the inserter.

Let the inserter read and handle the conf. Do this in the constructor
and allow override so some paths can hardcode a value.

Change-Id: I890cadd29678a53738761f4b0ab13020d6353f3e

10 months agoMerge branch 'stable-6.8' 12/1174312/1
Matthias Sohn [Wed, 10 Jan 2024 22:58:02 +0000 (23:58 +0100)]
Merge branch 'stable-6.8'

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

Change-Id: Ief6e4d6cd3fcea327f28c32643b8323f5d0c6936

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 agoMerge "FooterLines: handle extraction from messages without headers"
Ivan Frade [Tue, 9 Jan 2024 17:41:58 +0000 (17:41 +0000)]
Merge "FooterLines: handle extraction from messages without headers"

10 months agoFooterLines: handle extraction from messages without headers 44/1173244/8
Nitzan Gur-Furman [Wed, 6 Dec 2023 13:47:27 +0000 (14:47 +0100)]
FooterLines: handle extraction from messages without headers

Prior to this change, long subjects of messages with no headers were
treated as headers, and therefore were skipped. In a message of the
form `<long subject>\n\n<footers>`, the footers would then get parsed
as a message, meaning no footers were returned.

After this change, the first lines are skipped only if they match any
of the known headers. The first line ofter the optional headers is then
assumed to be the subject line.

`FooterLineTest` had a few test cases for extracting footers from
messages with no headers. However, there were all with short messages,
so the "skip this line" logic in `RawParseUtils` was never triggered.
Added test case to catch this issue.

Change-Id: I971a1dddf1a9aea094360c3c8fc3b9a8b011bbf9
Issue: Google b/287891316

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 agoRemove invalid/unnecessary Maven settings 31/1174031/1
Michael Keppler [Sat, 23 Dec 2023 19:31:11 +0000 (20:31 +0100)]
Remove invalid/unnecessary Maven settings

* Remove jgit.target POM and remove it from the module list. This was
only necessary when the target file had to be referenced as an artifact.
Meanwhile we reference it directly by its path, and can remove the Maven
build around it.

* Remove tycho configuration options that are no longer valid (resolved
was removed very early, probably before 1.0; includePackedArtifacts was
removed in 3.0). Also remove duplicate version specification.

Change-Id: Ifa69065dd73bf586b8359541375e065f5f60aa03

11 months agoUpdate maven plugins 46/1174046/1
Matthias Sohn [Fri, 22 Dec 2023 23:39:07 +0000 (00:39 +0100)]
Update maven plugins

- com.github.siom79.japicmp:japicmp-maven-plugin to 0.18.3
- com.github.spotbugs:spotbugs-maven-plugin to 4.8.2.0
- io.github.git-commit-id:git-commit-id-maven-plugin to 7.0.0
- org.apache.maven.plugins:maven-clean-plugin to 3.3.2
- org.apache.maven.plugins:maven-compiler-plugin to 3.12.0
- org.apache.maven.plugins:maven-dependency-plugin to 3.6.1
- org.apache.maven.plugins:maven-enforcer-plugin to 3.4.1
- org.apache.maven.plugins:maven-javadoc-plugin to 3.6.3
- org.apache.maven.plugins:maven-jxr-plugin to 3.3.1
- org.apache.maven.plugins:maven-pmd-plugin to 3.21.2
- org.apache.maven.plugins:maven-project-info-reports-plugin to 3.5.1
- org.apache.maven.plugins:maven-shade-plugin to 3.5.1
- org.apache.maven.plugins:maven-site-plugin to 4.0.0-M13
- org.apache.maven.plugins:maven-surefire-plugin to 3.2.3
- org.codehaus.mojo:build-helper-maven-plugin to 3.5.0
- org.cyclonedx:cyclonedx-maven-plugin to 2.7.10
- org.eclipse.cbi.maven.plugins:eclipse-jarsigner-plugin to 1.4.3
- org.jacoco:jacoco-maven-plugin to 0.8.11

Change-Id: Ie146085f567f0bcfe0124627939382fe5a764e6c

11 months agoUpdate org.eclipse.dash:license-tool-plugin to 1.1.0 45/1174045/1
Matthias Sohn [Fri, 22 Dec 2023 23:15:00 +0000 (00:15 +0100)]
Update org.eclipse.dash:license-tool-plugin to 1.1.0

Change-Id: I039e10fc6790d54c30cfd85a53c05604351996e0

11 months agoEnable using slf4j 2.x 85/1173385/7
Matthias Sohn [Sun, 10 Dec 2023 22:55:40 +0000 (23:55 +0100)]
Enable using slf4j 2.x

Eclipse platform moved to sfl4j 2.x. Hence relax version constraint so
that both 1.7 and 2.x are allowed.

Bug: egit-5
Change-Id: Ie0b00310d8f3f2553457c8668a38978a67b8febe

11 months agoUpdate Tycho to 4.0.4 86/1173386/4
Matthias Sohn [Sun, 10 Dec 2023 21:23:31 +0000 (22:23 +0100)]
Update Tycho to 4.0.4

Change-Id: I9d087b5a62ab3d474d894a2276572156c14dad4e

11 months agoUpdate mockito to 5.8.0 84/1173384/3
Matthias Sohn [Sat, 9 Dec 2023 23:08:09 +0000 (00:08 +0100)]
Update mockito to 5.8.0

Change-Id: I70d33b7af25fcb4754fb048dd9054eef7356f00c

11 months agoAdd 4.31 target platform and update orbit to 4.31 83/1173383/3
Matthias Sohn [Sat, 9 Dec 2023 22:58:25 +0000 (23:58 +0100)]
Add 4.31 target platform and update orbit to 4.31

and update bytebuddy to 1.14.10.

Change-Id: I145776a31d806f7e6dcc90263650109b3eb19067

11 months agoUpdate ecj to 3.36.0 82/1173382/3
Matthias Sohn [Sat, 9 Dec 2023 22:49:56 +0000 (23:49 +0100)]
Update ecj to 3.36.0

Change-Id: I803de19e8086239ebbae9877121946fdddfbaa89

11 months agoRenormalize line endings based on .gitattributes 51/1173051/3
Matthias Sohn [Fri, 24 Nov 2023 16:03:09 +0000 (17:03 +0100)]
Renormalize line endings based on .gitattributes

This fixes line endings of all text files to use LF in the repository.

Change-Id: I4df6fd7aaf9db9cdaa953a0d1062981b4612056c

11 months agoConfigure .gitattributes to manage line endings 50/1173050/3
Matthias Sohn [Fri, 24 Nov 2023 14:14:58 +0000 (15:14 +0100)]
Configure .gitattributes to manage line endings

Mark test resources as binary to prevent line ending normalization
Some of the test resources are used to test handling of line endings
in JGit.

Change-Id: Idd9ba604945797d1cd1f3af1a1987aee3188e1d6

11 months agoNormalize line endings to LF for all text files 49/1173049/3
Matthias Sohn [Fri, 24 Nov 2023 14:11:11 +0000 (15:11 +0100)]
Normalize line endings to LF for all text files

Change-Id: I69753494e4c7db4c0a8e6eca3b3e63d3ff561117

11 months agoMerge "Remove invalid spotbugs configuration"
Matthias Sohn [Fri, 22 Dec 2023 19:23:44 +0000 (19:23 +0000)]
Merge "Remove invalid spotbugs configuration"

11 months agoMerge "Fix PMD plugin configuration"
Matthias Sohn [Fri, 22 Dec 2023 19:21:33 +0000 (19:21 +0000)]
Merge "Fix PMD plugin configuration"

11 months agoBasePackFetchConnection: Skip object/ref lookups if local repo is empty 02/1173802/3
Dariusz Luksza [Mon, 18 Dec 2023 18:24:49 +0000 (18:24 +0000)]
BasePackFetchConnection: Skip object/ref lookups if local repo is empty

When cloning repository some of the operations in
`BasePackFetchConnection` can be skipped. We don't need to advertise
packs, compute "wanted time" or wanted refs to send. All of those
operations will try to read objects from an empty repository which
always results in a missing object.

This saves 99.9% of `LooseObjects.open()` calls which dramatically
speeds up object negotiation in V2 protocol.

In testing on JGit (v6.8.0.202311291450-r) repository, which contains
564 refs, the number of calls to `LooseObjects.open()` was reduced from
1187 to 1.

Skipping a call to `markRefsAdvertised()` initially reduced be above
number to 623. Then assuming "0" "want time" an on empty repository
pushed the calls down to 312. Finally, skipping objects reachability on
empty repository set calls down to 1.

The last call is performed from `FetchProcess.asForIsComplete()` which
probably needs to stay in place.

Bug: jgit-5
Change-Id: I2480690726ea54d3b1593380bc8f8d15b4d6afc6

11 months agoLooseObjects: Use File#exists when possible 37/1173737/2
Dariusz Luksza [Sun, 17 Dec 2023 16:43:56 +0000 (16:43 +0000)]
LooseObjects: Use File#exists when possible

When `trustFolderStat` flag is enabled we can use `File.exist()`
instead of rethrowing `FileNotFoundException`. This improves performance
of cloning and fetching.

A simple benchmark that generates a random `ObjectId` instance and then
tries to parse that object id, shows about 30% improvement with this
change.

The benchmark scenario was based on the stacktrace reported in jgit-5.
Where `RevWalk.parse()` call will eventually call `LooseObjects.open()`
and finally `LoseObjects.getOpenLoader()`.

Results on `master`:
  (packFiles)  Mode  Cnt        Score   Error  Units
           10  avgt    2      137.400          us/op
          100  avgt    2     1369.063          us/op
         1000  avgt    2    13730.759          us/op
        10000  avgt    2   137359.539          us/op
       100000  avgt    2  1382627.641          us/op

With this change:
  (packFiles)  Mode  Cnt        Score   Error  Units
           10  avgt    2       85.019          us/op
          100  avgt    2      868.748          us/op
         1000  avgt    2     8628.768          us/op
        10000  avgt    2    86877.505          us/op
       100000  avgt    2   863123.868          us/op

Issue: jgit-5
Change-Id: I366acf629873a5c7577a1032490faf57685f98dd

11 months agoRemove invalid spotbugs configuration 92/1173392/1
Michael Keppler [Sun, 17 Dec 2023 14:45:18 +0000 (15:45 +0100)]
Remove invalid spotbugs configuration

* findbugsXmlOutput was renamed to spotbugsXmlOutput long ago
* spotbugsXmlOutput has a default value of true and is deprecated,
therefore removing the entire line seems most reasonable

See https://spotbugs.github.io/spotbugs-maven-plugin/check-mojo.html#spotbugsXmlOutput

Change-Id: I83c0bbce1fb3622accb13978319b4313b0121655

11 months agoFix PMD plugin configuration 91/1173391/1
Michael Keppler [Sun, 17 Dec 2023 14:30:35 +0000 (15:30 +0100)]
Fix PMD plugin configuration

The configuration element has been renamed in release 3.18, see
https://github.com/apache/maven-pmd-plugin/releases/tag/maven-pmd-plugin-3.18.0

Change-Id: Ia6ec6992c4348d77d4b61f34190a57775cc30cec

11 months agoDfsReader: give subclasses visiblity over the pack bitmap index 78/1173678/5
Ivan Frade [Thu, 14 Dec 2023 17:25:06 +0000 (09:25 -0800)]
DfsReader: give subclasses visiblity over the pack bitmap index

Subclasses intercept many methods in DfsReader to capture metrics, but
they cannot record stats from PackBitmapIndex, as it is wrapped inside
a BitmapIndex.

Move the creation of the BitmapIndex to a protected method. Subclasses
can override it to e.g. read metrics from the index or set listeners to
the BitmapIndex.

Change-Id: I86c13b3ef88663d7faf59f2ec77df0a36b1627ed

11 months agoPackBitmapIndex/StoredBitmap: Expose size and counts 48/205448/6
Ivan Frade [Fri, 10 Nov 2023 20:05:51 +0000 (12:05 -0800)]
PackBitmapIndex/StoredBitmap: Expose size and counts

PackBitmapIndex holds a collection of StoredBitmaps. StoredBitmaps can
be either base bitmaps (ready) or an XOR over another bitmap. XOR
bitmaps are replaced with a resolved version on demand. Bitmaps
can use a significant amount of memory but we don't have detailed
visibility about it.

Add methods to PackBitmapIndex to know how many xor/bases we have and
their sizes.

Change-Id: I57aa80a1f07ddf9223eb34cfda85aab85529ea9c

11 months agoPackWriter/Statistics: Remove the bitmapt hit stats 03/1173603/1
Ivan Frade [Tue, 12 Dec 2023 21:31:03 +0000 (13:31 -0800)]
PackWriter/Statistics: Remove the bitmapt hit stats

The request uses bitmaps for reachability and to decide what to
pack. Setting the listener in the PackWriter only covers the second
case.

Remove the listener from the PackWriter. It makes more sense to set it
in the reader and at the moment the BitmapIndex only supports a single
listener.

This was introduced after the 6.8 tag, so it should be safe to remove.

Change-Id: Ib4c0a805c70e54b6a9e7f78ccdb8e0a465d238f1

11 months agoConfigure Github issue reporting 68/1173368/1
Thomas Wolf [Sun, 10 Dec 2023 16:02:10 +0000 (17:02 +0100)]
Configure Github issue reporting

Add two forms for bug reports and feature requests.

Change-Id: I8d80f2498741ba5bb88655d1e22798f99826fb7f

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 agoMerge "API filter for PackStatistics.objectsWithBitmapsFound"
Thomas Wolf [Wed, 6 Dec 2023 08:24:45 +0000 (08:24 +0000)]
Merge "API filter for PackStatistics.objectsWithBitmapsFound"

11 months agoFooterLine: Protect from ill-formed message 47/1173047/5
Kamil Musin [Tue, 5 Dec 2023 15:22:08 +0000 (16:22 +0100)]
FooterLine: Protect from ill-formed message

A raw commit message has some headers and then the actual
message. RawParseUtils.commitMessage returns the start position of the
actual message, or -1 when the message is not raw. FooterLine is not
handling this -1 and throws an IndexOutOfBounds exception.

Consider than msgB can be -1 when looking for the beginning of the
last paragraph.

FooterLine javadoc and parameter talk only about "raw" but previous
code accepted non-raw messages (used mostly in unit tests) so we need
to keep this behavior.

Change-Id: I4b88c507e210fdd200a85b01665c8524ab393b00

11 months agoMerge "Document option gc.writeCommitGraph"
Ivan Frade [Tue, 5 Dec 2023 18:39:19 +0000 (18:39 +0000)]
Merge "Document option gc.writeCommitGraph"

11 months agoAPI filter for PackStatistics.objectsWithBitmapsFound 76/1173176/1
Thomas Wolf [Tue, 5 Dec 2023 14:33:36 +0000 (15:33 +0100)]
API filter for PackStatistics.objectsWithBitmapsFound

The field was introduced in commit 5e563e1b.

Change-Id: Ic2f495e79319ac6044bcabf253b63b8b631eec84

11 months agoMerge "StartGenerator: Fix parent rewrite with non-default RevFilter"
Ivan Frade [Mon, 4 Dec 2023 23:38:57 +0000 (23:38 +0000)]
Merge "StartGenerator: Fix parent rewrite with non-default RevFilter"

11 months agoStartGenerator: Fix parent rewrite with non-default RevFilter 68/205168/27
Ronald Bhuleskar [Wed, 25 Oct 2023 20:10:33 +0000 (13:10 -0700)]
StartGenerator: Fix parent rewrite with non-default RevFilter

StartGenerator is responsible for propagating the RevWalk's
parent rewrite setting, but it currently only does so when a
non-default TreeFilter is set, when it should also do so if
the default TreeFilter is used with a non-default RevFilter.

Adding a new if condition within StartGenerator to enable parent
rewrite with non-default RevFilter.

TreeRevFilter relied on the old buggy functionality and has
been modified to explicitly refrain from rewriting parents.

Change-Id: I4e4ff67fb279edbcc3461496b132cea774fb742f

11 months agoUpdate MANIFEST.MF 42/1173142/2
Peter Kriens [Fri, 1 Dec 2023 16:47:49 +0000 (17:47 +0100)]
Update MANIFEST.MF

Add an import for javax.net.ssl

Signed-off-by: Peter Kriens <Peter.Kriens@aQute.biz>
11 months agoDocument option gc.writeCommitGraph 46/1173046/1
Matthias Sohn [Mon, 4 Dec 2023 22:03:26 +0000 (23:03 +0100)]
Document option gc.writeCommitGraph

Change-Id: Ic02d5abce18250b30f2c3f3741892d8cda251001

11 months agoBump last release version to 6.8.0.202311291450-r 45/1173045/1
Matthias Sohn [Mon, 4 Dec 2023 22:11:34 +0000 (23:11 +0100)]
Bump last release version to 6.8.0.202311291450-r

This is the version used to compare API changes against to detect
breaking API changes.

Change-Id: I005b6a24c98c507656ebab415492a4127f08d471

11 months agoPrepare 6.9.0-SNAPSHOT builds 44/1173044/1
Matthias Sohn [Mon, 4 Dec 2023 22:02:44 +0000 (23:02 +0100)]
Prepare 6.9.0-SNAPSHOT builds

Change-Id: Id1d784ec4870cfb53c4b140fe0bb3fad9eef651d

11 months agoMerge branch 'stable-6.8' 43/1173043/1
Matthias Sohn [Mon, 4 Dec 2023 21:58:45 +0000 (22:58 +0100)]
Merge branch 'stable-6.8'

* stable-6.8:
  Prepare 6.8.1-SNAPSHOT builds
  JGit v6.8.0.202311291450-r
  Rename method parameter to fix warning about hidden field
  Fix warnings about empty control flow statements
  BitmapIndexImpl: externalize error message
  Suppress not-externalized string warnings
  Silence API error for new method BitmapIndex#addBitmapLookupListener
  Update Orbit to orbit-aggregation/2023-12
  Prepare 6.8.0-SNAPSHOT builds
  JGit v6.8.0.202311212206-rc1

Change-Id: Ie88662f6458bb80147c7c164424eebd8b8240fc7

11 months agoBitmapWalkerTest: New test for the walker 71/1172471/2
Ivan Frade [Mon, 20 Nov 2023 21:18:37 +0000 (13:18 -0800)]
BitmapWalkerTest: New test for the walker

Change-Id: I414f5bdd86e5623d7669fa187df19e06acd02cef

11 months agoPackWriter: store the objects with bitmaps in the statistics 04/205504/17
Ivan Frade [Fri, 17 Nov 2023 18:44:56 +0000 (10:44 -0800)]
PackWriter: store the objects with bitmaps in the statistics

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.

Use the listener interface of the BitmapWalker to get the objects
walked with bitmaps and store them in the statistics.

Change-Id: Id15a904eb642d7f50d80ac77d1146db4fe4706eb

11 months agoFooterLine: First line cannot be a footer 30/1172930/1
Ivan Frade [Wed, 29 Nov 2023 18:51:04 +0000 (10:51 -0800)]
FooterLine: First line cannot be a footer

The first line of the commit message cannot be a footer line. This
restriction was dropped in commit [1] while adding multiline
footers. This affects at least the git-numberer gerrit plugin, that
even have a test for it [2].

Reintroduce the restriction that the first line of the commit message
cannot be a footer and bring the test from git-numberer to jgit.

[1] https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1172664
[2] https://chromium.googlesource.com/infra/gerrit-plugins/git-numberer/+/refs/heads/main/src/test/java/com/googlesource/chromium/plugins/gitnumberer/GetFooterLinesTest.java

Change-Id: Id3fa6b8614664dbc3fdccffe1006b0b9752a8de6

11 months agoReapply "Improve footer parsing to allow multiline footers." 29/1172929/1
Ivan Frade [Wed, 29 Nov 2023 21:44:02 +0000 (13:44 -0800)]
Reapply "Improve footer parsing to allow multiline footers."

This reverts commit e99fb6edc4b4eba43e27f9945df043e72ab297dd.

11 months agoRevert "Improve footer parsing to allow multiline footers." 02/1172902/1
Ivan Frade [Wed, 29 Nov 2023 18:05:07 +0000 (10:05 -0800)]
Revert "Improve footer parsing to allow multiline footers."

This reverts commit 340cc787a0d14a0698d757a919ccd77e0a129fb0.

This breaks a test in the git_numberer gerrit plugin used by chromium
[1].  The test checks that first line is never a footer, which sounds
right. That test should be included in FooterLineTest.

[1]
https://chromium.googlesource.com/infra/gerrit-plugins/git-numberer/+/refs/heads/main/src/test/java/com/googlesource/chromium/plugins/gitnumberer/GetFooterLinesTest.java

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