Commit Graph

9538 Commits

Author SHA1 Message Date
Ronald Bhuleskar 3b77e33ad8 CommitGraphWriter: add option for writing/using bloom filters
Currently, bloom filters are written and used without any way to turn
them off. Add a per-repo config variable to control whether bloom
filters are written. As for reading, add a JGit option to control this.
(A JGit option is used instead of a per-repo config variable as there is
usually no reason not to use the bloom filters if they are present, but
a global control to disable them is useful if there turns out to be an
issue with the implementation of bloom filters.)

The config that controls reading is the same as C Git, but the config
for writing is not: C Git has no config to control writing, but whether
bloom filters are written depends on whether bloom filters are already
present and what arguments are passed to "git commit-graph write". See
the manpage of "git commit-graph" for more information.

Change-Id: I1b7b25340387673506252b9260b22bfe147bde58
2023-07-18 14:21:48 -07:00
Jonathan Tan 77aec62141 CommitGraphWriter: reuse changed path filters
Teach CommitGraphWriter to reuse changed path filters that have been
read from the commit graph file whenever possible.

Change-Id: I1acbfa1613ca7198386a49209028886af360ddb6
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2023-07-18 14:21:48 -07:00
Jonathan Tan d3b40e72ac RevWalk: use changed path filters
Teach RevWalk, TreeRevFilter, PathFilter, and FollowFilter to use
changed path filters, whenever available, to speed revision walks by
skipping commits that fail the changed path filter.

This work is based on earlier work by Kyle Zhao
(I441be984b609669cff77617ecfc838b080ce0816).

Change-Id: I7396f70241e571c63aabe337f6de1b8b9800f7ed
Signed-off-by: kylezhao <kylezhao@tencent.com>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2023-07-18 14:21:48 -07:00
Jonathan Tan ff0f7c174f CommitGraphLoader: read changed-path filters
As described in the parent commit, add support for reading the BIDX and
BDAT chunks of the commit graph file, as described in man gitformat-
commit-graph(5).

This work is based on earlier work by Kyle Zhao
(I160f6b022afaa842c331fb9a086974e49dced7b2).

Change-Id: I82e02e6a3a3b758e6bf9d7bbd2198f0ffe3a331b
Signed-off-by: kylezhao <kylezhao@tencent.com>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2023-07-18 14:21:48 -07:00
Jonathan Tan 49beb5ae51 CommitGraphWriter: write changed-path filters
Add support for writing the BIDX and BDAT chunks of the commit graph
file, as described in man gitformat-commit-graph(5). The ability to read
such chunks will be added in a subsequent commit.

This work is based on earlier work by Kyle Zhao
(Ib863782af209f26381e3ca0a2c119b99e84b679c).

Change-Id: Ic18e6f0eeec7da1e1ff31751aabda5e6952dbe6e
Signed-off-by: kylezhao <kylezhao@tencent.com>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2023-07-18 14:21:48 -07:00
Matthias Sohn 5dc63514d0 Merge "ssh: PKCS#11 support" 2023-07-17 18:13:06 -04:00
Thomas Wolf 23758d7a61 ssh: PKCS#11 support
Support PKCS#11 HSMs (like YubiKey PIV) for SSH authentication.

Use the SunPKCS11 provider as described at [1]. This provider
dynamically loads the library from the PKCS11Provider SSH configuration
and creates a Java KeyStore with that provider. A Java CallbackHandler
is needed to feed PIN prompts from the KeyStore into the JGit
CredentialsProvider framework. Because the JGit CredentialsProvider may
be specific to a SSH session but the PKCS11Provider may be used by
several sessions, the CallbackHandler needs to be configurable per
session.

PIN prompts respect the NumberOfPasswordPrompts SSH configuration. As
long as the library asks only for a PIN, we use the KeyPasswordProvider
to prompt for it. This gives automatic integration in Eclipse with the
Eclipse secure storage, so a user has even the option to store the PIN
there. (Eclipse will then ask for the secure storage master password on
first access, so the usefulness of this is debatable.)

By default the provider uses the first PKCS#11 token (slot list index
zero). This can be overridden by a non-standard PKCS11SlotListIndex
ssh configuration entry. (For OpenSSH interoperability, also set
"IgnoreUnknown PKCS11SlotListIndex" in the SSH config file then.)

