]> source.dussan.org Git - jgit.git/log
jgit.git
18 months agoAdd protocol configuration to Amazon S3 transport 17/201117/3
Pat Patterson [Thu, 6 Apr 2023 15:05:56 +0000 (08:05 -0700)]
Add protocol configuration to Amazon S3 transport

Before this change, attempting to use the jgit Amazon S3 transport with an S3-compatible service that requires https (for example, Backblaze B2) results in an error:

$ jgit push b2
fatal: amazon-s3://metadaddy-jgit/repos/test/objects: error in packed-refs

This change adds a "protocol" property to the Amazon S3 transport configuration, defaulting to http, and uses that value when constructing the URL for the S3 service.

Example configuration for Backblaze B2:

accesskey: <Your B2 Application Key>
secretkey: <Your B2 Application Key Id>
acl: private
protocol: https
domain: s3.us-west-004.backblazeb2.com
region: us-west-004
aws.api.signature.version: 4

Behavior after this change:

$ jgit push b2
Counting objects:       3
Finding sources:        100% (3/3)
Getting sizes:          100% (2/2)
Compressing objects:    100% (37/37)
Writing objects:        100% (3/3)
Put pack-673f9bb.idx:   100% (1/1)
To amazon-s3://.jgit_b2@metadaddy-jgit/repos/test
 * [new branch]      main -> main

Change-Id: I03bdbb3510fb81a416c225a720178f42eec41b21

18 months ago[pgm] Implement git tag --contains option 78/201178/4
Matthias Sohn [Sun, 9 Apr 2023 20:49:58 +0000 (22:49 +0200)]
[pgm] Implement git tag --contains option

Change-Id: I390bcd2c2c563d4b27e1369f09548be59ba7c111

18 months agoListTagCommand: implement git tag --contains 77/201177/4
Matthias Sohn [Sun, 9 Apr 2023 18:51:15 +0000 (20:51 +0200)]
ListTagCommand: implement git tag --contains

Change-Id: I07e57ba098eace9656393837fad4cb3590f31b22

18 months agoRevWalk: use generation number to optimize getMergedInto() 41/187541/40
kylezhao [Tue, 9 Nov 2021 12:03:27 +0000 (20:03 +0800)]
RevWalk: use generation number to optimize getMergedInto()

A commit A can reach a commit B only if the generation number of A is
strictly larger than the generation number of B. This condition allows
significantly short-circuiting commit-graph walks.

On a copy of the Linux repository where HEAD is contained in v6.3-rc4
but no earlier tag, the command 'git tag --contains HEAD' of
ListTagCommand#call() had the following peformance improvement:
(excluded the startup time of the repo)

Before: 2649ms    (core.commitgraph=true)
        11909ms   (core.commitgraph=false)
After:  91ms     (core.commitgraph=true)
        11934ms   (core.commitgraph=false)

Bug: 574368
Change-Id: Ia2efaa4e9ae598266f72e70eb7e3b27655cbf85b
Signed-off-by: kylezhao <kylezhao@tencent.com>
18 months agoDfsPackFile: Extract block aligment code 74/201174/2
Ivan Frade [Tue, 11 Apr 2023 19:50:52 +0000 (12:50 -0700)]
DfsPackFile: Extract block aligment code

Loading of pack, bitmap and commit-graph copy the same code to adjust
the input stream buffering.

Extract to a common function. Besides reusing the code, the name hints
what it is doing.

This block aligment seems unnecessary as the reading is from storage
not dfs cache. The channel probably knows better. Left a TODO because
I don't know the original intention.

Change-Id: I18b77ae8189830fcd4d5932b6b5823b693ed6090

18 months agoMerge branch 'stable-6.5' 34/201134/1
Matthias Sohn [Thu, 6 Apr 2023 20:16:41 +0000 (22:16 +0200)]
Merge branch 'stable-6.5'

* stable-6.5:
  Ensure parsed RevCommitCG has derived data from commit-graph
  Downgrade maven-site-plugin to 3.12.1
  Use wagon-ssh-external to deploy Maven site

Change-Id: Ide721fb088fa04f6276ac495968a45e732f6e139

18 months agoEnsure parsed RevCommitCG has derived data from commit-graph 42/201042/3
kylezhao [Mon, 3 Apr 2023 09:04:38 +0000 (17:04 +0800)]
Ensure parsed RevCommitCG has derived data from commit-graph

