Commit Graph

5798 Commits

Author SHA1 Message Date
Alina Djamankulova 3cd7eb1b23 DFS block cache: Refactor to enable parallel index loading
With this change bitmap index creation is not blocked on index and
reverse index full initialization in DfsPackFile. Now bitmap index and index could be
read from storage in parallel in separate threads.

Update PackBitmapIndexV1 constructor to get packIndex and reverseIndex
suppliers instead of actual objects. Inner class IdxPositionBitmap was added to initialize pack objects after bitmap
index is fully read from storage. Update DfsPackFile and PackBitmapIndex
accordingly.

Signed-off-by: Alina Djamankulova <adjama@google.com>
Change-Id: Iea59ab58501b2acbbf9263412982ec9c6898a7ee
2021-08-12 14:51:18 -04:00
Julian Ruppel e2798413f9 Support commit.template config property
Adds functionality to read the git commit.template property. The
template content is read either via a default encoding or, if present,
via encoding specified by i18n.commitEncoding property.

Bug: 446355

Change-Id: I0c45db98e324ddff26a7e0262835f259d6528a86
Signed-off-by: Julian Ruppel <julian.ruppel@sap.com>
2021-07-21 15:50:02 -04:00
Luca Milanesio ed5be35e2e Remove use of deprecated getAllRefs() in ReceivePack
Repository.getAllRefs() is deprecated and should not
be used anymore. Leverage the ref-db and the retrieval
of refs by prefix and adapt the result to the expected
refname/ref map.

Bug: 534731
Change-Id: I37a9092859f220ddc4e5063d01544f3e82208be8
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
2021-06-26 16:41:01 +02:00
Matthias Sohn d46af8c69d Merge branch 'stable-5.12'
* stable-5.12:
  Retry loose object read upon "Stale file handle" exception
  Ignore missing javadoc in test bundles

Change-Id: I67c613c066a3252f9b0d0a3dcc026b57e10bfe1d
2021-06-26 16:37:59 +02:00
Matthias Sohn 8bd0161c83 Merge branch 'stable-5.11' into stable-5.12
* stable-5.11:
  Retry loose object read upon "Stale file handle" exception
  Ignore missing javadoc in test bundles

Change-Id: Ia4dc886c920cec3c9da86e1a90a0af68bd016b4f
2021-06-26 16:36:55 +02:00
Matthias Sohn e6ace4a96d Merge branch 'stable-5.10' into stable-5.11
* stable-5.10:
  Retry loose object read upon "Stale file handle" exception
  Ignore missing javadoc in test bundles

Change-Id: Ia385fa6b5d2fee64476793e06860a279bf2f6e36
2021-06-26 16:35:20 +02:00
Matthias Sohn bbb1c7f645 Merge branch 'stable-5.9' into stable-5.10
* stable-5.9:
  Retry loose object read upon "Stale file handle" exception
  Ignore missing javadoc in test bundles

Change-Id: I56fc2c47193a891285a705d44b3507f23982dc8a
2021-06-25 22:23:47 +02:00
Fabio Ponciroli 6976a30f44 searchForReuse might impact performance in large repositories
The search for reuse phase for *all* the objects scans *all*
the packfiles, looking for the best candidate to serve back to the
client.

This can lead to an expensive operation when the number of
packfiles and objects is high.

Add parameter "pack.searchForReuseTimeout" to limit the time spent
on this search.

Change-Id: I54f5cddb6796fdc93ad9585c2ab4b44854fa6c48
2021-06-25 17:57:59 +02:00
Antonio Barone 24d6d60538 Retry loose object read upon "Stale file handle" exception
When reading loose objects over NFS it is possible that the OS syscall
would fail with ESTALE errors: This happens when the open file
descriptor no longer refers to a valid file.

Notoriously it is possible to hit this scenario when git data is shared
among multiple clients, for example by multiple gerrit instances in HA.

If one of the two clients performs a GC operation that would cause the
packing and then the pruning of loose objects, the other client might
still hold a reference to those objects, which would cause an exception
to bubble up the stack.

The Linux NFS FAQ[1] (at point A.10), suggests that the proper way to
handle such ESTALE scenarios is to:

"[...] close the file or directory where the error occurred, and reopen
it so the NFS client can resolve the pathname again and retrieve the new
file handle."

In case of a stale file handle exception, we now attempt to read the
loose object again (up to 5 times), until we either succeed or encounter
a FileNotFoundException, in which case the search can continue to
Packfiles and alternates.

The limit of 5 provides an arbitrary upper bounds that is consistent to
the one chosen when handling stale file handles for packed-refs
files (see [2] for context).

[1] http://nfs.sourceforge.net/
[2] https://git.eclipse.org/r/c/jgit/jgit/+/54350