Once loaded, the provider and its shared library and the keys
contained remain available until the application exits.

Manually tested using SoftHSM. See file manual_tests.txt. Kudos to
Christopher Lamb for additional manual testing with a real YubiKey,
also on Windows.[2]

[1] https://docs.oracle.com/en/java/javase/11/security/pkcs11-reference-guide1.html
[2] https://www.eclipse.org/forums/index.php/t/1113295/

Change-Id: I544c97e1e24d05e28a9f0e803fd4b9151a76ed11
Signed-off-by: Thomas Wolf <twolf@apache.org>
2023-07-17 04:52:30 -04:00
Matthias Sohn db08835c6c GC: Remove handling of extra pack for RefTree
RefTree was packed in its own packfile, see
Icbb735be8fa91ccbf0708ca3a219b364e11a6b83.

RefTree was deleted in Ia3da7f2b82d9e365cec2ccf9397cbc47439cd150, since
it was experimental and never used productively. This change missed to
remove the extra pack handling for RefTree.

Change-Id: I8c0d0a66440c331c3d03d0e07d5629682af2a7a9
2023-07-17 00:57:21 +02:00
Matthias Sohn f41c5e8c01 Remove unnecessary @SuppressWarnings("serial")
Change-Id: Ib07fd89541dbd4b5095d49b2696429cbacc5bb4c
2023-07-16 15:14:19 +02:00
Matthias Sohn 010a14f24d Remove unused API problem filters
Change-Id: Iea5fb0bf7b2c6a14d7d8b55558f6e78d3fd523f1
2023-07-16 15:13:05 +02:00
Matthias Sohn b2f7dc189a Remove redundant specification of type arguments
Change-Id: I8289e0a6ca9154d6411993d250176a35df7cb905
2023-07-16 15:11:17 +02:00
Ivan Frade 760bdd09b1 DfsPackParser: Create object indices if config says so
The DfsInserter writes the pack and its indices in the flush() method,
but when the writing happens via DfsPackParser, it is the parser which
writes the pack and indices. When combined with a parser, flushing the
inserter is a noop.

Add the writing of the object size index to the packparser#parse
method, mirroring how the primary index is written.

Change-Id: I52c5db153fea7e4a8ecd8b3d5de7ad21f7f81a60
2023-07-14 10:51:18 -07:00
Ivan Frade afb013b983 PackParserTest: Extract pack-writing helper code to its own class
PackParserTest has code to create a small pack in memory. We can use
it to test also the DfsPackParser.

Extract the helper functions to a new class (InMemoryPack).

Change-Id: I6dea4d6ea2cac2da8201702df92fd09a687e90a6
2023-07-14 10:34:56 -07:00
Ivan Frade cb99ff5bbb DfsInserter: generate object size index if config says so
DfsInserter receives objects and on flush() writes a pack and its
primary index.

Teach the DfsInserter to write also the object size index if the
config says so.

Change-Id: I89308312f8fd898d4c714a9b68ff948d3663800b
2023-07-14 10:34:46 -07:00
Ivan Frade 4d2a003b91 DfsInserter: populate full size on object insertion
We need the full size of the object to populate the object size index
later.

Save the size the PackedObjectInfo while adding objects to the
pack. Then we don't need to re-read it from the pack at indexing time.

Change-Id: I5bd7ad402df60b4637038def8ef7be2ab45faf87
2023-07-14 10:25:20 -07:00
Ivan Frade 12a4a4ccaa DFSGarbargeCollector: Write object size indices
PackWriter knows how to add an object size index to the pack, but the
garbage collector is not using it yet.

Teach DfsGarbageCollector to write the object size index on
writePack(). Disable by default in the unreachable-garbage pack.

Callers control the content/presence of the index through the
PackConfig option (minBytesForObjSizeIndex) for all other packs, so
there is no need of a specific flag in DfsGarbageCollector.

Change-Id: I86f5f17310e6913381125bec4caab32dc45b7c9d
2023-07-14 10:25:06 -07:00
Ivan Frade 9dace2e6d6 DfsReader/PackFile: Implement isNotLargerThan using the obj size idx
isNotLargerThan() can avoid reading the size of a blob from disk using
the object size idx if available.

Load the object size index in the DfsPackfile following the same
pattern than the other indices. Override isNotLargerThan in DfsReader
to use the index when available.