If a RevCommitCG was newly created and called #parseCanonical(RevWalk,
byte[]) method immediately, its flag was marked as PARSED, but no
derived data was obtained from the commit-graph. This is different from
what we expected.

Change-Id: I5d417efa3c42d211f19e6acf255f761e84d84450
Signed-off-by: kylezhao <kylezhao@tencent.com>
18 months agoPatchApplierTest: specify charset to avoid warning 72/201072/2
Jonathan Tan [Tue, 4 Apr 2023 23:49:30 +0000 (16:49 -0700)]
PatchApplierTest: specify charset to avoid warning

Running

  bazel test //org.eclipse.jgit.test:org_eclipse_jgit_patch_PatchApplierTest

results in a DefaultCharset error on my machine, which can be avoided
by explicitly specifying a charset when calling getBytes on a string. In
these tests, the charset used doesn't really matter, so go with UTF_8.

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

18 months agoGcConcurrentTest: @Ignore flaky testInterruptGc 09/201109/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

18 months agoMerge "PatchApplier: Check for existence of src/dest files before any operation"
Han-Wen NIenhuys [Fri, 31 Mar 2023 10:24:32 +0000 (06:24 -0400)]
Merge "PatchApplier: Check for existence of src/dest files before any operation"

18 months agoPatchApplier: Check for existence of src/dest files before any operation 76/200976/5
Nitzan Gur-Furman [Thu, 30 Mar 2023 10:12:46 +0000 (12:12 +0200)]
PatchApplier: Check for existence of src/dest files before any operation

Change-Id: Ia3ec0ce1af65114b48669157a934f70f1e22fd37
Bug: Google b/271474227

18 months agoRevert "RefDirectory: Throw exception if CAS of packed ref list fails" 23/197823/4
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.

Change-Id: I3acee7527bb542996dcdfaddfb2bdb45ec444db5
Signed-off-by: Martin Fick <quic_mfick@quicinc.com>
18 months agoRefDirectory.delete: Prevent failures when packed-refs is outdated 68/200368/6
Kaushik Lingarkar [Thu, 2 Mar 2023 00:42:53 +0000 (16:42 -0800)]
RefDirectory.delete: Prevent failures when packed-refs is outdated

The in-memory copy of packed refs might be outdated by the time the
packed-refs lock is acquired, so ensure the one read from disk is
used after acquiring the lock to prevent commit packed-refs from
throwing an exception. As a side-effect, since this updates the
in-memory copy of packed-refs when it is re-read from disk, it can
prevent other callers needing to re-read if it had changed.

Change-Id: I724c866b330b397e955b5eb04b259eedd9911e93
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
18 months agoRefDirectory.pack: Only rely on packed refs from disk 21/200221/9
Kaushik Lingarkar [Mon, 27 Feb 2023 23:17:55 +0000 (15:17 -0800)]
RefDirectory.pack: Only rely on packed refs from disk

Since packed-refs is read from disk anyway, don't rely on the
in-memory copy as that is racy and if outdated, could result in
commit of pack-refs throwing an exception. This change also avoids
a possible unnecessary double read of packed-refs from disk.

Change-Id: I684a64991f53f8bdad58bbd248aae6522d11267d
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
18 months agoRefDirectory: Make pack() and commitPackRefs() void 02/200402/4
Kaushik Lingarkar [Tue, 7 Mar 2023 21:10:00 +0000 (13:10 -0800)]
RefDirectory: Make pack() and commitPackRefs() void

There are no more callers (since Iae71cb3) of these methods that need
the returned value. These methods should not have been returning
anything in the first place as that can introduce bugs such as the
one described in Iae71cb3.

Change-Id: I1d083a91603da803a106cfb1506925a82c2ef809
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
18 months agoImplement a snapshotting RefDirectory for use in request scope 48/200148/18
Kaushik Lingarkar [Mon, 27 Feb 2023 23:29:00 +0000 (15:29 -0800)]
Implement a snapshotting RefDirectory for use in request scope

Introduce a SnapshottingRefDirectory class which allows users to get
a snapshot of the ref database and use it in a request scope (for
example a Gerrit query) instead of having to re-read packed-refs
several times in a request.

This can potentially be further improved to avoid scanning/reading a
loose ref several times in a request. This would especially help
repeated lookups of a packed ref, where we check for the existence of
a loose ref each time.

Change-Id: I634b92877f819f8bf36a3b9586bbc1815108189a
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
18 months agoFix RefDirectoryTest.testGetRefs_LooseSorting_Bug_348834 73/200373/4
Kaushik Lingarkar [Tue, 7 Mar 2023 00:01:18 +0000 (16:01 -0800)]
Fix RefDirectoryTest.testGetRefs_LooseSorting_Bug_348834