Bug: 573791
Change-Id: I9950002f772bbd8afeb9c6108391923be9d0ef51
2021-06-24 23:52:22 +02:00
andrewxian2000 1ae7e08bca Fix garbage collection failing to delete pack file
The loosen() method has opened pack file and the open pack file handle
may prevent it from being deleted e.g. on Windows. Fix this by closing
the pack file only after loosen() finished.

Bug: 574178
Change-Id: Icd59931a218d84c9c97b450eea87b21ed01248ff
Signed-off-by: andrew.xian2000@gmail.com
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-22 14:16:30 +02:00
Thomas Wolf fc57689774 Fix PathSuffixFilter: can decide only on full paths
On a subtree, a PathSuffixFilter must return -1 ("indeterminate"),
not 0 ("include"), otherwise negation goes wrong: an indeterminate
result (-1) is passed on, but a decision (0/1) is inverted.

As a result a negated PathSuffixFilter would skip all folders.

Bug: 574253
Change-Id: I27fe785c0d772392a5b5efe0a7b1c9cafcb6e566
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-06-21 13:03:22 +02:00
Thomas Wolf 01b2c4fc90 Fix @since from commit 64d0aaa2
That commit was submitted on master between the 5.12.0 release and
the 5.13.0 version bump.

Change-Id: I679e818bfc5a4695b66548add9a83a22c89a4ffc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-06-14 21:23:29 +02:00
Matthias Sohn 1cbfea9ece Prepare 5.13.0-SNAPSHOT builds
Change-Id: Ie9cfc1eeb0eda7b2bbe744a22a7e4cfe6d59bc37
2021-06-14 01:49:05 +02:00
Matthias Sohn eb4deda909 Merge branch 'stable-5.12'
* stable-5.12:
  Prepare 5.12.1-SNAPSHOT builds
  JGit v5.12.0.202106070339-r
  [license-check] Update list of project dependencies
  [errorprone] Fix warning InputStreamSlowMultibyteRead
  [errorprone] Make operator precedence explicit in OpenSshConfigFile
  Update jetty to 9.4.41.v20210516
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I9bd4dfc3796a5034be7b3e86b35ef591bb516a2c
2021-06-14 01:32:21 +02:00
Matthias Sohn 3b300e5ed5 Merge branch 'stable-5.10' into stable-5.11
* stable-5.10:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I265425194c24fd82cbeff869ce41cbc9b73571a2
2021-06-14 01:13:18 +02:00
Matthias Sohn b8e57d2745 Merge "Prepare 5.12.1-SNAPSHOT builds" into stable-5.12 2021-06-13 18:52:44 -04:00
Matthias Sohn 527119120f Merge "Merge branch 'stable-5.10' into stable-5.11" into stable-5.12 2021-06-13 18:48:42 -04:00
Matthias Sohn a397727e4a Prepare 5.12.1-SNAPSHOT builds
Change-Id: Idf266c34aa9a04cf9c5e0e09bcb415c13d773d4c
2021-06-13 23:59:14 +02:00
Matthias Sohn 21f9d919ed Merge branch 'stable-5.10' into stable-5.11
* stable-5.10:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I50dcc037a96f3a4237c09516c82e1c18acbd2e0b
2021-06-13 23:57:08 +02:00
Matthias Sohn e2dc4b9c64 Merge branch 'stable-5.9' into stable-5.10
* stable-5.9:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: Ib1299564a4cfb9c01f422d7ada05fcfac29700f8
2021-06-13 23:55:46 +02:00
Matthias Sohn 84063386b5 Merge branch 'stable-5.8' into stable-5.9
* stable-5.8:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I9abf7dd8b8e5eb3199fd6b43a4653c4e4cf4bf1b
2021-06-13 23:55:03 +02:00
Matthias Sohn 0c7b101329 Merge branch 'stable-5.7' into stable-5.8
* stable-5.7:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I1ee0d01c14fb7dca151b4e7ae1b989da5a3a01e3
2021-06-13 23:54:06 +02:00
Matthias Sohn e68c381917 Merge branch 'stable-5.6' into stable-5.7
* stable-5.6:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I4570cce185877cb4c50eee519a1cf9467a766dea
2021-06-13 23:52:46 +02:00
Matthias Sohn 7856402c4b Merge branch 'stable-5.5' into stable-5.6
* stable-5.5:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in
    memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I504483a4dc979c5e7af18bad45dc18675e32afd2
2021-06-13 23:49:25 +02:00
Ronald Bhuleskar 64d0aaa2b6 Teach independent negotiation (no pack file) using an option "wait-for-done"
From Git commit 9c1e657a8f:
  Currently, the packfile negotiation step within a Git fetch cannot be
  done independent of sending the packfile, even though there is at
  least one application wherein this is useful - push negotiation.
  Therefore, make it possible for this negotiation step to be done
  independently.

  This feature is for protocol v2 only.

  In the protocol, the main hindrance towards independent negotiation is
  that the server can unilaterally decide to send the packfile. This is
  solved by a "wait-for-done" argument: the server will then wait for
  the client to say "done". In practice, the client will never say it;
  instead it will cease requests once it is satisfied.