Following CL introduces the writing of the object size index and the
tests cover this code.

Change-Id: I15c95b84c1424707c487a7d29c5c46b1a9d0ceba
2023-07-13 11:24:17 -07:00
Thomas Wolf 8a053b57ad [releng] Use tycho 4.0.0 instead of 4.0.0-SNAPSHOT
Now that it is released there is no need anymore to use a snapshot
version.

Change-Id: Idd35c48022370abf18049ef4b6ddd6253613888e
Signed-off-by: Thomas Wolf <twolf@apache.org>
2023-07-11 18:24:35 +02:00
Luca Milanesio 88ca88a32b 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
2023-07-05 15:30:11 +02:00
Luca Milanesio 3a6eec9bb6 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] dafcb8f6db/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java (506)

Bug: 582039
Change-Id: Id722e68d9ff4ac24e73bf765ab11017586b6766e
2023-07-05 15:30:11 +02:00
Luca Milanesio ac8d7838f0 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
2023-07-05 15:28:16 +02:00
Matthias Sohn dceebe350e Update mockito to 5.4.0 and bytebuddy to 1.14.5
Change-Id: Ia9de3f9fb6f51ac55a7c551cab4ce199318c1114
2023-07-02 19:16:14 +02:00
Matthias Sohn d443588239 Merge branch 'stable-6.6'
* stable-6.6:
  Update Orbit to R20230531010532 for 2023-06
  Bazel: Fix remote build execution for Java 17
  Bump bazel vesion to 6.2.0

Change-Id: I107eb2cd1ce3cb7670e7418ffd74a7b94ab858a6
2023-07-01 09:13:48 +02:00
qin shulei 79b46a0ef0 Fix S3Repository getSize to handle larger object sizes
Update `getSize` method in `S3Repository` to handle larger object sizes.
The method previously used `Integer.parseInt`
to parse the `Content-Length` header of an HTTP response,

which limited the maximum object size to 2 GB.

Replaces `Integer.parseInt` with `Long.parseLong`,
allowing the method to handle object sizes larger than 2 GB.

- Use minio as local S3 service for gerrit lfs plugin
- The minio seems will return the Content-length

Change-Id: Ia3a5fd1a335643786714aff3fcc7d10a6b152058
Signed-off-by: qin shulei <qinsl0106@thundersoft.com>
2023-06-29 11:00:35 +08:00
Anna Papitto 91b23cc552 DfsPackFile: make #getReverseIdx public
The DfsPackFile#getReverseIdx method, which wraps creating a
PackReverseIndex in caching, was package-private. This caused
implementations on top of DfsPackFile to directly instantiate a
PackReverseIndex in cases where it would benefit from caching.

Instead, make #getReverseIdx public so that the caching logic can be
reused by implementations where appropriate.