Since the first attempt to read a ref is not expected to trigger
a RefsChangedEvent, update the test to ensure 'lastNotifiedModCnt'
is not 0 before we start the actual work. The test has been passing
luckily because createBareRepository in setUp() happens to bump
'lastNotifiedModCnt'.

Change-Id: Ibd981f677920e8c3b965aa742fe669c42b8c1c93
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
18 months agoPackedBatchRefUpdate: Ensure updates are applied on latest packed refs 20/200220/7
Kaushik Lingarkar [Mon, 27 Feb 2023 23:03:32 +0000 (15:03 -0800)]
PackedBatchRefUpdate: Ensure updates are applied on latest packed refs

In the window between refs being packed (via refDb.pack) and obtaining
updates (via applyUpdates), packed-refs may have been updated by another
actor and relying on the previously read contents may lead to losing the
updates done by the other actor. To help avoid this, read packed-refs
from disk to ensure we have the latest copy after it is locked and
before committing updates to it.

Bug: 581641
Change-Id: Iae71cb30830b307d0df929c9131911ee476c711c
Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
18 months agoDowngrade maven-site-plugin to 3.12.1 90/200990/1
Matthias Sohn [Thu, 30 Mar 2023 20:00:52 +0000 (22:00 +0200)]
Downgrade maven-site-plugin to 3.12.1

This may fix the current authentication failures happening when trying
to deploy the jgit Maven site.

Change-Id: I55d4706cd041d93194af48fac9e8bfcd067e2cac

18 months agoUse wagon-ssh-external to deploy Maven site 73/200973/2
Matthias Sohn [Thu, 30 Mar 2023 07:26:26 +0000 (09:26 +0200)]
Use wagon-ssh-external to deploy Maven site

Using wagon-ssh stopped working. Try to use wagon-ssh-external instead.

Bug: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/2818
Change-Id: I6f8fa771ddf9623b2e528f23f2ebdc871372ba2f

18 months agoRecord my e-mail change in .mailmap 71/200971/1
Thomas Wolf [Thu, 21 Jul 2022 06:45:02 +0000 (08:45 +0200)]
Record my e-mail change in .mailmap

Change-Id: I3bf867f2d91c92315d77015bdc87cd60e4ece78a
Signed-off-by: Thomas Wolf <twolf@apache.org>
18 months ago[releng] Bump japicmp base version 70/200970/1
Thomas Wolf [Wed, 29 Mar 2023 06:39:03 +0000 (08:39 +0200)]
[releng] Bump japicmp base version

To 6.5.0.202303070854-r.

Change-Id: Ifdf7c85871263ef3cc810aedc207b3598ba01d86
Signed-off-by: Thomas Wolf <twolf@apache.org>
18 months agoPatchApplier: missing @since, and minor formatting 69/200969/1
Thomas Wolf [Wed, 29 Mar 2023 06:35:06 +0000 (08:35 +0200)]
PatchApplier: missing @since, and minor formatting

Change-Id: I561ca2f522579571b29d3e6f35f24e201d1c1663
Signed-off-by: Thomas Wolf <twolf@apache.org>
18 months agoMerge "BasePackFetchConnection: support negotiationTip feature"
Ivan Frade [Tue, 28 Mar 2023 23:29:17 +0000 (19:29 -0400)]
Merge "BasePackFetchConnection: support negotiationTip feature"

18 months agoBasePackFetchConnection: support negotiationTip feature 86/200786/13
Ronald Bhuleskar [Wed, 22 Mar 2023 22:07:19 +0000 (15:07 -0700)]
BasePackFetchConnection: support negotiationTip feature

By default, Git will report, to the server, commits reachable from all local refs to find common commits in an attempt to reduce the size of the to-be-received packfile. If specified with negotiation tip, Git will only report commits reachable from the given tips. This is useful to speed up fetches when the user knows which local ref is likely to have commits in common with the upstream ref being fetched.

When negotation-tip is on, use the wanted refs instead of all refs as source of the "have" list to send.

This is controlled by the `fetch.usenegotationtip` flag, false by default. This works only for programmatic fetches and there is no support for it yet in the CLI.

Change-Id: I19f8fe48889bfe0ece7cdf78019b678ede5c6a32