Advertising the server capability option "wait-for-done" is behind the
transport config: uploadpack.advertisewaitfordone, which by default is
false.

Change-Id: I5ebd3e99ad76b8943597216e23ced2ed38eb5224
2021-06-11 12:29:12 -04:00
Matthias Sohn 1f062c64be JGit v5.12.0.202106070339-r
Change-Id: I0fbfea2c83f1ce83f75130cc97591547032f1104
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-07 09:38:29 +02:00
Matthias Sohn ae692779ce [errorprone] Fix warning InputStreamSlowMultibyteRead
Change-Id: I50dace6e310016c04f524eb0cfcce0da05fadd47
2021-06-07 00:28:48 +02:00
Matthias Sohn c2f9acdc32 [errorprone] Make operator precedence explicit in OpenSshConfigFile
This fixes the errorprone warning OperatorPrecedence.

Change-Id: I4c7dafa5ac8e1d58fa15cf91fe1b3cf3f182d536
2021-06-07 00:25:32 +02:00
Matthias Sohn 5977260af6 Merge branch 'stable-5.4' into stable-5.5
* stable-5.4:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: If5232b68d3e25df7b71e417cbcbb39476e925f22
2021-06-05 22:49:56 +02:00
Matthias Sohn c14cb5c0ed Merge branch 'stable-5.3' into stable-5.4
* stable-5.3:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I1338fc79a7be6b77fb28df511dd7504fb19b6d1a
2021-06-05 22:49:07 +02:00
Matthias Sohn 8e52e30b92 Merge branch 'stable-5.2' into stable-5.3
* stable-5.2:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: I7838f7d237a3598bf55995426d7ba1de146cb6ad
2021-06-05 22:48:01 +02:00
Matthias Sohn 87c42c1b3c Merge branch 'stable-5.1' into stable-5.2
* stable-5.1:
  Prepare 5.1.17-SNAPSHOT builds
  JGit v5.1.16.202106041830-r
  BatchRefUpdate: Skip saving conflicting ref names and prefixes in memory
  BatchRefUpdateTest: Accurately assert RefsChangedEvent(s) fired
  Optimize RefDirectory.isNameConflicting()
  Update bazlets and bazel version

Change-Id: If1b5a2b380cf155e66bf5d5c6d216f86c919bb37
2021-06-05 22:20:46 +02:00
Matthias Sohn e7b4af0d95 Prepare 5.1.17-SNAPSHOT builds
Change-Id: I20c69728465f956a5744a75eb548ef18962286dd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-05 00:45:08 +02:00
Matthias Sohn f3d07f6649 JGit v5.1.16.202106041830-r
Change-Id: I526ed2a08553bc0b2678aaefaff9e0c6529baefc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-05 00:31:03 +02:00
Matthias Sohn 044c5f215c Prepare 5.12.0-SNAPSHOT builds
Change-Id: Ifc72d3f3ac84b9c4055b95ec0093d877ffb09ab0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-03 20:04:28 +02:00
Demetr Starshov f6b9b392e7 Fixing visibility for HostEntry constructors.
HostEntry class was public with empty constructor, so adding
constructors with default visibility actually reduced visibility of
constructor.

Change-Id: I4c996c0559102084946ba49a71afe10dda5e0f95
2021-06-02 16:19:39 -07:00
Matthias Sohn 45a4c131ae JGit v5.12.0.202106021050-rc1
Change-Id: I622ee049f14f37504ff4a062f03d6fc25465d0ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-02 16:49:17 +02:00
Matthias Sohn 1f733663bf Prepare 5.12.0-SNAPSHOT builds
Change-Id: I25e4efc9b40ae4e7168b37385445c73992c5beb0
2021-06-02 08:47:28 +02:00
Matthias Sohn 94aa245023 JGit v5.12.0.202106011439-rc1
Change-Id: Ieac1d02879defe0f4791062448d4efc328a2f652
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-01 20:38:31 +02:00
Matthias Sohn a14bc9bb69 Clarify operator precedence to fix errorprone error
Errorprone raised error OperatorPrecedence in bazel build.

Change-Id: Ibab601e67d4d5cafe9a7d900c78b0d432181a073
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-06-01 11:16:59 -04:00
Han-Wen NIenhuys 6dc3506b52 Merge "Skip detecting content renames for binary files" 2021-05-31 08:57:13 -04:00
Youssef Elghareeb 1788b72d1a Skip detecting content renames for binary files
This is similar to change Idbc2c29bd that skipped detecting content
renames for large files. With this change, we added a new option in
RenameDetector called "skipContentRenamesForBinaryFiles", that when set,
causes binary files with any slight modification to be identified as
added/deleted. The default for this boolean is false, so preserving
current behaviour.