Change-Id: I4553e514a4ac320bfe2455c00023343ad97f9d15
Signed-off-by: Anna Papitto <annapapitto@google.com>
2023-06-27 13:25:29 -07:00
Matthias Sohn 55230e2b95 Add missing bazel dependency to benchmarks
Change-Id: I330cbdbe7fdd2e3523cfc555adb15b577e858083
2023-06-27 14:43:48 +02:00
Matthias Sohn 4d5f2ada5e Update JMH to 1.36
Change-Id: Ie5cbbbae59fac9b0044808bd098d47f530126c67
2023-06-27 14:43:48 +02:00
Matthias Sohn 00fa17680e Update bouncycastle to 1.75
Change-Id: I7538759005b9a4eb8f1ae9337ce0056500eb7227
2023-06-27 14:43:48 +02:00
Matthias Sohn d2f1145890 Update org.eclipse.jdt:ecj to 3.34.0
Change-Id: I59715e1abfdefdf883290557806a9a1cbb34c3b3
2023-06-27 14:30:18 +02:00
Matthias Sohn 8f1693c2dc Update eclipse-jarsigner-plugin to 1.4.2
Change-Id: I3f92a32ccf795ae8c6c4e1699d0040ac84d743c2
2023-06-27 13:42:46 +02:00
Matthias Sohn 23a0e7e06c Update maven-surefire-report-plugin to 3.0.0
Change-Id: Id1f33c85045d280ac7238a9f1ba63a7c19f0e455
2023-06-27 13:10:36 +02:00
Matthias Sohn 6eb5a4cc81 Update maven-project-info-reports-plugin to 3.4.3
Change-Id: I1bd92105af3cc8eb2e6116677e50365702b58f5c
2023-06-27 13:08:53 +02:00
Matthias Sohn 9a60f7f7a8 Update maven-compiler-plugin to 3.11.0
Change-Id: Ia63fd770ebb8b44dcb3e09721c890fc2b42cbcec
2023-06-27 13:07:33 +02:00
Matthias Sohn 5fcd681ace Update maven-enforcer-plugin to 3.3.0
Change-Id: I9ad8bf71a492017ba3d71b527acd02ad22612fb9
2023-06-27 13:06:11 +02:00
Matthias Sohn 6250020fa4 Update build-helper-maven-plugin to 3.4.0
Change-Id: I9b5e8a6b0baebd67d84f48d95b83c6c802829aea
2023-06-27 10:54:05 +02:00
Matthias Sohn a00f1663dc Update spring-boot-maven-plugin to 2.7.13
Change-Id: I9d28540971a9c45f961ccfef1123a0a4ba3f88f2
2023-06-27 10:42:50 +02:00
Matthias Sohn d32352a447 Update maven-source-plugin to 3.3.0
Change-Id: I4735538aeeb92a01009aad1ca837cb636dcd4b93
2023-06-27 10:25:45 +02:00
Matthias Sohn dd92c1aa98 Prepare 5.13.3-SNAPSHOT builds
Change-Id: I02b9388c8bc1c266bb29b4502504d137dd42142f
2023-06-22 02:15:21 +02:00
Matthias Sohn 5aa8a7e276 JGit v5.13.2.202306221912-r
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Change-Id: Id0ee779fba85a6d5557f6319969adb2c74feebcf
2023-06-22 01:12:05 +02:00
Anna Papitto 8e61971620 PackReverseIndex: separate out the computed implementation
PackReverseIndex is a concrete class whose implementation is computed
from a pack's forward index. Callers which have a reverse index file may
want to use an implementation that is file-based instead.

Generalize PackReverseIndex into an interface without
implementation-specific logic and separate out the logic for the
computed implementation into a new concrete class.

Change-Id: I98d9835363c5e1c8c3c11a81b0761af3cdeaa41a
Signed-off-by: Anna Papitto <annapapitto@google.com>
2023-06-21 14:04:12 -07:00
Thomas Wolf faefa90f99 Default for global (user) git ignore file
C git has a default for git config core.excludesfile: "Its default
value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either
not set or empty, $HOME/.config/git/ignore is used instead." [1]

Implement this in the WorkingTreeIterator$RootIgnoreNode.

To make this testable, mock the "user.home" directory for all JGit
tests, otherwise tests might pick up a real user's git ignore file.
Also ensure that JGit code always reads "user.home" via the
SystemReader.

Add tests for both locations.

[1] https://git-scm.com/docs/gitignore#_description

Bug: 436127
Change-Id: Ie510259320286c3c13a6464a37da1bd9ca1e373a
Signed-off-by: Thomas Wolf <twolf@apache.org>
2023-06-19 08:19:29 +02:00
Antoine Musso 7b955048eb Fix all Javadoc warnings and fail on them
This fixes all the javadoc warnings, stops ignoring doclint 'missing'
category and fails the build on javadoc warnings for public and
protected classes and class members.

Since javadoc doesn't allow access specifiers when specifying doclint
configuration we cannot set `-Xdoclint:all,-missing/private`
hence there is no simple way to skip private elements from doclint.
Therefore we check javadoc using the Eclipse Java compiler
(which is used by default) and javadoc configuration in
`.settings/org.eclipse.jdt.core.prefs` files.
This allows more fine grained configuration.

We can reconsider this when javadoc starts supporting access specifiers
in the doclint configuration.

Below are detailled explanations for most modifications.

@inheritDoc
===========
doclint complains about explicits `{@inheritDoc}` when the parent does
not have any documentation. As far as I can tell, javadoc defaults to
inherit comments and should only be used when one wants to append extra
documentation from the parent. Given the parent has no documentation,
remove those usages which doclint complains about.

In some case I have moved up the documentation from the concrete class
up to the abstract class.

Remove `{@inheritDoc}` on overriden methods which don't add additional
documentation since javadoc defaults to inherit javadoc of overridden
methods.