18 months agoPatchApplierTest: Remove test data with Apache license 56/199756/4
Ivan Frade [Thu, 2 Feb 2023 23:02:13 +0000 (15:02 -0800)]
PatchApplierTest: Remove test data with Apache license

Some test data introduced in [1] includes code with Apache
license. This triggers warnings in license analyzers.

Remove the licensed files and the test case as a quick relief. We
should restore the test with appropiate data in a follow-up change.

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

Change-Id: I42670dc7d994f77d2c7f2c2156bcf1e112374022

18 months agoMerge "Fix PatchApplier error handling."
Han-Wen NIenhuys [Tue, 28 Mar 2023 09:51:18 +0000 (05:51 -0400)]
Merge "Fix PatchApplier error handling."

18 months agoFix PatchApplier error handling. 13/200313/9
Nitzan Gur-Furman [Fri, 3 Mar 2023 13:24:19 +0000 (14:24 +0100)]
Fix PatchApplier error handling.

1. For general errors, throw IOException instead of wrapping them with
PatchApplyException. The wrapping was moved (back) to ApplyCommand.
2. For file specific errors, log the errors as part of
PatchApplier::Result.
3. Change applyPatch() to receive the parsed Patch object, so the caller
can decide how to handle parsing errors.

Background: this utility class was extracted from ApplyCommand on V6.4.0.
During the extraction, we left the exception wrapping by
PatchApplyException intact. This attitude made it harder for the callers to
distinguish between the actual error causes.

Change-Id: Ib0f2b5e97a13df2339d8b65f2fea1c819c161ac3

18 months agoMerge branch 'stable-6.5' 73/200873/1
Matthias Sohn [Mon, 27 Mar 2023 09:02:52 +0000 (11:02 +0200)]
Merge branch 'stable-6.5'

* stable-6.5:
  Ensure FileCommitGraph scans commit-graph file if it already exists

Change-Id: I5218ff5214222c7d6d96e452cf427eea1f20c316

18 months agoEnsure FileCommitGraph scans commit-graph file if it already exists 71/200871/5
kylezhao [Mon, 27 Mar 2023 06:48:31 +0000 (14:48 +0800)]
Ensure FileCommitGraph scans commit-graph file if it already exists

When commit-graph file already exists in the repository, a newly
created FileCommitGraph didn't scan CommitGraph until the file was
modified, resulting in wrong result.

Change-Id: Ic85676f2d3b6a88f3ae28d4065729926b6fb2f23
Signed-off-by: kylezhao <kylezhao@tencent.com>
18 months agoMerge branch 'stable-6.5' 96/200796/1
Matthias Sohn [Thu, 23 Mar 2023 08:08:05 +0000 (09:08 +0100)]
Merge branch 'stable-6.5'

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

Change-Id: I498359a229b9bd3b62415870d3fdeae281977aa6

18 months agoMerge branch 'stable-6.4' into stable-6.5 95/200795/1
Matthias Sohn [Thu, 23 Mar 2023 08:07:33 +0000 (09:07 +0100)]
Merge branch 'stable-6.4' into stable-6.5

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

Change-Id: I7e3a4b3671e779fd62062c4e10d224f432e39b54

18 months agoMerge branch 'stable-6.3' into stable-6.4 94/200794/1
Matthias Sohn [Thu, 23 Mar 2023 08:07:09 +0000 (09:07 +0100)]
Merge branch 'stable-6.3' into stable-6.4

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

Change-Id: I99455916d447f5dffed85e9a5c1d51b323f07a16

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)

18 months agoGC: Close File.lines stream 22/200722/3
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.

Signed-off-by: Xing Huang <xingkhuang@google.com>
Change-Id: I82c6faa3ef1083f6c7e964f96e9540b4db18eee8
Signed-off-by: Xing Huang <xingkhuang@google.com>
19 months agoMerge branch 'stable-6.5' 96/200396/1
Matthias Sohn [Tue, 7 Mar 2023 15:41:06 +0000 (16:41 +0100)]
Merge branch 'stable-6.5'

* stable-6.5:
  Rerun flaky tests 3 times
  Prepare 6.5.1-SNAPSHOT builds
  JGit v6.5.0.202303070854-r
  Ignore generated org.eclipse.jgit.benchmarks/dependency-reduced-pom.xml
  [sshd] Fix calculation of timeout in AbstractClientProxyConnector
  Silence API error raised for removed BranchRebaseMode#PRESERVE

Change-Id: Ie615980c81371ee26b2395e67e026bbd17422fbd

