Commit Graph

9748 Commits

Author SHA1 Message Date
Matthias Sohn 68c08265aa Add missing @since tags for new API methods
This was missed in d3b40e72ac.

Change-Id: I6e90157c6be34ae6618e246b02cf77631c8e9732
2023-07-25 23:22:46 +02:00
Matthias Sohn 8879eec460 Add missing package import needed to use MurmurHash3
This was missed in 49beb5ae51 and broke the OSGi classpath.

Change-Id: I08a307e9e3aade4ed8a5b5e2cc5e5d03c57dfa56
2023-07-25 22:06:27 +02:00
Jonathan Tan c77fb93478 Merge "Identify a commit that generates a diffEntry on a rename Event." 2023-07-25 12:09:40 -04:00
Ronald Bhuleskar ec3d919aa5 Identify a commit that generates a diffEntry on a rename Event.
When using FollowFilter's rename callback, a callback is generated with the diff. The caller that is interested in the renames knows what the diff's are but have no idea what commit generated that diff.

This will allow FollowFilter's rename callback to track diffEntry for a given commit.

Change-Id: If1e63ccd19fdcb9c58c59137110fe24e0ce023d2
2023-07-24 19:42:51 -04:00
Jonathan Tan 0f4af2bc36 Merge changes I60a92463,Ic3b68220
* changes:
  PackReverseIndexV1: reverse index parsed from version 1 file
  ComputedPackReverseIndex: Clarify custom bucket sort algorithm
2023-07-21 14:05:38 -04:00
Anna Papitto f196c7a0e8 Pack: open reverse index from file if present
The reverse index for a pack is still always computed if needed, which
is slower than parsing it from a file.

Supply the file path where the reverse index file might be so that it
parsed instead of computed if the file is present.

Change-Id: I8c60d970fd587341dfb2763fb87f1c586279f2a5
Signed-off-by: Anna Papitto <annapapitto@google.com>
2023-07-18 15:19:26 -07:00
Anna Papitto 000e7caf5e PackReverseIndexV1: reverse index parsed from version 1 file
The reverse index for a pack is used to quickly find an object's
position in the pack's forward index based on that object's pack offset.
It is currently computed from the forward index by sorting the index
entries by the corresponding pack offset. This computation uses
insertion sort, which has an average runtime of O(n^2).

Cgit persists a pack reverse index file
to avoid recomputing the reverse index ordering. Instead they write a
file with format
https://git-scm.com/docs/pack-format#_pack_rev_files_have_the_format
which can later be read and parsed into the in-memory reverse index
each time it is needed.

PackReverseIndexV1 parses a reverse index file with the official
version 1 format into an in-memory representation of the reverse index
which implements methods to find an object's forward index position
from its offset in logorithmic time.

Change-Id: I60a92463fbd6a8cc9c1c7451df1c14d0a21a0f64
Signed-off-by: Anna Papitto <annapapitto@google.com>
2023-07-18 15:19:26 -07:00
Anna Papitto 2eba4e5b41 PackReverseIndex: open file if present otherwise compute
The existing #read and #computeFromIndex static builder methods require
the caller to choose whether to supply an input stream of a reverse
index file or a forward index to compute the reverse index from, which
is slower.

Allow a caller to provide a file path where the pack's reverse index
might be and the pack's forward index index and simply get some reverse
index instance back. Prefer opening and parsing the file if it is
present, to save computation time. Otherwise, fall back onto computing
the reverse index from the pack's forward index.

Change-Id: I09bdd4b813ad62c86add586417b2ab86e9331aec
Signed-off-by: Anna Papitto <annapapitto@google.com>
2023-07-18 15:19:26 -07:00
Anna Papitto 8123dcd699 PackReverseIndex: verify checksums
The new version 1 file-based reverse index has a footer with the
checksum of the corresponding pack file and a checksum of its own
contents. The initial implementation doesn't enforce that the pack
checksum matches the checksum found in the forward index nor that the
self checksum matches the contents of the file just read in.

Offer a method for reverse index users to verify the checksums in a way
appropriate to the version being used. For the pre-existing computed
version, always succeed since it is not based on a file so there is no
possibility of corruption.

Check for corruption of the file itself during parsing the checksum
footer, by comparing the self checksum with the digest of the file
contents read.

Change-Id: I87ff3933cf1afa76663350400b616695e4966cb6
Signed-off-by: Anna Papitto <annapapitto@google.com>
2023-07-18 15:19:26 -07:00
Anna Papitto 7d2669587f ComputedPackReverseIndex: Clarify custom bucket sort algorithm
The ComputedPackReverseIndex uses a custom sorting algorithm, based on
bucket sort with insertion sort but with the data managed as a linked
list across two int arrays. This custom algorithm relies on the set of
values being sorted being exactly 0, ..., n-1; so that they can serve a
second purpose of being indexes into a second equally sized list.

This custom algorithm was introduced ~10 years ago in
6cc532a43c.
The original author is no longer an active contributor, so it is
valuable for the code to be readable, especially as there is currently
active work on reverse indexes.

Rename variables and add comments to clarify the algorithm and improve
readability. There are no functional changes to the algorithm.

Change-Id: Ic3b682203f20e06f9f865f81259e034230f9720a
Signed-off-by: Anna Papitto <annapapitto@google.com>
2023-07-18 15:19:20 -07:00
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