@value to @link
===============
In PackConfig, DEFAULT_SEARCH_FOR_REUSE_TIMEOUT and similar are forged
from Integer.MAX_VALUE and are thus not considered constants (I guess
cause the value would depends on the platform). Replace it with a link
to `Integer.MAX_VALUE`.

In `StringUtils.toBoolean`, @value was used to refer to the
`stringValue` parameter. I have replaced it with `{@code stringValue}`.

{@link <url>} to <a>
====================
@link does not support being given an external URL. Replaces them with
HTML `<a>`.

@since: being invalid
=====================

org.eclipse.jgit/src/org/eclipse/jgit/util/Equality.java has an invalid
tag `@since: ` due to the extra `:`. Javadoc does not complain about it
with version 11.0.18+10 but does with 11.0.19.7. It is invalid
regardless.

invalid HTML syntax
===================

- javadoc doesn't allow <br/>, <p/> and </p> anymore, use <br> and <p>
instead
- replace <tt>code</tt> by {@code code}
- <table> tags don't allow summary attribute, specify caption as
<caption>caption</caption> to fix this

doclint visibility issue
========================

In the private abstract classes `BaseDirCacheEditor` and
`BasePackConnection` links to other methods in the abstract class are
inherited in the public subclasses but doclint gets confused and
considers them unreachable. The HTML documentation for the sub classes
shows the relative links in the sub classes, so it is all correct. It
must be a bug somewhere in javadoc.
Mute those warnings with: @SuppressWarnings("doclint:missing")

Misc
====
Replace `<` and `>` with HTML encoded entities (`&lt; and `&gt;`).
In `SshConstants` I went enclosing a serie of -> arrows in @literal.

Additional tags
===============
Configure maven-javad0c-plugin to allow the following additional tags
defined in https://openjdk.org/jeps/8068562:
- apiNote
- implSpec
- implNote

Missing javadoc
===============
Add missing @params and descriptions

Change-Id: I840056389aa59135cfb360da0d5e40463ce35bd0
Also-By: Matthias Sohn <matthias.sohn@sap.com>
2023-06-16 01:08:13 +02:00
Antoine Musso c7960910f0 Mark COMMIT_GENERATION_* constants final
In org.eclipse.jgit.lib.Constants the constants are all marked final
with the exception of:

- COMMIT_GENERATION_UNKOWN
- COMMIT_GENERATION_NOT_COMPUTED

They were introduced by cf70e7cbe4 without the `final` keyword while
other constants have it which certainly has been forgotten.

The javadoc `{@value}` tag causes raises a warning about the fields not
being constants which is how I have discovered the ommission.

Change-Id: I0ad87f42355440c7d50158e773a280a0526e9671
2023-06-09 16:40:35 +02:00
Matthias Sohn 6f4f7e911f Update Orbit to R20230531010532 for 2023-06
Change-Id: I844efc4bec153931f0a7b3c694bade4f5b166295
2023-06-09 10:52:45 +02:00
Matthias Sohn f19d29a13d Merge "Merge branch 'stable-6.5' into stable-6.6" into stable-6.6 2023-06-08 16:36:55 -04:00
Luca Milanesio ff4caff26a Merge branch 'stable-6.6'
* stable-6.6:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: I6011c20b1aca179126393b0e03fbfb0ba1b6d64c
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
2023-06-08 00:28:55 +01:00
Luca Milanesio 5074a31510 Merge branch 'stable-6.5' into stable-6.6
* stable-6.5:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: Ia2f6f41f27ab430c31871a2cf2cd99dfcbfd9b61
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
2023-06-08 00:28:20 +01:00
Luca Milanesio ff581f51e9 Merge branch 'stable-6.4' into stable-6.5
* stable-6.4:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: I7d922a92b7674723cbf6a93fb7c9bc5c0cdb8206
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
2023-06-08 00:27:49 +01:00
Luca Milanesio b6237ca8b6 Merge branch 'stable-6.3' into stable-6.4
* stable-6.3:
  Revert "RefDirectory: Throw exception if CAS of packed ref list fails"

Change-Id: I33049e70595f097a66e8f4a63b3d8d1c147e878e
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
2023-06-08 00:27:00 +01:00
Luca Milanesio 880f1234b2 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>
2023-06-08 00:26:04 +01:00