19 months agoRerun flaky tests 3 times 88/200388/1
Matthias Sohn [Tue, 7 Mar 2023 15:37:45 +0000 (16:37 +0100)]
Rerun flaky tests 3 times

This can help to reduce time spent on rebuilds caused by flaky tests.

Change-Id: I8f7831e470fd8aa065f0b8728f62f39734d05016

19 months agoPrepare 6.5.1-SNAPSHOT builds 87/200387/1
Matthias Sohn [Tue, 7 Mar 2023 15:38:44 +0000 (16:38 +0100)]
Prepare 6.5.1-SNAPSHOT builds

Change-Id: Idd9977ac08a339906e33beb73f57f8f6885ad86f

19 months agoJGit v6.5.0.202303070854-r 81/200381/1 v6.5.0.202303070854-r
Matthias Sohn [Tue, 7 Mar 2023 13:54:32 +0000 (14:54 +0100)]
JGit v6.5.0.202303070854-r

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

19 months agoIgnore generated org.eclipse.jgit.benchmarks/dependency-reduced-pom.xml 80/200380/1
Matthias Sohn [Tue, 7 Mar 2023 13:53:57 +0000 (14:53 +0100)]
Ignore generated org.eclipse.jgit.benchmarks/dependency-reduced-pom.xml

Change-Id: I8afe0e5128a63e0df02c5350772c942912408171

19 months ago[sshd] Fix calculation of timeout in AbstractClientProxyConnector 58/200358/4
Stephan Wahlbrink [Mon, 6 Mar 2023 09:33:24 +0000 (10:33 +0100)]
[sshd] Fix calculation of timeout in AbstractClientProxyConnector

The previous implementation mixed nano seconds (elapsed) and milli
seconds (remaining) without conversion.

Change-Id: I9e1654afa47fa32c94808af3b2dd0418a372fb00

19 months agoSilence API error raised for removed BranchRebaseMode#PRESERVE 70/200370/1
Matthias Sohn [Mon, 6 Mar 2023 20:39:42 +0000 (21:39 +0100)]
Silence API error raised for removed BranchRebaseMode#PRESERVE

It was replaced by MERGES to match C git which did that in 2.34.

Change-Id: Ib6a33b4a3650345bf0f9d3726dd9e14c5797e836

19 months agoMerge branch 'stable-6.5' 21/200321/1
Matthias Sohn [Fri, 3 Mar 2023 15:04:00 +0000 (16:04 +0100)]
Merge branch 'stable-6.5'

* stable-6.5:
  [errorprone] Suppress [Finally] warnings
  Update Orbit to R20230302014618 for 2023-03
  Improve test coverage when core.trustPackedRefsStat set to after_open
  Prepare 6.5.0-SNAPSHOT builds
  JGit v6.5.0.202302281825-rc1
  Prepare 6.5.0-SNAPSHOT builds
  JGit v6.5.0.202302221508-m3

Change-Id: Ice109c060d14c455262f61aed088111b238d735b

19 months agoMerge branch 'stable-6.4' into stable-6.5 20/200320/1
Matthias Sohn [Fri, 3 Mar 2023 15:03:26 +0000 (16:03 +0100)]
Merge branch 'stable-6.4' into stable-6.5

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

Change-Id: Id0a3b571aa6bbf159b225794ddc884f79431c670

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

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

Change-Id: I236c5cbb638493cc4b23475be50d0f724d62a688

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 ago[errorprone] Suppress [Finally] warnings 99/200299/2
Matthias Sohn [Thu, 2 Mar 2023 09:43:10 +0000 (10:43 +0100)]
[errorprone] Suppress [Finally] warnings

In these cases we use Throwable#addSuppressed to ensure the exception
thrown in the catch block preceding the finally block throwing another
exception isn't lost.

Change-Id: I96e78a5c15238ab77ac90ca1901850ce19acfcd8

19 months agoUpdate Orbit to R20230302014618 for 2023-03 97/200297/2
Matthias Sohn [Thu, 2 Mar 2023 09:14:50 +0000 (10:14 +0100)]
Update Orbit to R20230302014618 for 2023-03

and update
- com.google.gson to 2.10.1.v20230109-0753

Change-Id: I9745797a278c43ec62a82b5620bb72f075a23c1f

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 agoPrepare 6.6.0-SNAPSHOT builds 75/200275/1
Matthias Sohn [Wed, 1 Mar 2023 14:40:45 +0000 (15:40 +0100)]
Prepare 6.6.0-SNAPSHOT builds