Change-Id: I4770b1f69c60b1037025ddd0940ba86df6047299
2021-05-31 13:48:37 +02:00
Ivan Frade c59626ad7a RepoCommand: Retry commit on LockFailure
When the target repository is receiving commits from other sources,
the repo command commit can fail with a LOCK_FAILURE. We could let
callers retry, but then the command needs to redo all the work (opening
all subrepos to recreate the tree).

Retry the commit in LOCK_FAILURE inside the command. The commit
rewrites the whole tree, so it shouldn't have merge errors. Use an
exponential delay with jitter for the retries.

Change-Id: I517b6f2afd16a4b695e6cf471b5d6cf492024ec4
Signed-off-by: Ivan Frade <ifrade@google.com>
2021-05-26 14:07:28 -07:00
Ivan Frade 0667b8ec4d RepoCommand: Do not set 'branch' if the revision is a tag
The "branch" field in the .gitmodules is the signal for gerrit to keep
the superproject autoupdated. Tags are immutable and there is no need to
track them, plus the cgit client requires the field to be a "remote
branch name" but not a tag.

Do not set the "branch" field if the revision is a tag. Keep those tags
in another field ("ref") as they help other tools to find the commit in
the destination repository.

We can still have false negatives when a refname is not fully qualified,
but this check covers e.g. the most common case in android.

Note that the javadoc of #setRecordRemoteBranch already mentions that
"submodules that request a tag will not have branch name recorded".

Change-Id: Ib1c321a4d3b7f8d51ca2ea204f72dc0cfed50c37
Signed-off-by: Ivan Frade <ifrade@google.com>
2021-05-26 14:32:04 +02:00
Matthias Sohn a43ad1e56d Merge "Add git config for conflict style merge/diff3" 2021-05-26 08:30:41 -04:00
Thomas Wolf 1126f26d21 ApplyCommand: fix "no newline at end" detection
Check the last line of the last hunk of a file, not the last line of
the whole patch.

Note that C git only checks that this line starts with "\ " and is at
least 12 characters long because of possible different texts when non-
English messages are used.

Change-Id: I0db81699eb3e99ed7b536a3e2b8dc97df1f58a89
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-26 00:38:00 +02:00
Thomas Wolf 2a0295ccfd ApplyCommand: handle completely empty context lines in text patches
C git treats completely empty lines as empty context lines (which
traditionally have a single blank). Apparently newer GNU diff may
produce such lines; see [1]. ("Newer" meaning "since 2006"...)

[1] https://github.com/git/git/commit/b507b465f7831

Change-Id: I80c1f030edb17a46289b1dabf11a2648d2660d38
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-26 00:38:00 +02:00
Thomas Wolf 76b76a6048 ApplyCommand: use byte arrays for text patches, not strings
Instead of converting the patch bytes to strings apply the patch on
byte level, like C git does. Converting the input lines and the hunk
lines from bytes to strings and then applying the patch based on
strings may give surprising results if a patch converts a text file
from one encoding to another. Moreover, in the end we don't know which
encoding to use to write the result.

Previous code just wrote the result as UTF-8, which forcibly changed
the encoding if the original input had some other encoding (even if the
patch had the same non-UTF-8 encoding). It was also wrong if the input
was UTF-8, and the patch should have changed the encoding to something
else.

So use ByteBuffers instead of Strings. This has the additional advantage
that all these ByteBuffers can share the underlying byte arrays of the
input and of the patch, so it also reduces memory consumption.

Change-Id: I450975f2ba0e7d0bec8973e3113cc2e7aea187ee
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-26 00:38:00 +02:00
Thomas Wolf 10ac449911 ApplyCommand: support binary patches
Implement applying binary patches. Handles both literal and delta
patches. Note that C git also runs binary files through the clean
and smudge filters. Implement the same safeguards against corrupted
patches as in C git: require the full OIDs to be present in the patch
file, and apply a binary patch only if both pre- and post-image hashes
match.

Add tests for applying literal and delta patches.

Bug: 371725
Change-Id: I71dc214fe4145d7cc8e4769384fb78c7d0d6c220
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2021-05-26 00:38:00 +02:00
Thomas Wolf 0fe794a433 ApplyCommand: add a stream to apply a delta patch
Add a new BinaryDeltaInputStream that applies a delta provided by
another InputStream to a given base. Because delta application needs
random access to the base, the base itself cannot be yet another
InputStream. But at least this enables streaming of the result.

Add a simple test using delta hunks generated by C git.

Bug: 371725
Change-Id: Ibd26fa2f49860737ad5c5387f7f4870d3e85e628
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2021-05-26 00:37:59 +02:00