]> source.dussan.org Git - jgit.git/log
jgit.git
2 months agoMerge branch 'stable-6.2' into stable-6.3 57/1199457/1 stable-6.3
Matthias Sohn [Wed, 14 Aug 2024 08:51:16 +0000 (10:51 +0200)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Fix "Comparison of narrow type with wide type in loop condition"
  JGit v5.13.3.202401111512-r

Change-Id: I6bce3a4d64a617d74d0cbf4e79887b067e1ea2c5

2 months agoMerge branch 'stable-6.1' into stable-6.2 56/1199456/1 stable-6.2
Matthias Sohn [Wed, 14 Aug 2024 07:25:43 +0000 (09:25 +0200)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Fix "Comparison of narrow type with wide type in loop condition"
  JGit v5.13.3.202401111512-r

Change-Id: Ib536297ef20a75b36cff8f41d57855913f7d7f26

2 months agoMerge branch 'stable-6.0' into stable-6.1 55/1199455/1 stable-6.1
Matthias Sohn [Wed, 14 Aug 2024 07:24:40 +0000 (09:24 +0200)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Fix "Comparison of narrow type with wide type in loop condition"
  JGit v5.13.3.202401111512-r

Change-Id: I23afe07585ff17ad8486cbe2c667f6acbe912542

2 months agoMerge branch 'stable-5.13' into stable-6.0 54/1199454/1 stable-6.0
Matthias Sohn [Wed, 14 Aug 2024 06:57:35 +0000 (08:57 +0200)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Fix "Comparison of narrow type with wide type in loop condition"
  JGit v5.13.3.202401111512-r

Change-Id: Ib15aa83972d81986959889dc03e943fe55c78873

2 months agoFix "Comparison of narrow type with wide type in loop condition" 67/1198667/1 stable-5.13
Matthias Sohn [Fri, 9 Aug 2024 09:53:01 +0000 (11:53 +0200)]
Fix "Comparison of narrow type with wide type in loop condition"

This issue was detected by a GitHub CodeQL security scan run on JGit
source code.

Description of the error raised by the security scan:
"In a loop condition, comparison of a value of a narrow type with a
value of a wide type may always evaluate to true if the wider value is
sufficiently large (or small). This is because the narrower value may
overflow. This can lead to an infinite loop."

Fix this by using type `long` for the local variable `done`.

Change-Id: Ibd4f71299e3f2e40d4331227bd143569a4264d8c

9 months agoJGit v5.13.3.202401111512-r 13/1174313/1 v5.13.3.202401111512-r
Matthias Sohn [Thu, 11 Jan 2024 14:12:40 +0000 (15:12 +0100)]
JGit v5.13.3.202401111512-r

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

9 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

9 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

9 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

9 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

11 months agoCheckout: better directory handling 42/204642/6
Thomas Wolf [Fri, 11 Aug 2023 19:40:13 +0000 (21:40 +0200)]
Checkout: better directory handling

This backports the upstream security fix to downstream stable-5.13 branch.
(cherry picked from commit 9072103f3b3cf64dd12ad2949836ab98f62dabf1)

When checking out a file into the working tree ensure that all parent
directories of the file below the working tree root are actually
directories and do exist before we try to create the file.

When multiple files are to be checked out (or even a whole tree), this
may check the same directories over and over again. Asking the file
system every time for file attributes is a potentially expensive
operation. As a remedy, introduce an in-memory cache of directory
states for a particular check-out operation.

Apply the same fix also in the ResolveMerger, which may also check out
files, and also in the PatchApplier. In PatchApplier, also validate
paths.

Change-Id: Ie12864c54c9f901a2ccee7caddec73027f353111
Signed-off-by: Thomas Wolf <twolf@apache.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
12 months agoMerge branch 'stable-6.2' into stable-6.3 28/204928/1
Matthias Sohn [Thu, 12 Oct 2023 22:51:46 +0000 (00:51 +0200)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  PackConfig: fix @since tags
  Remove unused API problem filters
  Add support for git config repack.packKeptObjects
  Do not exclude objects in locked packs from bitmap processing

Change-Id: I22b89bf00dcef26b2096d25397aa9a57a745a92b

12 months agoMerge branch 'stable-6.1' into stable-6.2 04/204904/1
Matthias Sohn [Thu, 12 Oct 2023 22:44:33 +0000 (00:44 +0200)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  PackConfig: fix @since tags
  Remove unused API problem filters
  Add support for git config repack.packKeptObjects
  Do not exclude objects in locked packs from bitmap processing

Change-Id: Ib4e4fe407dce334c7537bf278baa39db93aa2f09

12 months agoMerge branch 'stable-6.0' into stable-6.1 03/204903/2
Matthias Sohn [Thu, 12 Oct 2023 22:33:19 +0000 (00:33 +0200)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  PackConfig: fix @since tags
  Remove unused API problem filters
  Add support for git config repack.packKeptObjects
  Do not exclude objects in locked packs from bitmap processing

Change-Id: I0c9c0b3c206cac03a93b30eda348177a4de35c36

12 months agoMerge branch 'stable-5.13' into stable-6.0 02/204902/1
Matthias Sohn [Thu, 12 Oct 2023 22:22:11 +0000 (00:22 +0200)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  PackConfig: fix @since tags
  Remove unused API problem filters
  Add support for git config repack.packKeptObjects
  Do not exclude objects in locked packs from bitmap processing

Change-Id: Ifeaa4b4f0c5944d4ecd3042be429833ff72b43ed

12 months agoPackConfig: fix @since tags 01/204901/1
Matthias Sohn [Thu, 12 Oct 2023 22:19:12 +0000 (00:19 +0200)]
PackConfig: fix @since tags

Change-Id: Ia513f7cdbf3c197e8661720fc804984ff165fc5c

12 months agoRemove unused API problem filters 00/204900/1
Matthias Sohn [Thu, 12 Oct 2023 22:18:59 +0000 (00:18 +0200)]
Remove unused API problem filters

Change-Id: I9d5b96cf841478af8613667ef8574423630f8028

12 months agoAdd support for git config repack.packKeptObjects 20/204820/8
Antonio Barone [Thu, 5 Oct 2023 19:58:13 +0000 (21:58 +0200)]
Add support for git config repack.packKeptObjects

Change Ide3445e652 introduced the `--pack-kept-objects` option to GC for
including the objects contained in the locked packfiles during the
repack phase.

Whilst this allowed to explicitly pass a command line argument to the
jgit gc program, it did not allow the option to be read from
configuration.

Allow the pack kept objects option to be configured exactly as C-Git
documents [1], by introducing a new `repack.packKeptObjects`
configuration.

`repack.packKeptObjects` defaults to `true`, when the
`pack.buildBitmaps` is `true` (which is the default case), `false`
otherwise.

[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-repackpackKeptObjects

Bug: 582292
Change-Id: Ia931667277410d71bc079d27c097a57094299840

12 months agoDo not exclude objects in locked packs from bitmap processing 25/203625/21
Luca Milanesio [Fri, 11 Aug 2023 19:15:17 +0000 (20:15 +0100)]
Do not exclude objects in locked packs from bitmap processing

Packfiles having an equivalent .keep file are associated with in-flight
pushes that haven't been completed, with potentially a set of git
objects not yet referenced by a ref.

If the Git client is not up-to-date, it may result in pushing a
packfile, generating a <packfile>.keep on the server, which
may also contain existing commits due to the lack of Git protocol
negotiation in the git-receive-pack.

The Git protocol negotiation is the phase where the client and the
server exchange the list of refs they have for trying to find a common
base and minimise the amount of objects to be transferred.

The repack phase in GC was previously skipping all objects that were
contained in all packfiles having a <packfile>.keep file associated
(aka "locked packfiles"), which did not take into consideration the
fact that excluding the existing commits would have resulted in the
generation of an invalid bitmap file.

The code for excluding the objects in the locked packfiles was written
well before the bitmap was introduced, hence could not consider a use
case that did not exist at that time.

However, when the bitmap was introduced, the exclusion of locked
packfiles was not changed, hence creating a potential problem.
The issue went unnoticed for many years because the bitmap generation
was disabled when JGit noticed any locked packfiles; however, the
bitmaps are enabled again since  Id722e68d9f , and the the issue is now
visible and is impacting the GC repack phase.

Introduce the '--pack-kept-objects' option in GC for including the
objects contained in the locked packfiles during the repack phase,
which is not an issue because of the following:

- If there are any existing commits duplicated in the packfiles
  they will be just considered once anyway because the repack doesn't
  generate duplicates in the output packfile.

- If there are any new commits that do not have any ref pointing to
  them, they will be automatically excluded from the output repacked
  packfile.

The same identical solution is adopted in the C implementation of git
in repack.c.

Because the locked packfile is not pruned, any new commits not pointed
by any refs will remain in the repository and there will not be any
accidental pruning or object loss as it is today before this change.

As a side-effect of this change, it is now potentially possible to still
have duplicate BLOBs after GC when the keep packfile contained existing
objects. However, it is way better to keep the duplication until the
next GC phase rather than omitting existing objects from repacking and,
therefore generating an invalid bitmap and incorrect packfile.

Bug: 582292
Bug: 582455
Change-Id: Ide3445e652fcf256a7912f881cb898897c99b8f8

14 months agoMerge branch 'stable-6.2' into stable-6.3 21/203521/1
Matthias Sohn [Wed, 2 Aug 2023 23:37:43 +0000 (01:37 +0200)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Add verification in GcKeepFilesTest that bitmaps are generated
  Express the explicit intention of creating bitmaps in GC
  GC: prune all packfiles after the loosen phase
  Prepare 5.13.3-SNAPSHOT builds
  JGit v5.13.2.202306221912-r

Change-Id: I589ed444b5cbfc5b073cac91323e2cc97ab98087

14 months agoMerge branch 'stable-6.1' into stable-6.2 20/203520/1
Matthias Sohn [Wed, 2 Aug 2023 23:28:07 +0000 (01:28 +0200)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Add verification in GcKeepFilesTest that bitmaps are generated
  Express the explicit intention of creating bitmaps in GC
  GC: prune all packfiles after the loosen phase
  Prepare 5.13.3-SNAPSHOT builds
  JGit v5.13.2.202306221912-r

Change-Id: I5b16c3b613a95b7f28c8f6ac0b20c4c593759cea

14 months agoMerge branch 'stable-6.0' into stable-6.1 19/203519/1
Matthias Sohn [Wed, 2 Aug 2023 23:19:21 +0000 (01:19 +0200)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Add verification in GcKeepFilesTest that bitmaps are generated
  Express the explicit intention of creating bitmaps in GC
  GC: prune all packfiles after the loosen phase
  Prepare 5.13.3-SNAPSHOT builds
  JGit v5.13.2.202306221912-r

Change-Id: Ib08037f6055dac1776e38cfb4ff8c88a50ad3e60

14 months agoMerge branch 'stable-5.13' into stable-6.0 18/203518/1
Matthias Sohn [Wed, 2 Aug 2023 23:17:17 +0000 (01:17 +0200)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Add verification in GcKeepFilesTest that bitmaps are generated
  Express the explicit intention of creating bitmaps in GC
  GC: prune all packfiles after the loosen phase
  Prepare 5.13.3-SNAPSHOT builds
  JGit v5.13.2.202306221912-r

Change-Id: I1f50995d9d9c592ec0e02a04e0e409440b49f9f3

15 months agoAdd verification in GcKeepFilesTest that bitmaps are generated 09/202509/2
Luca Milanesio [Sat, 10 Jun 2023 00:20:44 +0000 (01:20 +0100)]
Add verification in GcKeepFilesTest that bitmaps are generated

The packfiles with the .keep extensions are meant to prevent
a packfile from being processed or removed during GC.
From the point of view of the GC process then, the associated
packfile should be completely transparent:
- it should not included in the repacked file
- it should not pruned
- its objects should be left untouched, even if unreachable
- the GC process, including the bitmap generation should continue
  as usual, as the the packfiles with .keep file did not exist

Add one explicit test for making sure that the management
of .keep file is also transparent to the generation of bitmaps,
which are still generated if a .keep file exists.

Bug: 582039
Change-Id: I14f6adc3f961c606fbc617e51ea6ed6e2ef8604f

15 months agoExpress the explicit intention of creating bitmaps in GC 08/202508/2
Luca Milanesio [Sat, 10 Jun 2023 01:21:07 +0000 (02:21 +0100)]
Express the explicit intention of creating bitmaps in GC

Add an explicit flag to PackWriter for allowing the
GC.repack() phase to explicitly generate bitmaps only for the
heads packfile and not for the others.

Previously the bitmap generation was conditioned to the
presence of object ids exclusion from the PackWriter.

The introduction of the bitmap generation in the PackWriter
done in Icdb0cdd66 has accidentally made the .keep files not
completely transparent, because their presence have disabled
the generation of the bitmap index, even if the generation
of bitmaps is enabled.

This bug has been an accidental consequence of the intention
of the bitmap generator to avoid generating bitmaps for the
non-heads packfile, however the implementation done by Colby
decided to use the excludeInPacks variable (see [1]) which
is unfortunately also used for excluding the packfiles having
an associated .keep file (see [2]).

[1] https://git.eclipse.org/r/c/jgit/jgit/+/7940/18/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java#1617
[2] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/dafcb8f6db82b899c917832768f1c240d273190c/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java#506

Bug: 582039
Change-Id: Id722e68d9ff4ac24e73bf765ab11017586b6766e

15 months agoGC: prune all packfiles after the loosen phase 10/202510/2
Luca Milanesio [Sun, 11 Jun 2023 16:24:29 +0000 (17:24 +0100)]
GC: prune all packfiles after the loosen phase

When loosening the objects inside the packfiles to be pruned, make sure
that the packfile list is stable and prune all the files after the
loosening is done.

This prevents a series of exceptions previously thrown when loosening
the packfiles, due to the too early pruning of the packfiles that were
still in the pack list.

Bug: 581532
Change-Id: I776776e2e083f1fa749d53f965bf50f919823b4f

15 months agoPrepare 5.13.3-SNAPSHOT builds 58/202658/1
Matthias Sohn [Thu, 22 Jun 2023 00:15:21 +0000 (02:15 +0200)]
Prepare 5.13.3-SNAPSHOT builds

Change-Id: I02b9388c8bc1c266bb29b4502504d137dd42142f

15 months agoJGit v5.13.2.202306221912-r 57/202657/1 v5.13.2.202306221912-r
Matthias Sohn [Wed, 21 Jun 2023 23:12:05 +0000 (01:12 +0200)]
JGit v5.13.2.202306221912-r

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

16 months agoMerge branch 'stable-6.2' into stable-6.3 99/202299/1
Luca Milanesio [Wed, 7 Jun 2023 23:26:00 +0000 (00:26 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: I70db1bc8529eb6a66610946946da5447a578bffa
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
16 months agoMerge branch 'stable-6.1' into stable-6.2 98/202298/1
Luca Milanesio [Wed, 7 Jun 2023 23:25:07 +0000 (00:25 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: I1a98e293ef10917b2d8ad64e88be9e82c7bcf693
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
16 months agoMerge branch 'stable-6.0' into stable-6.1 97/202297/1
Luca Milanesio [Wed, 7 Jun 2023 23:23:54 +0000 (00:23 +0100)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: Idc0d1f8ab4524868b7e9754799f70acc1d24f2cb
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
16 months agoMerge branch 'stable-5.13' into stable-6.0 96/202296/1
Luca Milanesio [Wed, 7 Jun 2023 23:21:07 +0000 (00:21 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: I883b21b00317cc6d9951a8a5f9505078ddd2a3a7
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
16 months agoRevert "RefDirectory: Throw exception if CAS of packed ref list fails" 92/201992/2
Martin Fick [Wed, 8 Mar 2023 15:34:38 +0000 (08:34 -0700)]
Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

This reverts commit 9c33f7364d41956240818ba12d8b79d5ea846162.

Reason for revert: This change was based on the false claim that the
packedrefs file lock is held while the CAS is being done, but it is
actually released before the CAS (the in memory lock is still held,
however that does not prevent external actors from updating the
packedrefs files and then another thread from subsequently re-reading it
and updating the in memory packedRefList). Although reverting this
change can cause the CAS to fail, it should not actually matter since
the failure would indicate that another thread has already updated the
in memory packedRefList to either the same version this thread was
trying to update it too, or to a more recent version. Either way,
failing the CAS is then appropriate and should not be problematic.

Although this change reverts the code in the RefDirectory class, it
keeps the "improvements" to the test so that it continues to pass
reliably. The reason for the quotes around the word "improvements" is
because I believe the test alteration actually dramatically changes the
intent of the test, and that the original intent of the test is
untestable with the GC and RefDirectory classes as is.

Bug: 582044
Change-Id: I3acee7527bb542996dcdfaddfb2bdb45ec444db5
Signed-off-by: Martin Fick <quic_mfick@quicinc.com>
(cherry picked from commit c5617711a1b4d5d0807cc7eed702b78d114d46b3)

17 months agoMerge branch 'stable-6.2' into stable-6.3 80/201480/3
Matthias Sohn [Thu, 27 Apr 2023 00:07:23 +0000 (02:07 +0200)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  [bazel] Move ToolTestCase to src folder (6.2)
  GcConcurrentTest: @Ignore flaky testInterruptGc
  Fix CommitTemplateConfigTest
  Fix after_open config and Snapshotting RefDir tests to work with bazel
  [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory
  Demote severity of some error prone bug patterns to warnings
  UploadPack: Fix NPE when traversing a tag chain

Change-Id: I736c7d0ed9c6e9718fa98976c3dc5a25ab8cda85

17 months ago[bazel] Move ToolTestCase to src folder (6.2) 25/201525/2
Matthias Sohn [Mon, 24 Apr 2023 16:50:10 +0000 (18:50 +0200)]
[bazel] Move ToolTestCase to src folder (6.2)

Bazel barks at the abstract ToolTestCase not containing any test. Move
it from the tst/ source folder to the src/ source folder so that bazel
knows this is a helper class which doesn't contain tests.

Change-Id: Ie353c27526644ea9b47437b9bd9cd730a432ab29

17 months agoMerge branch 'stable-6.1' into stable-6.2 79/201479/3
Matthias Sohn [Wed, 26 Apr 2023 23:48:07 +0000 (01:48 +0200)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  GcConcurrentTest: @Ignore flaky testInterruptGc
  Fix CommitTemplateConfigTest
  Fix after_open config and Snapshotting RefDir tests to work with bazel
  [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory
  Demote severity of some error prone bug patterns to warnings
  UploadPack: Fix NPE when traversing a tag chain

Change-Id: I9863cbce95d845efc891724898954b0b2f8dbf7b

17 months agoMerge branch 'stable-6.0' into stable-6.1 29/201529/1
Matthias Sohn [Wed, 26 Apr 2023 23:37:29 +0000 (01:37 +0200)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  GcConcurrentTest: @Ignore flaky testInterruptGc
  Fix CommitTemplateConfigTest

Change-Id: I9c622de39200c6ee248d600736dc5db477f6bf9f

17 months agoMerge branch 'stable-5.13' into stable-6.0 28/201528/1
Matthias Sohn [Wed, 26 Apr 2023 23:07:47 +0000 (01:07 +0200)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  GcConcurrentTest: @Ignore flaky testInterruptGc
  Fix CommitTemplateConfigTest

Adapt GcConcurrentTest to changed FileRepositoryBuilder API.

Change-Id: I8906662a6391ceed20ab29cfbe238daf13e1be63

17 months agoGcConcurrentTest: @Ignore flaky testInterruptGc 27/201527/1
Jonathan Tan [Wed, 5 Apr 2023 20:44:59 +0000 (13:44 -0700)]
GcConcurrentTest: @Ignore flaky testInterruptGc

During my development of Id7721cc5b7ea650e77c2db47042715487983cae6, I
have found this test to be flaky when run by CI. As a speculative fix,
mark this test as @Ignore so it won't be run.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Change-Id: Idfe04d7f1fb72a772d4c8d249ca86a9c2eec0b1a

17 months agoFix CommitTemplateConfigTest 26/201526/1
Matthias Sohn [Wed, 26 Apr 2023 23:00:44 +0000 (01:00 +0200)]
Fix CommitTemplateConfigTest

The cherry-picked 61d4e313 doesn't match 5.13 APIs which changed in
newer versions.

Change-Id: I61ed0242472ed822028d86d3038f956f6bd5735c

17 months agoFix after_open config and Snapshotting RefDir tests to work with bazel 63/201463/3
Prudhvi Akhil Alahari [Mon, 24 Apr 2023 09:15:17 +0000 (14:45 +0530)]
Fix after_open config and Snapshotting RefDir tests to work with bazel

The changes I1db6fcf414b and I634b92877f added tests which were failing
with errors [1] and [2] with "bazel test //...". This was not caught
because we don't have CI running with bazel. Fix bazel build file so
that these errors are no longer thrown when run with bazel.

[1] error: cannot find symbol FileRepositoryBuilderTest
[2] error: cannot find symbol RefDirectoryTest

Bug: 581816
Signed-off-by: Prudhvi Akhil Alahari <quic_prudhvi@quicinc.com>
Change-Id: I1e57111662825f5f14f373bc4f8d24cce1fec0b8

17 months agoMerge branch 'stable-6.0' into stable-6.1 78/201478/2
Matthias Sohn [Wed, 26 Apr 2023 19:55:16 +0000 (21:55 +0200)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory
  Demote severity of some error prone bug patterns to warnings
  UploadPack: Fix NPE when traversing a tag chain

Change-Id: I5e13d5b5414aef97e518898166bfa166c692e60f

17 months agoMerge branch 'stable-5.13' into stable-6.0 21/201521/1
Matthias Sohn [Wed, 26 Apr 2023 19:40:22 +0000 (21:40 +0200)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory
  Demote severity of some error prone bug patterns to warnings

Change-Id: I63b9adc22e1e1d9a9c754fe070ddfe21a52446c7

17 months ago[bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory 20/201520/1
Matthias Sohn [Wed, 12 Jan 2022 22:45:34 +0000 (23:45 +0100)]
[bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory

Move this test to another class and skip it when running tests with
bazel since the bazel test runner does not allow to create files in the
home directory.

FS#userHome retrieves the home directory on the first call and caches it
for subsequent calls to avoid overhead in case path translation is
required (currently on cygwin). This prevents that the test can mock the
home directory using MockSystemReader like SshTestHarness does.

Change-Id: I6a22f37f4a19eb4b4935509eae508a23e56db7aa

17 months agoDemote severity of some error prone bug patterns to warnings 19/201519/1
David Ostrovsky [Wed, 26 Apr 2023 08:08:25 +0000 (10:08 +0200)]
Demote severity of some error prone bug patterns to warnings

The code is not violation free, so demote the severity of these bug
patterns to warning:

o DefaultCharset
o FutureReturnValueIgnored
o UnusedException

Change-Id: Ie886a4a247770a74953385f018498ac2515ed209

17 months agoUploadPack: Fix NPE when traversing a tag chain 08/201108/6
Kaushik Lingarkar [Wed, 5 Apr 2023 01:05:53 +0000 (18:05 -0700)]
UploadPack: Fix NPE when traversing a tag chain

Always parse RevTags including their body before getting their object
to ensure that non-cached objects are handled correctly when traversing
a tag chain. An NPE in UploadPack#addTagChain will occur on a depth=1
fetch of a branch containing a tag chain and the ref to one of the
middle tags in the chain is deleted.

Change-Id: Ifd8fe868869070b365df926fec5dcd8e64d4f521
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
17 months agoMerge branch 'stable-6.2' into stable-6.3 26/201426/1
Matthias Sohn [Thu, 20 Apr 2023 22:25:51 +0000 (00:25 +0200)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Add missing since tag for SshBasicTestBase
  Add missing since tag for SshTestHarness#publicKey2
  Silence API errors
  Prevent infinite loop rescanning the pack list on PackMismatchException
  Remove blank in maven.config

Change-Id: I8006068f16ae442a2246e043a680053f2af34e9f

17 months agoMerge branch 'stable-6.1' into stable-6.2 25/201425/1
Matthias Sohn [Thu, 20 Apr 2023 22:19:38 +0000 (00:19 +0200)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Add missing since tag for SshBasicTestBase
  Add missing since tag for SshTestHarness#publicKey2
  Silence API errors
  Prevent infinite loop rescanning the pack list on PackMismatchException
  Remove blank in maven.config

Change-Id: I4c5b000b09287cc32f0e4d6a24a766ef4e17ddbe

17 months agoMerge branch 'stable-6.0' into stable-6.1 24/201424/1
Matthias Sohn [Thu, 20 Apr 2023 22:11:40 +0000 (00:11 +0200)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Add missing since tag for SshBasicTestBase
  Add missing since tag for SshTestHarness#publicKey2
  Silence API errors
  Prevent infinite loop rescanning the pack list on PackMismatchException
  Remove blank in maven.config

Change-Id: Ia01c5ac5259b8820afb823d97bee247b5a5fb14a

17 months agoMerge branch 'stable-5.13' into stable-6.0 23/201423/1
Matthias Sohn [Thu, 20 Apr 2023 14:01:33 +0000 (16:01 +0200)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Add missing since tag for SshBasicTestBase
  Add missing since tag for SshTestHarness#publicKey2
  Silence API errors
  Prevent infinite loop rescanning the pack list on
PackMismatchException
  Remove blank in maven.config

Change-Id: Id37bee59ca3c7947604c54b6d4e7c02628a657fe

17 months agoMerge branch 'stable-5.12' into stable-5.13 16/201416/1
Matthias Sohn [Thu, 20 Apr 2023 13:40:36 +0000 (15:40 +0200)]
Merge branch 'stable-5.12' into stable-5.13

* stable-5.12:
  Add missing since tag for SshBasicTestBase
  Add missing since tag for SshTestHarness#publicKey2
  Silence API errors
  Prevent infinite loop rescanning the pack list on
PackMismatchException
  Remove blank in maven.config

Change-Id: Ibe6652374ab5971105e62b05279f218c8c130fee

17 months agoMerge branch 'stable-5.11' into stable-5.12 15/201415/1 stable-5.12
Matthias Sohn [Thu, 20 Apr 2023 13:12:01 +0000 (15:12 +0200)]
Merge branch 'stable-5.11' into stable-5.12

* stable-5.11:
  Add missing since tag for SshBasicTestBase
  Add missing since tag for SshTestHarness#publicKey2
  Silence API errors
  Prevent infinite loop rescanning the pack list on PackMismatchException
  Remove blank in maven.config

Change-Id: I25bb99687b969f9915a7cbda8d1332bec778096a

17 months agoAdd missing since tag for SshBasicTestBase 14/201414/2 stable-5.11
Matthias Sohn [Thu, 20 Apr 2023 12:46:05 +0000 (14:46 +0200)]
Add missing since tag for SshBasicTestBase

Change-Id: Iad8ae9bb526418b279dc54a5e9d0c877c1eca475

17 months agoMerge branch 'stable-5.10' into stable-5.11 13/201413/2
Matthias Sohn [Thu, 20 Apr 2023 12:42:56 +0000 (14:42 +0200)]
Merge branch 'stable-5.10' into stable-5.11

* stable-5.10:
  Add missing since tag for SshTestHarness#publicKey2
  Silence API errors
  Prevent infinite loop rescanning the pack list on
PackMismatchException
  Remove blank in maven.config

Migrated "Prevent infinite loop rescanning the pack list on
PackMismatchException" to refactoring done in
https://git.eclipse.org/r/q/topic:restore-preserved-packs

Change-Id: I0fb77bb9b498d48d5da88a93486b99bf8121e3bd

17 months agoAdd missing since tag for SshTestHarness#publicKey2 12/201412/1 stable-5.10
Matthias Sohn [Thu, 20 Apr 2023 12:35:58 +0000 (14:35 +0200)]
Add missing since tag for SshTestHarness#publicKey2

Change-Id: Ib6e4945340d2e1761dc0e787bdbe72286cdc95bc

17 months agoSilence API errors 11/201411/1
Matthias Sohn [Thu, 20 Apr 2023 12:37:46 +0000 (14:37 +0200)]
Silence API errors

Change-Id: I367c05c43df3385c33ce76bc10b2dc3bd330665c

17 months agoMerge branch 'stable-5.9' into stable-5.10 10/201410/2
Matthias Sohn [Thu, 20 Apr 2023 07:52:30 +0000 (09:52 +0200)]
Merge branch 'stable-5.9' into stable-5.10

* stable-5.9:
  Prevent infinite loop rescanning the pack list on
PackMismatchException
  Remove blank in maven.config

Change-Id: I15ff2d7716ecaceb0eb87b8823d85670f5db709d

17 months agoPrevent infinite loop rescanning the pack list on PackMismatchException 78/200978/6 stable-5.9
Matthias Sohn [Thu, 30 Mar 2023 11:43:17 +0000 (13:43 +0200)]
Prevent infinite loop rescanning the pack list on PackMismatchException

We found, when analysing an incident where Gerrit's gc runner thread got
stuck, that we can end up in an infinite loop in
ObjectDirectory#openPackedObject which tries to rescan the pack
list and starts over trying to open a packed object in an unconfined
loop if it catches a PackMismatchException.

Here the relevant part of a thread dump we created while the gc runner
was stuck:

"WorkQueue-2[java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@350812a3[Not
completed,
task = java.util.concurrent.Executors$RunnableAdapter@5425d7ee]]" #72
tid=0x00007f73cee1c800 nid=0x584
runnable  [0x00007f7392d57000]
   java.lang.Thread.State: RUNNABLE
at org.eclipse.jgit.internal.storage.file.WindowCache.removeAll(WindowCache.java:716)
at org.eclipse.jgit.internal.storage.file.WindowCache.purge(WindowCache.java:399)
at org.eclipse.jgit.internal.storage.file.PackFile.close(PackFile.java:296)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.reuseMap(ObjectDirectory.java:973)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.scanPacksImpl(ObjectDirectory.java:904)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.scanPacks(ObjectDirectory.java:895)
- locked <0x000000050a498f60> (a
java.util.concurrent.atomic.AtomicReference)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.searchPacksAgain(ObjectDirectory.java:794)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openPackedObject(ObjectDirectory.java:465)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openPackedFromSelfOrAlternate(ObjectDirectory.java:417)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openObject(ObjectDirectory.java:408)
at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:132)
at org.eclipse.jgit.lib.ObjectReader$1.open(ObjectReader.java:279)
at org.eclipse.jgit.revwalk.RevWalk$2.next(RevWalk.java:1031)
at org.eclipse.jgit.internal.storage.pack.PackWriter.findObjectsToPack(PackWriter.java:1911)
at org.eclipse.jgit.internal.storage.pack.PackWriter.preparePack(PackWriter.java:960)
at org.eclipse.jgit.internal.storage.pack.PackWriter.preparePack(PackWriter.java:876)
at org.eclipse.jgit.internal.storage.file.GC.writePack(GC.java:1168)
at org.eclipse.jgit.internal.storage.file.GC.repack(GC.java:852)
at org.eclipse.jgit.internal.storage.file.GC.doGc(GC.java:269)
at org.eclipse.jgit.internal.storage.file.GC.gc(GC.java:220)
at org.eclipse.jgit.api.GarbageCollectCommand.call(GarbageCollectCommand.java:179)
at com.google.gerrit.server.git.GarbageCollection.run(GarbageCollection.java:112)
at com.google.gerrit.server.git.GarbageCollection.run(GarbageCollection.java:75)
at com.google.gerrit.server.git.GarbageCollection.run(GarbageCollection.java:71)
at com.google.gerrit.server.git.GarbageCollectionRunner.run(GarbageCollectionRunner.java:76)
at com.google.gerrit.server.logging.LoggingContextAwareRunnable.run(LoggingContextAwareRunnable.java:103)
at java.util.concurrent.Executors$RunnableAdapter.call(java.base@11.0.18/Executors.java:515)
at java.util.concurrent.FutureTask.runAndReset(java.base@11.0.18/FutureTask.java:305)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(java.base@11.0.18/ScheduledThreadPoolExecutor.java:305)
at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:612)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.18/ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.18/ThreadPoolExecutor.java:628)
at java.lang.Thread.run(java.base@11.0.18/Thread.java:829)

The code in ObjectDirectory#openPackedObject [1] apparently assumes that
this is caused by a transient problem which it can resume from by
retrying. We use `core.trustFolderStat = false` on this server since it
uses NFS. The incident we had showed that we can enter into an infinite
loop here if there is a permanent mismatch between a pack file and its
corresponding pack index. I am not yet sure how this can happen.

Break the infinite loop by limiting the number of attempts rescanning
the pack list to 5 retries.  When we exceed this threshold set the type
of the PackMismatchException to permanent and rethrow it which breaks
the infinite loop.

Also apply the same limit in #getPackedObjectSize
and #selectObjectRepresentation where we use similar retry loops.

[1] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/011c26ff36b9e76c84fc2459e337f159c0f55a9a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java#465

Change-Id: I20fb63bcc1fdc3a03d39b963f06a90e6f0ba73dc

17 months agoRemove blank in maven.config 03/201403/1
Matthias Sohn [Fri, 14 Apr 2023 16:13:18 +0000 (18:13 +0200)]
Remove blank in maven.config

Maven 3.9.1 doesn't accept this whitespace.

Change-Id: I0f6e3652b1e581615c370d35bc782184712ac922

18 months agoMerge branch 'stable-6.2' into stable-6.3 44/201344/1
Matthias Sohn [Sat, 15 Apr 2023 19:35:16 +0000 (21:35 +0200)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Remove blank in maven.config
  DirCache: support option index.skipHash

Change-Id: If0bb5f1a317ab981e6bbf5671851f124b18ab8ca

18 months agoMerge branch 'stable-6.1' into stable-6.2 43/201343/1
Matthias Sohn [Sat, 15 Apr 2023 19:34:41 +0000 (21:34 +0200)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Remove blank in maven.config
  DirCache: support option index.skipHash

Change-Id: Ief50a2ca8e5a8630627506f4d2142d62c0554615

18 months agoMerge branch 'stable-6.0' into stable-6.1 42/201342/1
Matthias Sohn [Fri, 14 Apr 2023 22:49:59 +0000 (00:49 +0200)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Remove blank in maven.config
  DirCache: support option index.skipHash

Change-Id: Idf757bcab0d7a65ea63504674a681170c6db2f94

18 months agoMerge branch 'stable-5.13' into stable-6.0 36/201336/1
Matthias Sohn [Fri, 14 Apr 2023 22:49:08 +0000 (00:49 +0200)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Remove blank in maven.config
  DirCache: support option index.skipHash

Change-Id: I0cc3033b1876c8c691c2a6876206cd71fa07d2e0

18 months agoRemove blank in maven.config 35/201335/1
Matthias Sohn [Fri, 14 Apr 2023 16:13:18 +0000 (18:13 +0200)]
Remove blank in maven.config

Maven 3.9.1 doesn't accept this whitespace.

Change-Id: I0f6e3652b1e581615c370d35bc782184712ac922

18 months agoDirCache: support option index.skipHash 16/200916/2
Matthias Sohn [Mon, 27 Mar 2023 20:23:11 +0000 (22:23 +0200)]
DirCache: support option index.skipHash

Support the new option index.skipHash which was introduced in git 2.40
[1]. If it is set to true skip computing the git index checksum. This
accelerates Git commands that manipulate the index, such as git add, git
commit, or git status. Instead of storing the checksum, write a trailing
set of bytes with value zero, indicating that the computation was
skipped.

Accept a skipped checksum consisting of 20 null bytes when reading the
index since the option could have been set to true at the time when the
index was written.

[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-indexskipHash

Bug: 581723
Change-Id: I28ebe44c5ca1cbcb882438665d686452a0c111b2

18 months agoMerge branch 'stable-6.2' into stable-6.3 93/200793/1
Matthias Sohn [Thu, 23 Mar 2023 08:06:43 +0000 (09:06 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  GC: Close File.lines stream

Change-Id: Id93b1933a5ce1ede9eb388c9fd54a4b3749694bf

18 months agoMerge branch 'stable-6.1' into stable-6.2 92/200792/1
Matthias Sohn [Thu, 23 Mar 2023 08:06:16 +0000 (09:06 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  GC: Close File.lines stream

Change-Id: Ia2be0b05ed860125a388b01d6c291832f08dd990

18 months agoMerge branch 'stable-6.0' into stable-6.1 91/200791/1
Matthias Sohn [Thu, 23 Mar 2023 08:05:42 +0000 (09:05 +0100)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  GC: Close File.lines stream

Change-Id: I2f9e6da5584a40bb4b4efed0b87ae456f119d757

18 months agoMerge branch 'stable-5.13' into stable-6.0 90/200790/1
Matthias Sohn [Thu, 23 Mar 2023 08:04:50 +0000 (09:04 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  GC: Close File.lines stream

Change-Id: Ib473750e5a3ad3d74b0cb41f25052890f50a975c

18 months agoGC: Close File.lines stream 89/200789/2
Xing Huang [Tue, 21 Mar 2023 22:27:49 +0000 (17:27 -0500)]
GC: Close File.lines stream

From File#lines javadoc: The returned stream from File Lines
encapsulates a Reader. If timely disposal of file system resources is
required, the try-with-resources construct should be used to ensure
that the stream's close method is
invoked after the stream operations are completed.

Wrap File.lines with try-with-resources.

Change-Id: I82c6faa3ef1083f6c7e964f96e9540b4db18eee8
Signed-off-by: Xing Huang <xingkhuang@google.com>
(cherry picked from commit 172a207945da376b6b4143305aef2af56f7c42e2)

19 months agoMerge branch 'stable-6.2' into stable-6.3 18/200318/1
Matthias Sohn [Fri, 3 Mar 2023 15:02:16 +0000 (16:02 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Improve test coverage when core.trustPackedRefsStat set to after_open

Change-Id: I02d7444b28b662eb46f3d0ba1a62d342820bed1f

19 months agoMerge branch 'stable-6.1' into stable-6.2 17/200317/1
Matthias Sohn [Fri, 3 Mar 2023 15:01:26 +0000 (16:01 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Improve test coverage when core.trustPackedRefsStat set to after_open

Change-Id: I63ba388ee2e174019733e63f8177792e1808a5c3

19 months agoImprove test coverage when core.trustPackedRefsStat set to after_open 04/200304/1
Prudhvi Akhil Alahari [Thu, 2 Mar 2023 11:21:48 +0000 (16:51 +0530)]
Improve test coverage when core.trustPackedRefsStat set to after_open

As of today, we don't have test coverage for RefDirectory when
core.trustPackedRefsStat config is set to after_open. Thus create new
test classes which set core.trustPackedRefsStat config to after_open in
setup and extend RefDirectoryTest and FileRepositoryBuilderTest
respectively.

Change-Id: I1db6fcf414bc488106ad4c85fb934480f299c995
Signed-off-by: Prudhvi Akhil Alahari <quic_prudhvi@quicinc.com>
19 months agoMerge branch 'stable-6.2' into stable-6.3 24/200124/1
Matthias Sohn [Wed, 22 Feb 2023 20:03:52 +0000 (21:03 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  If tryLock fails to get the lock another gc has it
  Fix GcConcurrentTest#testInterruptGc
  Don't swallow IOException in GC.PidLock#lock
  Check if FileLock is valid before using or releasing it

Change-Id: I5b6b10622b61fde3f0f10455a74ae159a0b69082

19 months agoMerge branch 'stable-6.1' into stable-6.2 23/200123/1
Matthias Sohn [Wed, 22 Feb 2023 20:03:22 +0000 (21:03 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  If tryLock fails to get the lock another gc has it
  Fix GcConcurrentTest#testInterruptGc
  Don't swallow IOException in GC.PidLock#lock
  Check if FileLock is valid before using or releasing it

Change-Id: I3ffe92566cc145053bb762f612dd96bc6d542c62

19 months agoMerge branch 'stable-6.0' into stable-6.1 22/200122/1
Matthias Sohn [Wed, 22 Feb 2023 20:02:47 +0000 (21:02 +0100)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  If tryLock fails to get the lock another gc has it
  Fix GcConcurrentTest#testInterruptGc
  Don't swallow IOException in GC.PidLock#lock
  Check if FileLock is valid before using or releasing it

Change-Id: Idea23e555c024557d7e39a86efe25f609400b962

19 months agoMerge branch 'stable-5.13' into stable-6.0 21/200121/1
Matthias Sohn [Wed, 22 Feb 2023 20:02:09 +0000 (21:02 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  If tryLock fails to get the lock another gc has it
  Fix GcConcurrentTest#testInterruptGc
  Don't swallow IOException in GC.PidLock#lock
  Check if FileLock is valid before using or releasing it

Change-Id: I708d0936fa86b028e4da4e7e21f332f8b48ad293

19 months agoIf tryLock fails to get the lock another gc has it 19/200119/2
Matthias Sohn [Wed, 22 Feb 2023 19:36:39 +0000 (20:36 +0100)]
If tryLock fails to get the lock another gc has it

Change-Id: Ifd3bbcc5e0591883b774d23256949a83010ea134

19 months agoFix GcConcurrentTest#testInterruptGc 18/200118/2
Matthias Sohn [Wed, 22 Feb 2023 19:35:01 +0000 (20:35 +0100)]
Fix GcConcurrentTest#testInterruptGc

With the new GC.PidLock interrupting a running GC throws a
ClosedByInterruptException.

Change-Id: I7ccea1ae9a43d4edfdab2fcfd1324c64cc22b38f

19 months agoDon't swallow IOException in GC.PidLock#lock 06/200106/1
Matthias Sohn [Wed, 22 Feb 2023 18:27:30 +0000 (19:27 +0100)]
Don't swallow IOException in GC.PidLock#lock

This broke the test GcConcurrentTest#testInterruptGc which expects
ClosedByInterruptException when the thread doing gc is interrupted.

Change-Id: I89e02fc37aceeccb04c20cfc5b71cb8fa21793d6

19 months agoCheck if FileLock is valid before using or releasing it 71/200071/2
Matthias Sohn [Wed, 22 Feb 2023 01:42:32 +0000 (02:42 +0100)]
Check if FileLock is valid before using or releasing it

Change-Id: I23ba67b61b9b03772f33a929c080c0d02b8c8652

19 months agoMerge branch 'stable-6.2' into stable-6.3 66/200066/1
Matthias Sohn [Wed, 22 Feb 2023 00:27:50 +0000 (01:27 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Use Java 11 ProcessHandle to get pid of the current process
  Acquire file lock "gc.pid" before running gc
  Silence API errors introduced by 9424052f

Change-Id: I53cf9675deac0b588048d8224216d2a7e8bd16ec

19 months agoMerge branch 'stable-6.1' into stable-6.2 65/200065/1
Matthias Sohn [Wed, 22 Feb 2023 00:27:16 +0000 (01:27 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Use Java 11 ProcessHandle to get pid of the current process
  Acquire file lock "gc.pid" before running gc
  Silence API errors introduced by 9424052f

Change-Id: I0562a4a224779ccf1e4cc1ff8f5a352e55ab220a

19 months agoMerge branch 'stable-6.0' into stable-6.1 64/200064/1
Matthias Sohn [Wed, 22 Feb 2023 00:26:36 +0000 (01:26 +0100)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Use Java 11 ProcessHandle to get pid of the current process
  Acquire file lock "gc.pid" before running gc
  Silence API errors introduced by 9424052f

Change-Id: Ib9a2419253ffcbc90874adbfdb8129fee3178210

19 months agoUse Java 11 ProcessHandle to get pid of the current process 63/200063/1
Matthias Sohn [Wed, 22 Feb 2023 00:06:06 +0000 (01:06 +0100)]
Use Java 11 ProcessHandle to get pid of the current process

Change-Id: I790f218601c1d5e1b39c4101e3b2708e76b9d782

19 months agoMerge branch 'stable-5.13' into stable-6.0 62/200062/1
Matthias Sohn [Wed, 22 Feb 2023 00:00:26 +0000 (01:00 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Acquire file lock "gc.pid" before running gc
  Silence API errors introduced by 9424052f

Change-Id: Ibb5c46cb79377d2d2cd7d4586f31c86665d2851c

19 months agoAcquire file lock "gc.pid" before running gc 48/199848/4
Matthias Sohn [Fri, 10 Feb 2023 22:39:20 +0000 (23:39 +0100)]
Acquire file lock "gc.pid" before running gc

Git guards gc by locking a lock file "gc.pid" before starting execution.
The lock file contains the pid and hostname of the process holding the
lock. Git tries to kill the process holding that lock if the lock file
wasn't modified in the last 12 hours and was started from the same host.

Teach JGit to acquire this lock before running gc but skip execution if
another process already holds the lock. Killing the other process could
be undesired if it's a long running application.

If the lock file wasn't modified in the last 12 hours try to lock it and
run gc if locking succeeds.

Register a shutdown hook for the lock file to ensure it is cleaned up if
the process is gracefully killed.

Change-Id: I00b838dcbf4fb0d03863bf7a2cd86b743c6c6971

19 months agoSilence API errors introduced by 9424052f 37/200037/1
Matthias Sohn [Mon, 20 Feb 2023 21:32:37 +0000 (22:32 +0100)]
Silence API errors introduced by 9424052f

Change-Id: Ia9e619a8fa06648086b583c994e4b107ae06c44d

19 months agoMerge branch 'stable-6.2' into stable-6.3 26/200026/1
Matthias Sohn [Mon, 20 Feb 2023 19:59:14 +0000 (20:59 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Fix getPackedRefs to not throw NoSuchFileException
  Add pack options to preserve and prune old pack files
  Allow to perform PackedBatchRefUpdate without locking loose refs
  Document option "core.sha1Implementation" introduced in 59029aec

Change-Id: I765c7302ce84a6a9c28fdef29da2bfaa49477c6e

19 months agoMerge branch 'stable-6.1' into stable-6.2 25/200025/1
Matthias Sohn [Thu, 16 Feb 2023 15:59:56 +0000 (16:59 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Fix getPackedRefs to not throw NoSuchFileException
  Add pack options to preserve and prune old pack files
  Allow to perform PackedBatchRefUpdate without locking loose refs
  Document option "core.sha1Implementation" introduced in 59029aec

Change-Id: Id32683d5f506e082d39af269803bccee0280cc27

19 months agoMerge branch 'stable-6.0' into stable-6.1 67/199967/1
Matthias Sohn [Thu, 16 Feb 2023 15:56:07 +0000 (16:56 +0100)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Add pack options to preserve and prune old pack files
  Allow to perform PackedBatchRefUpdate without locking loose refs
  Document option "core.sha1Implementation" introduced in 59029aec

Change-Id: I876a38c2de8b7d5eaacd00e36b85599f88173221

19 months agoMerge branch 'stable-5.13' into stable-6.0 62/199962/2
Matthias Sohn [Thu, 16 Feb 2023 15:42:58 +0000 (16:42 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Add pack options to preserve and prune old pack files
  Allow to perform PackedBatchRefUpdate without locking loose refs
  Document option "core.sha1Implementation" introduced in 59029aec

Change-Id: I423f410578f5bbe178832b80fef8998a5372182c

19 months agoFix getPackedRefs to not throw NoSuchFileException 59/199959/1
Prudhvi Akhil Alahari [Thu, 16 Feb 2023 11:11:55 +0000 (16:41 +0530)]
Fix getPackedRefs to not throw NoSuchFileException

Since Files.newInputStream is from java.nio package, it throws
java.nio.file.NoSuchFileException. This was missed in the change
I00da88e. Without this change, getPackedRefs fails with
NoSuchFileException when there is no packed-refs file in a project.

Change-Id: I93c202ddb73a0a5979af8e4d09e45f5645664b45
Signed-off-by: Prudhvi Akhil Alahari <quic_prudhvi@quicinc.com>
20 months agoAdd pack options to preserve and prune old pack files 46/199846/2
Matthias Sohn [Fri, 10 Feb 2023 20:05:47 +0000 (21:05 +0100)]
Add pack options to preserve and prune old pack files

Add the options
- pack.preserveOldPacks
- pack.prunePreserved

This allows to configure in git config if old packs should be preserved
during gc and pruned during the next gc.

The original implementation in 91132bb0 only allows to set these options
using the API.

Change-Id: I5b23ab4f317d12f5ccd234401419913e8263cc9a

20 months agoAllow to perform PackedBatchRefUpdate without locking loose refs 58/199758/1
Saša Živkov [Fri, 21 Oct 2022 14:32:03 +0000 (16:32 +0200)]
Allow to perform PackedBatchRefUpdate without locking loose refs

Add another newBatchUpdate method in the RefDirectory where we can
control if the created PackedBatchRefUpdate will lock the loose refs or
not.

This can be useful in cases when we run programs which have exclusive
access to a Git repository and we know that locking loose refs is
unnecessary and just a performance loss.

Change-Id: I7d0932eb1598a3871a2281b1a049021380234df9
(cherry picked from commit cb90ed08526bd51f04e5d72e3ba3cf5bd30c11e4)

20 months agoDocument option "core.sha1Implementation" introduced in 59029aec 11/199711/2
Matthias Sohn [Wed, 1 Feb 2023 13:33:31 +0000 (14:33 +0100)]
Document option "core.sha1Implementation" introduced in 59029aec

Bug: 580310
Change-Id: I10f3d6f6b5af7ab96683994c9cbd85e6c18a5084

20 months agoMerge branch 'stable-6.2' into stable-6.3 86/199686/1
Matthias Sohn [Tue, 31 Jan 2023 23:59:32 +0000 (00:59 +0100)]
Merge branch 'stable-6.2' into stable-6.3

* stable-6.2:
  Shortcut during git fetch for avoiding looping through all local refs
  FetchCommand: fix fetchSubmodules to work on a Ref to a blob
  Silence API warnings introduced by I466dcde6
  Allow the exclusions of refs prefixes from bitmap
  PackWriterBitmapPreparer: do not include annotated tags in bitmap
  BatchingProgressMonitor: avoid int overflow when computing percentage
  Speedup GC listing objects referenced from reflogs
  FileSnapshotTest: Add more MISSING_FILE coverage

Change-Id: I2ff386d9a096277360e6c7bd5535b49984620fb3

20 months agoMerge branch 'stable-6.1' into stable-6.2 85/199685/1
Matthias Sohn [Tue, 31 Jan 2023 23:44:41 +0000 (00:44 +0100)]
Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Shortcut during git fetch for avoiding looping through all local refs
  FetchCommand: fix fetchSubmodules to work on a Ref to a blob
  Silence API warnings introduced by I466dcde6
  Allow the exclusions of refs prefixes from bitmap
  PackWriterBitmapPreparer: do not include annotated tags in bitmap
  BatchingProgressMonitor: avoid int overflow when computing percentage
  Speedup GC listing objects referenced from reflogs
  FileSnapshotTest: Add more MISSING_FILE coverage

Change-Id: Iff2fba026b49463016015b2fae1a42cf76ee2dbb

20 months agoMerge branch 'stable-6.0' into stable-6.1 84/199684/1
Matthias Sohn [Tue, 31 Jan 2023 23:38:52 +0000 (00:38 +0100)]
Merge branch 'stable-6.0' into stable-6.1

* stable-6.0:
  Shortcut during git fetch for avoiding looping through all local refs
  FetchCommand: fix fetchSubmodules to work on a Ref to a blob
  Silence API warnings introduced by I466dcde6
  Allow the exclusions of refs prefixes from bitmap
  PackWriterBitmapPreparer: do not include annotated tags in bitmap
  BatchingProgressMonitor: avoid int overflow when computing percentage
  Speedup GC listing objects referenced from reflogs
  FileSnapshotTest: Add more MISSING_FILE coverage

Change-Id: Ib5055f2f3b8a313c178d6f6c7c5630285ad5a726

20 months agoMerge branch 'stable-5.13' into stable-6.0 83/199683/1
Matthias Sohn [Tue, 31 Jan 2023 23:30:52 +0000 (00:30 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Shortcut during git fetch for avoiding looping through all local refs
  FetchCommand: fix fetchSubmodules to work on a Ref to a blob
  Silence API warnings introduced by I466dcde6
  Allow the exclusions of refs prefixes from bitmap
  PackWriterBitmapPreparer: do not include annotated tags in bitmap
  BatchingProgressMonitor: avoid int overflow when computing percentage
  Speedup GC listing objects referenced from reflogs
  FileSnapshotTest: Add more MISSING_FILE coverage

Change-Id: I58ad4c210a5e7e5a1ba6b22315b04211c8909950