Change-Id: I17893f9db12bcb208866f40a06cd4f1ccbb4fe30

19 months agoPrepare 6.5.0-SNAPSHOT builds 73/200273/1
Matthias Sohn [Wed, 1 Mar 2023 14:30:29 +0000 (15:30 +0100)]
Prepare 6.5.0-SNAPSHOT builds

Change-Id: I313e3deed8fa00df0406b3d7b73e5b643dc25a05

19 months agoJGit v6.5.0.202302281825-rc1 54/200254/1 v6.5.0.202302281825-rc1
Matthias Sohn [Tue, 28 Feb 2023 23:23:58 +0000 (00:23 +0100)]
JGit v6.5.0.202302281825-rc1

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

19 months agoMerge branch 'master' into stable-6.5 51/200251/1
Matthias Sohn [Tue, 28 Feb 2023 23:11:41 +0000 (00:11 +0100)]
Merge branch 'master' into stable-6.5

* master:
  Change config pull.rebase=preserve to pull.rebase=merges
  BatchingProgressMonitor: expose time spent per task
  PackWriter: offer to write an object-size index for the pack
  Fix formatting in GC#doGc
  PackExt: Define new extension for the object size index

Change-Id: I174db870e6c2fcb72ff535b39bb6e1c3358f11b8

19 months agoPrepare 6.5.0-SNAPSHOT builds 50/200250/1
Matthias Sohn [Tue, 28 Feb 2023 23:10:18 +0000 (00:10 +0100)]
Prepare 6.5.0-SNAPSHOT builds

Change-Id: Ie95ce8fcc2a570505d23d5a1642e33c041212260

19 months agoChange config pull.rebase=preserve to pull.rebase=merges 79/199379/6
Pavel Salamon [Thu, 12 Jan 2023 15:39:07 +0000 (16:39 +0100)]
Change config pull.rebase=preserve to pull.rebase=merges

The native git option to preserve merge commits during rebase
has been changed from pull.rebase=preserve to pull.rebase=merges.

This changeset in jgit makes the same config change. The old "preserve"
option is no longer recognized and is replaced by new option called
"merges".

This makes jgit's rebase configuration compatible with native git
versions 2.34 and newer where the old "preserve" option has been
removed.

Change-Id: Ic07ff954e258115e76465a1593ef3259f4c418a3

19 months agoBatchingProgressMonitor: expose time spent per task 82/199682/7
Matthias Sohn [Thu, 19 Jan 2023 00:46:50 +0000 (01:46 +0100)]
BatchingProgressMonitor: expose time spent per task

Display elapsed time per task if enabled via
ProgressMonitor#showDuration or if system property or environment
variable GIT_TRACE_PERFORMANCE is set to "true". If both the system
property and the environment variable are set the system property takes
precedence.

E.g. using jgit CLI:

$ GIT_TRACE_PERFORMANCE=true jgit clone https://foo.bar/foobar
Cloning into 'foobar'...
remote: Counting objects: 1 [0.002s]
remote: Finding sources: 100% (15531/15531) [0.006s]
Receiving objects:      100% (169737/169737) [13.045s]
Resolving deltas:       100% (67579/67579) [1.842s]

Change-Id: I4d624e7858b286aeddbe7d4e557589986d73659e

19 months agoPackWriter: offer to write an object-size index for the pack 89/191089/25
Ivan Frade [Tue, 28 Dec 2021 22:23:40 +0000 (14:23 -0800)]
PackWriter: offer to write an object-size index for the pack

PackWriter callers tell the writer what do the want to include in the
pack and invoke #writePack(). Afterwards, they can invoke #writeIndex()
to write the corresponding pack index.

Mirror this for the object-size index, adding a #writeObjectSizeIndex()
method.

Change-Id: Ic319975c72c239cd6488303f7d4cced797e6fe00

19 months agoFix formatting in GC#doGc 65/200165/1
Matthias Sohn [Fri, 24 Feb 2023 14:18:39 +0000 (15:18 +0100)]
Fix formatting in GC#doGc

Change-Id: Ifa3adb66d4e0404bab4036d6b165d6c4dafe921a

19 months agoPackExt: Define new extension for the object size index 85/191085/19
Ivan Frade [Tue, 4 Jan 2022 20:30:10 +0000 (12:30 -0800)]
PackExt: Define new extension for the object size index

Change-Id: I6bbaf43b4e6fb456ca0e9e0c6efcfeded0f94d6d

19 months agoJGit v6.5.0.202302221508-m3 30/200130/1 v6.5.0.202302221508-m3
Matthias Sohn [Wed, 22 Feb 2023 20:09:10 +0000 (21:09 +0100)]
JGit v6.5.0.202302221508-m3

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

19 months agoMerge branch 'master' into stable-6.5 28/200128/1
Matthias Sohn [Wed, 22 Feb 2023 20:07:34 +0000 (21:07 +0100)]
Merge branch 'master' into stable-6.5

* master:
  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: I0a599ec9241dd3b9b9a61122b2eda6bd647bcc22

19 months agoMerge branch 'stable-6.4' 27/200127/1
Matthias Sohn [Wed, 22 Feb 2023 20:06:41 +0000 (21:06 +0100)]
Merge branch 'stable-6.4'

* stable-6.4:
  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: Ia2797b44a60342eb9df53f0b3d674cba92a512fc

19 months agoMerge branch 'stable-6.3' into stable-6.4 25/200125/2
Matthias Sohn [Wed, 22 Feb 2023 20:04:31 +0000 (21:04 +0100)]
Merge branch 'stable-6.3' into stable-6.4

* stable-6.3:
  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: I5af34c92e423a651db53b4dc45ed844d5f39910d

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 'master' into stable-6.5 70/200070/1
Matthias Sohn [Wed, 22 Feb 2023 01:18:10 +0000 (02:18 +0100)]
Merge branch 'master' into stable-6.5

* master:
  Use Java 11 ProcessHandle to get pid of the current process
  UploadPack: use allow-any-sha1-in-want configuration
  Acquire file lock "gc.pid" before running gc
  Silence API errors introduced by 9424052f

Change-Id: I71c8ee39e0f3438cbc1992c24f9f6c33ece88c07

19 months agoMerge branch 'stable-6.4' 68/200068/1
Matthias Sohn [Wed, 22 Feb 2023 00:29:32 +0000 (01:29 +0100)]
Merge branch 'stable-6.4'

* stable-6.4:
  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: Ifa4e56b6ecca9305f3f1685e45450019bfc82e22

19 months agoMerge branch 'stable-6.3' into stable-6.4 67/200067/1
Matthias Sohn [Wed, 22 Feb 2023 00:28:27 +0000 (01:28 +0100)]
Merge branch 'stable-6.3' into stable-6.4

* stable-6.3:
  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: Ic40dbab18616d8d9fe3820b9890c86652b80eb47

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 agoUploadPack: use allow-any-sha1-in-want configuration 94/180794/8
kylezhao [Thu, 20 May 2021 03:29:59 +0000 (11:29 +0800)]
UploadPack: use allow-any-sha1-in-want configuration

C git 2.11 supports setting the equivalent of RequestPolicy.ANY with
uploadpack.allowAnySHA1InWant[1]. Parse this into TransportConfig and
use it from UploadPack.

Add additional tests for [2] and this change.

We can execute "git clone --filter=blob:none --no-checkout" successfully
with config uploadPack.allowFilter is true. But when we checkout, the
git will fetch other missing objects required by the checkout(this is
why we need this config).

When both uploadPack.allowFilter and uploadPack.allowAnySHA1InWant are
true, jgit will support partial clone. If you are using an extremely
large monorepo, this feature can help. It allows users to work on an
incomplete repo which reduces disk usage.

[1] https://github.com/git/git/commit/f8edeaa05d8623a9f6dad408237496c51101aad8
[2] change Id39771a6e42d8082099acde11249306828a053c0

Bug: 573390
Change-Id: I8fe75f03bf1fea7c11e0d67c8637bd05dd1f9b89
Signed-off-by: kylezhao <kylezhao@tencent.com>
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 'master' into stable-6.5 33/200033/1
Matthias Sohn [Mon, 20 Feb 2023 21:18:22 +0000 (22:18 +0100)]
Merge branch 'master' into stable-6.5

* master:
  Externalize strings introduced in c9552aba
  Silence API error introduced by 596c445a
  PackConfig: add entry for minimum size to index
  Fix getPackedRefs to not throw NoSuchFileException
  PackObjectSizeIndex: interface and impl for the object-size index
  UInt24Array: Array of unsigned ints encoded in 3 bytes.
  PackIndex: expose the position of an object-id in the index
  Add pack options to preserve and prune old pack files
  DfsPackFile/DfsGC: Write commit graphs and expose in pack
  ObjectReader: Allow getCommitGraph to throw IOException
  Allow to perform PackedBatchRefUpdate without locking loose refs
  Document option "core.sha1Implementation" introduced in 59029aec
  UploadPack: consume delimiter in object-info command
  PatchApplier fix - init cache with provided tree
  Avoid error-prone warning
  Fix unused exception error-prone warning
  UploadPack: advertise object-info command if enabled
  Move MemRefDatabase creation in a separate method.
  DfsReaderIoStats: Add Commit Graph fields into DfsReaderIoStats

Change-Id: Ic9f91f2139432999b99c444302457b3c08911009

19 months agoExternalize strings introduced in c9552aba 31/200031/1
Matthias Sohn [Mon, 20 Feb 2023 20:40:40 +0000 (21:40 +0100)]
Externalize strings introduced in c9552aba

Change-Id: I81bb78344df61e6eb42622fcef6235d4da0ae052

19 months agoSilence API error introduced by 596c445a 30/200030/1
Matthias Sohn [Mon, 20 Feb 2023 20:31:09 +0000 (21:31 +0100)]
Silence API error introduced by 596c445a

Change-Id: I961ba2d89c11373ccb81e6450d7d951204ffca36

19 months agoMerge branch 'stable-6.4' 29/200029/2
Matthias Sohn [Mon, 20 Feb 2023 20:26:08 +0000 (21:26 +0100)]
Merge branch 'stable-6.4'

* stable-6.4:
  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: I36051c623fcd480aa80ed32b4e89f9bdd1b798e0

19 months agoMerge branch 'stable-6.3' into stable-6.4 27/200027/1
Matthias Sohn [Mon, 20 Feb 2023 20:01:38 +0000 (21:01 +0100)]
Merge branch 'stable-6.3' into stable-6.4

* stable-6.3:
  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: I1073098fb06eabafdb3c5e7fcf44d55b86a1b152

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 agoPackConfig: add entry for minimum size to index 84/191084/18
Ivan Frade [Tue, 4 Jan 2022 19:10:04 +0000 (11:10 -0800)]
PackConfig: add entry for minimum size to index

The object size index can have up to #(blobs-in-repo) entries, taking
a relevant amount of memory. Let operators configure the threshold size
to include objects in the size index.

The index will include objects with size *at or above* this
value (with -1 for none). This is more effective for the
filter-by-size case.

Lowering the threshold adds more objects to the index. This improves
performance at the cost of memory/storage space. For the object-size
case, more calls will use the index instead of reading IO. For the
filter-by-size case, lower threshold means better granularity (if
ObjectReader#isSmallerThan is implemented based only on the index).

Change-Id: I6ccd9334adbbc2abf95fde51dbbfc85b8230ade0

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 agoPackObjectSizeIndex: interface and impl for the object-size index 83/191083/16
Ivan Frade [Wed, 15 Dec 2021 00:36:54 +0000 (16:36 -0800)]
PackObjectSizeIndex: interface and impl for the object-size index

Operations like "clone --filter=blob:limit=N" or the "object-info"
command need to read the size of the objects from the storage. An
index would provide those sizes at once rather than having to seek in
the packfile.

Introduce an interface for the Object-size index. This index returns
the inflated size of an object. Not all objects could be indexed (to
limit memory usage).

This implementation indexes only blobs (no trees, nor
commits) *above* certain size threshold (configurable). Lower
threshold adds more objects to the index, consumes more memory and
provides better performance. 0 means "all blobs" and -1 "disabled".

If we don't index everything, for the filter use case is more
efficient to index the biggest objects first: the set is small and
most objects are filtered by NOT being in the index. For the
object-size, the more objects in the index the better, regardless
their size. All together, it is more helpful to index above threshold.

Change-Id: I9ed608ac240677e199b90ca40d420bcad9231489

20 months agoUInt24Array: Array of unsigned ints encoded in 3 bytes. 92/199892/3
Ivan Frade [Fri, 10 Feb 2023 20:21:01 +0000 (12:21 -0800)]
UInt24Array: Array of unsigned ints encoded in 3 bytes.

The object size index stores positions of objects in the main
index (when ordered by sha1). These positions are per-pack and usually
a pack has <16 million objects (there are exceptions but rather
rare). It could save some memory storing these positions in three bytes
instead of four. Note that these positions are sorted and always positive.

Implement a wrapper around a byte[] to access and search "ints" while
they are stored as unsigned 3 bytes.

Change-Id: Iaa26ce8e2272e706e35fe4cdb648fb6ca7591972