]> source.dussan.org Git - jgit.git/log
jgit.git
5 years agoreftable: increment pointer *after* reading uint16 81/147281/10
Han-Wen Nienhuys [Wed, 7 Aug 2019 21:28:32 +0000 (23:28 +0200)]
reftable: increment pointer *after* reading uint16

This fixes timezone reads out of the reflog.

Change-Id: I126d8742e5e904a074c544514180720466164f7c
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
5 years agoreftable: test absense of prefix matching in Reflog 14/146814/15
Han-Wen Nienhuys [Tue, 30 Jul 2019 17:26:34 +0000 (19:26 +0200)]
reftable: test absense of prefix matching in Reflog

Change-Id: I6705e6c57a8c080b17c7b93fdd598cf44a9d91c2
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
5 years agoreftable: enforce ordering for ref and log writes 99/146799/19
Han-Wen Nienhuys [Tue, 30 Jul 2019 14:54:31 +0000 (16:54 +0200)]
reftable: enforce ordering for ref and log writes

Previously, the API did not enforce ordering of writes.  Misuse of
this API would lead to data effectively being lost.

Guard against that with IllegalArgumentException, and add a test.

Change-Id: I04f55c481d60532fc64d35fa32c47037a03988ae
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
5 years agoreftable: add some more comments 88/146788/13
Han-Wen Nienhuys [Mon, 19 Aug 2019 09:25:58 +0000 (11:25 +0200)]
reftable: add some more comments

Change-Id: I95208f7a05919b5019895cf41ae378c97da6e680
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
5 years agoreftable: fix seeking to refs in reflog implementation 87/146787/8
Han-Wen Nienhuys [Mon, 29 Jul 2019 08:58:50 +0000 (10:58 +0200)]
reftable: fix seeking to refs in reflog implementation

Small reftables omit the log index. Currently,
ReftableWriter#shouldHaveIndex does this if there is a single-block
log, but other writers could decide on different criteria.

In the case that the log index is missing, we have to linearly search
for the right block. It is never appropriate to use binary search on
blocks for log data, as the blocks are compressed and therefore
irregularly sized.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Id59874edf6bf45c7dec502d9465888e077ffe198

5 years agoFix ApplyCommand which doesn't work if patch adds empty file 72/144072/6
Anton Khodos [Fri, 14 Jun 2019 15:16:15 +0000 (17:16 +0200)]
Fix ApplyCommand which doesn't work if patch adds empty file

Bug: 548219
Change-Id: Ibb32132a38e54508a24489322da58ddfd80a1d9a
Signed-off-by: Anton Khodos <khodosanton@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoTransportHttp: resolve redirect URIs from the "Location" header 53/147653/2
Thomas Wolf [Tue, 13 Aug 2019 21:59:50 +0000 (23:59 +0200)]
TransportHttp: resolve redirect URIs from the "Location" header

The "Location" header in a redirect response may contain a relative
URI. Resolve it against the URI the request was made.

Bug: 550033
Change-Id: I29de07dfbbbc794090821b7c190cb2cf662c5a60
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoGPG: also consider pubring.gpg when looking for keys 66/147766/2
Thomas Wolf [Thu, 15 Aug 2019 09:46:46 +0000 (11:46 +0200)]
GPG: also consider pubring.gpg when looking for keys

The algorithm for finding keys was already improved in commit db0eb9f8,
but that wasn't quite correct yet.

If there is no pubring.kbx but a private-keys-v1.d directory and a
pubring.gpg, GPG also uses pubring.gpg in combination with the
private-keys-v1.d directory. GPG has three ways to locate public and
private key pairs:

* pubring.kbx and private-keys-v1.d (GPG >= 2.1)
* pubring.gpg and private-keys-v1.d (GPG >= 2.1)
* pubring.gpg and secring.gpg (GPG < 2.1)

See [1] and [2]. pubring.kbx may not exist if the user migrated from
an older GPG installation and didn't run the agent. Since we don't
know which GPG version the user has we must try secring.gpg also if
we found the public key in pubring.gpg, but didn't find the secret
key in the private key directory. Note that GPG < 2.1 also may have
a private key directory, used by the agent. But it may also _not_ have
that directory.

[1] https://lists.gnupg.org/pipermail/gnupg-users/2015-December/054881.html
[2] https://www.gnupg.org/faq/whats-new-in-2.1.html#nosecring

Bug: 549439
Change-Id: I6088014b16c585b6a3408bb31dba3c116e6b583d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoGPG: check secring.gpg for keys if pubring.kbx is empty 13/146413/3
Thomas Wolf [Sat, 20 Jul 2019 16:45:56 +0000 (18:45 +0200)]
GPG: check secring.gpg for keys if pubring.kbx is empty

If no OpenPGP key is found in pubring.kbx, try the legacy secring.gpg.
This appears to be consistent with GPG[1].

[1] https://lists.gnupg.org/pipermail/gnupg-users/2015-December/054881.html

Bug: 549439
Change-Id: I1557fd9b1f555a9b521fcd57cd3caccbdbacbeda
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoMerge branch 'stable-5.4' 25/147325/2
Matthias Sohn [Fri, 9 Aug 2019 12:12:57 +0000 (14:12 +0200)]
Merge branch 'stable-5.4'

* stable-5.4: (82 commits)
  Export all packages of o.e.j.ant and o.e.j.archive bundles
  Do not require test bundles to export all packages
  Fix API problem filters
  Increase severity of AmbiguousMethodReference to ERROR
  [error prone] suppress AmbiguousMethodReference in AnyLongObjectId
  [error prone] fix ReferenceEquality warning in CommitBuilder
  [error prone] suppress NonAtomicVolatileUpdate warning in SimpleLruCache
  [error prone] fix ReferenceEquality warning in CommitGraphPane#authorFor
  [error prone] fix ReferenceEquality warning in RevWalk#isMergedInto
  [error prone] fix ReferenceEquality warning in RefUpdate#updateImpl
  [error prone] fix ReferenceEquality warning in static equals methods
  [error prone] suppress AmbiguousMethodReference in AnyObjectId
  [error prone] fix "FutureReturnValueIgnored" error in FS
  Fix formatting and add missing braces in Repository#stripWorkDir
  Repository: fix reference comparison of Files
  MergeAlgorithm: Suppress Error Prone warning about reference equality
  Fix NarrowingCompoundAssignment warnings from Error Prone
  FS_POSIX: handle Files.getFileStore() failures
  Fix OpenSshConfigTest#config
  FileSnapshot: fix bug with timestamp thresholding
  In LockFile#waitForStatChange wait in units of file time resolution
  Cache FileStoreAttributeCache per directory
  Fix FileSnapshot#save(long) and FileSnapshot#save(Instant)
  Persist minimal racy threshold and allow manual configuration
  Measure minimum racy interval to auto-configure FileSnapshot
  Reuse FileUtils to recursively delete files created by tests
  Fix FileAttributeCache.toString()
  Add test for racy git detection in FileSnapshot
  Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times
  Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit
  Add missing javadoc in org.eclipse.jgit.junit
  Enhance RepeatRule to report number of failures at the end
  Fix FileSnapshotTests for filesystem with high timestamp resolution
  Retry deleting test files in FileBasedConfigTest
  Measure filesystem timestamp resolution already in test setup
  Refactor FileSnapshotTest to use NIO APIs
  Measure stored timestamp resolution instead of time to touch file
  Handle CancellationException in FileStoreAttributeCache
  Fix FileSnapshot#saveNoConfig
  Use Instant for smudge time in DirCache and DirCacheEntry
  Use Instant instead of milliseconds for filesystem timestamp handling
  Workaround SecurityException in FS#getFsTimestampResolution
  Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution
  FS: ignore AccessDeniedException when measuring timestamp resolution
  Add debug trace for FileSnapshot
  Use FileChannel.open to touch file and set mtime to now
  Persist filesystem timestamp resolution and allow manual configuration
  Increase bazel timeout for long running tests
  Bazel: Fix lint warning flagged by buildifier
  Update bazlets to latest version
  Bazel: Add missing dependencies for ArchiveCommandTest
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  Add support for nanoseconds and microseconds for Config#getTimeUnit
  Optionally measure filesystem timestamp resolution asynchronously
  Delete unused FileTreeIteratorWithTimeControl
  FileSnapshot#equals: consider UNKNOWN_SIZE
  Timeout measuring file timestamp resolution after 2 seconds
  Fix RacyGitTests#testRacyGitDetection
  GlobalBundleCache: Fix ClassNewInstance warning from Error Prone
  IncorrectObjectTypeException: Fix typos in constructors' Javadoc
  Change RacyGitTests to create a racy git situation in a stable way
  Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8
  Fix non-deterministic hash of archives created by ArchiveCommand
  Update Maven plugins ecj, plexus, error-prone
  Update Maven plugins and cleanup Maven warnings
  Make inner classes static where possible
  Error Prone: Increase severity of NonOverridingEquals to ERROR
  Error Prone: Increase severity of ImmutableEnumChecker to ERROR
  GitDateParser#ParseableSimpleDateFormat: Make formatStr private final
  BatchRefUpdateTest: Suppress ImmutableEnumChecker warning
  PacketLineIn: Suppress comparison warnings for END and DELIM
  FileSnapshot#toString: Suppress ReferenceEquality warnings
  Blame: Suppress ReferenceEquality warning for RevCommit instances
  Fix API problem filters
  pgm: add missing optional dependency to org.tukaani:xz
  NetscapeCookieFile: Make hash static and group overloaded write
  NetscapeCookieFile: Javadoc fixes
  Config: Handle reference-equality warning (and empty javadoc)
  Error Prone: Increase severity of ShortCircuitBoolean to ERROR
  ObjectWalk: Prefer boolean operators over logical operators in comparisons
  BasePackFetchConnection: Prefer boolean operators over logical operators in comparisons
  PackWriter: Prefer boolean operators over logical operators in comparisons

Change-Id: I825fd55bcb5345fb7afe066bf54ca50325f40acb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoExport all packages of o.e.j.ant and o.e.j.archive bundles 69/147369/1
Matthias Sohn [Fri, 9 Aug 2019 11:24:50 +0000 (13:24 +0200)]
Export all packages of o.e.j.ant and o.e.j.archive bundles

Follow best practice in Eclipse OSGi based projects to export all
packages to foster reuse and experimentation.

Change-Id: I27f2810fbf0439fcb7c907e7b4d570a9613f8aa6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoDo not require test bundles to export all packages 68/147368/1
Matthias Sohn [Fri, 9 Aug 2019 11:16:11 +0000 (13:16 +0200)]
Do not require test bundles to export all packages

Configure PDE to not warn about not exported packages for test bundles.

Reusable test code which other bundles may want to reuse should go into
one of the junit bundles:
- org.eclipse.jgit.junit
- org.eclipse.jgit.junit.http
- org.eclipse.jgit.junit.ssh

Change-Id: Ifbdf30f8552e8f4bad6bbdeb63f729c53c844315
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix API problem filters 67/147367/1
Matthias Sohn [Fri, 9 Aug 2019 11:12:59 +0000 (13:12 +0200)]
Fix API problem filters

- add missing filters for methods introduced in 5.4.1 to fix error prone
warnings
- remove no longer needed filters

Change-Id: Ia74d4e9876eae8acd403c8dea1fdf1227d68037e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoIncrease severity of AmbiguousMethodReference to ERROR 45/147345/1
David Pursehouse [Fri, 9 Aug 2019 07:06:56 +0000 (16:06 +0900)]
Increase severity of AmbiguousMethodReference to ERROR

All instances of this problem have been fixed. Increase its severity
to ERROR to prevent reoccurrences.

Change-Id: I42d41a7c32b43d1ba59a28cd2f5a7d0ad315d8d9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years ago[error prone] suppress AmbiguousMethodReference in AnyLongObjectId 44/147344/1
David Pursehouse [Fri, 9 Aug 2019 07:06:28 +0000 (16:06 +0900)]
[error prone] suppress AmbiguousMethodReference in AnyLongObjectId

Move the implementation of the static equals() method to a new method
and suppress the error. Deprecate the old method to signal that we
intend to remove it in the next major release.

See https://errorprone.info/bugpattern/AmbiguousMethodReference

Change-Id: I712697a411ab44c6e05ae4604eb2dcb9c0f8abd3
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoUpgrade eclipse-jarsigner-plugin to 1.1.6 23/147323/1
David Pursehouse [Fri, 9 Aug 2019 01:01:39 +0000 (10:01 +0900)]
Upgrade eclipse-jarsigner-plugin to 1.1.6

Change-Id: Iae7ebfe24bec19c0b56a325ab38384cdb05d3d90
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoUpgrade Spotbugs to 3.1.12.2 27/146427/5
David Pursehouse [Sun, 21 Jul 2019 23:39:45 +0000 (08:39 +0900)]
Upgrade Spotbugs to 3.1.12.2

Change-Id: I4d673e058317e90b3de63f68202e580c0573f925
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoUpgrade maven-site-plugin to 3.8.2 39/146739/4
Marco Miller [Mon, 29 Jul 2019 16:32:07 +0000 (12:32 -0400)]
Upgrade maven-site-plugin to 3.8.2

Change-Id: I79a3032e2ff7af14a41e6eb2618d2b1e22d1fde2
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years ago[error prone] fix ReferenceEquality warning in CommitBuilder 20/147320/1
Matthias Sohn [Thu, 8 Aug 2019 23:40:46 +0000 (01:40 +0200)]
[error prone] fix ReferenceEquality warning in CommitBuilder

Comparing with UTF_8 constant in StandardCharsets doesn't require to use
equals.

Change-Id: I6c73a929367f32c9e76ce99f6c0af268480d9230
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years ago[error prone] suppress NonAtomicVolatileUpdate warning in SimpleLruCache 19/147319/1
Matthias Sohn [Thu, 8 Aug 2019 23:25:47 +0000 (01:25 +0200)]
[error prone] suppress NonAtomicVolatileUpdate warning in SimpleLruCache

It's not important to update time field, scalability is more important
than perfect LRU ordering of cache entries.

Change-Id: I22466c580cd3613b81e1989130b2724af9d6c466
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years ago[error prone] fix ReferenceEquality warning in CommitGraphPane#authorFor 18/147318/1
Matthias Sohn [Thu, 8 Aug 2019 23:13:54 +0000 (01:13 +0200)]
[error prone] fix ReferenceEquality warning in CommitGraphPane#authorFor

Change-Id: I4d620ca65f7cd85863fe8b7182b01d262fbe3504
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years ago[error prone] fix ReferenceEquality warning in RevWalk#isMergedInto 17/147317/1
Matthias Sohn [Thu, 8 Aug 2019 23:06:13 +0000 (01:06 +0200)]
[error prone] fix ReferenceEquality warning in RevWalk#isMergedInto

Change-Id: Ibef75e2bc76e90f6e29c4cb3ba1c1f6e67009b10
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years ago[error prone] fix ReferenceEquality warning in RefUpdate#updateImpl 16/147316/1
Matthias Sohn [Thu, 8 Aug 2019 23:04:24 +0000 (01:04 +0200)]
[error prone] fix ReferenceEquality warning in RefUpdate#updateImpl

Change-Id: I6687e1eec6b6ecfe319a598ef8aec1976cee354b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years ago[error prone] fix ReferenceEquality warning in static equals methods 15/147315/1
Matthias Sohn [Thu, 8 Aug 2019 23:01:27 +0000 (01:01 +0200)]
[error prone] fix ReferenceEquality warning in static equals methods

Implement a helper method suppressing the ReferenceEquality error prone
warning and use it to fix this warning in static equals methods where
this comparison is used to implement fast path of static equals
implementation.

See https://errorprone.info/bugpattern/ReferenceEquality

Change-Id: I33538a3406007d24efec3a504e031ca1069572ed
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years ago[error prone] suppress AmbiguousMethodReference in AnyObjectId 67/147267/2
Matthias Sohn [Thu, 8 Aug 2019 13:09:46 +0000 (15:09 +0200)]
[error prone] suppress AmbiguousMethodReference in AnyObjectId

Move the implementation of the static equals() method to a new method
and suppress the error. Deprecate the old method to signal that we
intend to remove it in the next major release.

See https://errorprone.info/bugpattern/AmbiguousMethodReference

Change-Id: I5e29c97f4db3e11770be589a6ccd785e2c9ac7f2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years ago[error prone] fix "FutureReturnValueIgnored" error in FS 61/147261/3
Matthias Sohn [Thu, 8 Aug 2019 12:27:08 +0000 (14:27 +0200)]
[error prone] fix "FutureReturnValueIgnored" error in FS

Change-Id: I53731091b3e34ac2e93a18f0ad6dd04dc56f8177
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix formatting and add missing braces in Repository#stripWorkDir 62/147262/1
Matthias Sohn [Thu, 8 Aug 2019 12:42:14 +0000 (14:42 +0200)]
Fix formatting and add missing braces in Repository#stripWorkDir

Change-Id: I601d917f3741e0207a8ee7a365d9c2dea6422401
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoRepository: fix reference comparison of Files 98/144198/2
Matthias Sohn [Sat, 15 Jun 2019 23:50:38 +0000 (01:50 +0200)]
Repository: fix reference comparison of Files

Change-Id: Ib46ea2c0d5039c88b4fc59723135c503a8c950ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMergeAlgorithm: Suppress Error Prone warning about reference equality 90/146290/2
David Pursehouse [Thu, 18 Jul 2019 07:21:13 +0000 (16:21 +0900)]
MergeAlgorithm: Suppress Error Prone warning about reference equality

Error Prone reports:

  [ReferenceEquality] Comparison using reference equality instead of
  value equality

The END_EDIT instance is used as a marker, and thus it's OK to use
a reference equality comparison. Factor the comparison to a method
and add a suppression.

Change-Id: I7d9dc1fa21f46c984787056b0b5d163e313026a6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoFix NarrowingCompoundAssignment warnings from Error Prone 86/144686/4
David Pursehouse [Sat, 22 Jun 2019 09:47:43 +0000 (18:47 +0900)]
Fix NarrowingCompoundAssignment warnings from Error Prone

Error Prone reports:

  [NarrowingCompoundAssignment] Compound assignments from long to int
  hide lossy casts

and

  [NarrowingCompoundAssignment] Compound assignments from int to byte
  hide lossy casts

  See https://errorprone.info/bugpattern/NarrowingCompoundAssignment

Fix the warnings by adding explicit casts or changing types as
necessary.

Now that all occurrences of the warning are fixed, increase its
severity to ERROR.

Change-Id: Idb3670e6047b146ae37daee07212ff9455512623
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoFS_POSIX: handle Files.getFileStore() failures 51/145451/3
Thomas Wolf [Thu, 4 Jul 2019 07:53:25 +0000 (09:53 +0200)]
FS_POSIX: handle Files.getFileStore() failures

Android unconditionally throws a SecurityException;[1] getFileStore()
is not supported. Catch the exception and don't attempt the hard-
linking atomic file mechanism.

[1] https://android.googlesource.com/platform/libcore/+/21e6175e25

Bug: 548947
Change-Id: Idfba2d9dbcbc80ea15ab2ae7889e5142444c1581
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoMerge branch 'stable-5.3' into stable-5.4 57/147257/1
Matthias Sohn [Thu, 8 Aug 2019 11:17:48 +0000 (13:17 +0200)]
Merge branch 'stable-5.3' into stable-5.4

* stable-5.3:
  Fix OpenSshConfigTest#config
  FileSnapshot: fix bug with timestamp thresholding
  In LockFile#waitForStatChange wait in units of file time resolution
  Cache FileStoreAttributeCache per directory
  Fix FileSnapshot#save(long) and FileSnapshot#save(Instant)
  Persist minimal racy threshold and allow manual configuration
  Measure minimum racy interval to auto-configure FileSnapshot
  Reuse FileUtils to recursively delete files created by tests
  Fix FileAttributeCache.toString()
  Add test for racy git detection in FileSnapshot
  Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times
  Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit
  Add missing javadoc in org.eclipse.jgit.junit
  Enhance RepeatRule to report number of failures at the end
  Fix FileSnapshotTests for filesystem with high timestamp resolution
  Retry deleting test files in FileBasedConfigTest
  Measure filesystem timestamp resolution already in test setup
  Refactor FileSnapshotTest to use NIO APIs
  Measure stored timestamp resolution instead of time to touch file
  Handle CancellationException in FileStoreAttributeCache
  Fix FileSnapshot#saveNoConfig
  Use Instant for smudge time in DirCache and DirCacheEntry
  Use Instant instead of milliseconds for filesystem timestamp handling
  Workaround SecurityException in FS#getFsTimestampResolution
  Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution
  FS: ignore AccessDeniedException when measuring timestamp resolution
  Add debug trace for FileSnapshot
  Use FileChannel.open to touch file and set mtime to now
  Persist filesystem timestamp resolution and allow manual configuration
  Increase bazel timeout for long running tests
  Bazel: Fix lint warning flagged by buildifier
  Update bazlets to latest version
  Bazel: Add missing dependencies for ArchiveCommandTest
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  Add support for nanoseconds and microseconds for Config#getTimeUnit
  Optionally measure filesystem timestamp resolution asynchronously
  Delete unused FileTreeIteratorWithTimeControl
  FileSnapshot#equals: consider UNKNOWN_SIZE
  Timeout measuring file timestamp resolution after 2 seconds
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8
  Fix non-deterministic hash of archives created by ArchiveCommand
  Update Maven plugins ecj, plexus, error-prone
  Update Maven plugins and cleanup Maven warnings
  Make inner classes static where possible
  Fix API problem filters

Change-Id: Iec3ad6ccc194582cb844310dc172c3103dae4457
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-5.2' into stable-5.3 36/147236/2
Matthias Sohn [Thu, 8 Aug 2019 10:30:47 +0000 (12:30 +0200)]
Merge branch 'stable-5.2' into stable-5.3

* stable-5.2:
  Fix OpenSshConfigTest#config
  FileSnapshot: fix bug with timestamp thresholding
  In LockFile#waitForStatChange wait in units of file time resolution
  Cache FileStoreAttributeCache per directory
  Fix FileSnapshot#save(long) and FileSnapshot#save(Instant)
  Persist minimal racy threshold and allow manual configuration
  Measure minimum racy interval to auto-configure FileSnapshot
  Reuse FileUtils to recursively delete files created by tests
  Fix FileAttributeCache.toString()
  Add test for racy git detection in FileSnapshot
  Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times
  Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit
  Add missing javadoc in org.eclipse.jgit.junit
  Enhance RepeatRule to report number of failures at the end
  Fix FileSnapshotTests for filesystem with high timestamp resolution
  Retry deleting test files in FileBasedConfigTest
  Measure filesystem timestamp resolution already in test setup
  Refactor FileSnapshotTest to use NIO APIs
  Measure stored timestamp resolution instead of time to touch file
  Handle CancellationException in FileStoreAttributeCache
  Fix FileSnapshot#saveNoConfig
  Use Instant for smudge time in DirCache and DirCacheEntry
  Use Instant instead of milliseconds for filesystem timestamp handling
  Workaround SecurityException in FS#getFsTimestampResolution
  Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution
  FS: ignore AccessDeniedException when measuring timestamp resolution
  Add debug trace for FileSnapshot
  Use FileChannel.open to touch file and set mtime to now
  Persist filesystem timestamp resolution and allow manual configuration
  Increase bazel timeout for long running tests
  Bazel: Fix lint warning flagged by buildifier
  Update bazlets to latest version
  Bazel: Add missing dependencies for ArchiveCommandTest
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  Add support for nanoseconds and microseconds for Config#getTimeUnit
  Optionally measure filesystem timestamp resolution asynchronously
  Delete unused FileTreeIteratorWithTimeControl
  FileSnapshot#equals: consider UNKNOWN_SIZE
  Timeout measuring file timestamp resolution after 2 seconds
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Deprecate Constants.CHARACTER_ENCODING in favor of
StandardCharsets.UTF_8
  Fix non-deterministic hash of archives created by ArchiveCommand
  Update Maven plugins ecj, plexus, error-prone
  Update Maven plugins and cleanup Maven warnings
  Make inner classes static where possible
  Fix API problem filters

Change-Id: I238adfd3080a5fed9d64c3c757297da6ea893918
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-5.1' into stable-5.2 22/147222/3
Matthias Sohn [Thu, 8 Aug 2019 09:18:14 +0000 (11:18 +0200)]
Merge branch 'stable-5.1' into stable-5.2

* stable-5.1:
  Fix OpenSshConfigTest#config
  FileSnapshot: fix bug with timestamp thresholding
  In LockFile#waitForStatChange wait in units of file time resolution
  Cache FileStoreAttributeCache per directory
  Fix FileSnapshot#save(long) and FileSnapshot#save(Instant)
  Persist minimal racy threshold and allow manual configuration
  Measure minimum racy interval to auto-configure FileSnapshot
  Reuse FileUtils to recursively delete files created by tests
  Fix FileAttributeCache.toString()
  Add test for racy git detection in FileSnapshot
  Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times
  Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit
  Add missing javadoc in org.eclipse.jgit.junit
  Enhance RepeatRule to report number of failures at the end
  Fix FileSnapshotTests for filesystem with high timestamp resolution
  Retry deleting test files in FileBasedConfigTest
  Measure filesystem timestamp resolution already in test setup
  Refactor FileSnapshotTest to use NIO APIs
  Measure stored timestamp resolution instead of time to touch file
  Handle CancellationException in FileStoreAttributeCache
  Fix FileSnapshot#saveNoConfig
  Use Instant for smudge time in DirCache and DirCacheEntry
  Use Instant instead of milliseconds for filesystem timestamp handling
  Workaround SecurityException in FS#getFsTimestampResolution
  Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution
  FS: ignore AccessDeniedException when measuring timestamp resolution
  Add debug trace for FileSnapshot
  Use FileChannel.open to touch file and set mtime to now
  Persist filesystem timestamp resolution and allow manual configuration
  Increase bazel timeout for long running tests
  Bazel: Fix lint warning flagged by buildifier
  Update bazlets to latest version
  Bazel: Add missing dependencies for ArchiveCommandTest
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  Add support for nanoseconds and microseconds for Config#getTimeUnit
  Optionally measure filesystem timestamp resolution asynchronously
  Delete unused FileTreeIteratorWithTimeControl
  FileSnapshot#equals: consider UNKNOWN_SIZE
  Timeout measuring file timestamp resolution after 2 seconds
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8
  Fix non-deterministic hash of archives created by ArchiveCommand
  Update Maven plugins ecj, plexus, error-prone
  Update Maven plugins and cleanup Maven warnings
  Make inner classes static where possible
  Fix API problem filters

Change-Id: Ia57385b2a60f48a5317c8d723721c235d7043a84
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix OpenSshConfigTest#config 44/147244/1
Matthias Sohn [Thu, 8 Aug 2019 08:10:12 +0000 (10:10 +0200)]
Fix OpenSshConfigTest#config

- use FS.DETECTED instead of db.getFS() since the ssh config is
typically in a different place than the repository, the same is used in
OpenSshConfig
- reduce unnecessary repeated writes by introducing wait for one tick of
the file time resolution

Change-Id: Ifac915e97ff420ec5cf8e2f162e351f9f51b6b14
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge changes from topic 'sshd'
David Pursehouse [Thu, 8 Aug 2019 01:31:57 +0000 (21:31 -0400)]
Merge changes from topic 'sshd'

* changes:
  sshd: add missing javadoc in SshTestGitServer
  sshd: shared reference in JGitClientSession must be volatile
  sshd: correct the protocol version exchange

5 years agoFileSnapshot: fix bug with timestamp thresholding 66/146866/13
Han-Wen Nienhuys [Wed, 31 Jul 2019 15:27:47 +0000 (17:27 +0200)]
FileSnapshot: fix bug with timestamp thresholding

Increase the safety factor to 2.5x for extra safety if max of measured
timestamp resolution and measured minimal racy threshold is < 100ms, use
1.25 otherwise since for large filesystem resolution values the
influence of finite resolution of the system clock should be negligible.

Before, not yet using the newly introduced minRacyThreshold measurement,
the threshold was 1.1x FS resolution, and we could issue the
following sequence of events,

  start
  create-file
  read-file (currentTime)
  end

which had the following timestamps:

  create-file 1564589081998
  start 1564589082002
  read 1564589082003
  end 1564589082004

In this case, the difference between create-file and read is 5ms,
which exceeded the 4ms FS resolution, even though the events together
took just 2ms of runtime.

Reproduce with:
  bazel test --runs_per_test=100 \
    //org.eclipse.jgit.test:org_eclipse_jgit_internal_storage_file_FileSnapshotTest

The file system timestamp resolution is 4ms in this case.

This code assumes that the kernel and the JVM use the same clock that
is synchronized with the file system clock. This seems plausible,
given the resolution of System.currentTimeMillis() and the latency for
a gettimeofday system call (typically ~1us), but it would be good to
justify this with specifications.

Also cover a source of flakiness: if the test runs under extreme load,
then we could have

  start
  create-file
  <long delay>
  read
  end

which would register as an unmodified file. Avoid this by skipping the
test if end-start is too big.

[msohn]:
- downported from master to stable-5.1
- skip test if resolution is below 10ms
- adjust safety factor to 1.25 for resolutions above 100ms

Change-Id: I87d2cf035e01c44b7ba8364c410a860aa8e312ef
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoIn LockFile#waitForStatChange wait in units of file time resolution 72/147072/4
Matthias Sohn [Mon, 5 Aug 2019 16:00:35 +0000 (18:00 +0200)]
In LockFile#waitForStatChange wait in units of file time resolution

Since we now measure file time resolution we can use it to replace the
hard coded wait time of 25ms. FileSnapshot#equals will return true until
the mtime of the old (o) and the new FileSnapshot (n) differ by at least
one  file time resolution.

Change-Id: Icb713a80ce9eb929242ed083406bfb6650c72223
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoCache FileStoreAttributeCache per directory 81/146281/34
Matthias Sohn [Fri, 19 Jul 2019 15:35:27 +0000 (17:35 +0200)]
Cache FileStoreAttributeCache per directory

Cache FileStoreAttributeCache entries since looking up FileStore for a
file may be expensive on some platforms.

Implement a simple LRU cache based on ConcurrentHashMap using a simple
long counter to order access to cache entries.

Change-Id: I4881fa938ad2f17712c05da857838073a2fc4ddb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Also-By: Marc Strapetz <marc.strapetz@syntevo.com>
5 years agoFix FileSnapshot#save(long) and FileSnapshot#save(Instant) 26/147026/2
Matthias Sohn [Sun, 4 Aug 2019 22:51:04 +0000 (00:51 +0200)]
Fix FileSnapshot#save(long) and FileSnapshot#save(Instant)

Use the fallback timestamp resolution as already described in the
javadoc of these methods. Using zero file timestamp resolution doesn't
make sense.

Change-Id: Iaad2a0f99c3be3678e94980a0a368181b6aed38c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoPersist minimal racy threshold and allow manual configuration 80/146280/23
Matthias Sohn [Wed, 17 Jul 2019 14:31:42 +0000 (16:31 +0200)]
Persist minimal racy threshold and allow manual configuration

To enable persisting the minimal racy threshold per FileStore add a
new config option to the user global git configuration:

- Config section is "filesystem"
- Config subsection is concatenation of
  - Java vendor (system property "java.vendor")
  - Java version (system property "java.version")
  - FileStore's name, on Windows we use the attribute volume:vsn instead
    since  the name is not necessarily unique.
  - separated by '|'
  e.g.
    "AdoptOpenJDK|1.8.0_212-b03|/dev/disk1s1"
  The same prefix is used as for filesystem timestamp resolution, so
  both values are stored in the same config section
- The config key for minmal racy threshold is "minRacyThreshold" as a
  time value, supported time units are those supported by
  DefaultTypedConfigGetter#getTimeUnit
- measure for 3 seconds to limit runtime which depends on hardware, OS
  and Java version being used

If the minimal racy threshold is configured for a given FileStore the
configured value is used instead of measuring it.

When the minimal racy threshold was measured it is persisted in the user
global git configuration.

Rename FileStoreAttributeCache to FileStoreAttributes since this class
is now declared public in order to enable exposing all attributes in one
object.

Example:

[filesystem "AdoptOpenJDK|11.0.3|/dev/disk1s1"]
timestampResolution = 7000 nanoseconds
minRacyThreshold = 3440 microseconds

Change-Id: I22195e488453aae8d011b0a8e3276fe3d99deaea
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Also-By: Marc Strapetz <marc.strapetz@syntevo.com>
5 years agoMeasure minimum racy interval to auto-configure FileSnapshot 85/146085/31
Matthias Sohn [Mon, 15 Jul 2019 13:00:09 +0000 (15:00 +0200)]
Measure minimum racy interval to auto-configure FileSnapshot

By running FileSnapshotTest#detectFileModified we found that the sum of
measured filesystem timestamp resolution and measured clock resolution
may yield a too small interval after a file has been modified which we
need to consider racily clean. In our tests we didn't find this behavior
on all systems we tested on, e.g. on MacOS using APFS and Java 8 and 11
this effect was not observed.

On Linux (SLES 15, kernel 4.12.14-150.22-default) we collected the
following test results using Java 8 and 11:

In 23-98% of 10000 test runs (depending on filesystem type and Java
version) the test failed, which means the effective interval which needs
to be considered racily clean after a file was modified is larger than
the measured file timestamp resolution.

"delta" is the observed interval after a file has been modified but
FileSnapshot did not yet detect the modification:

"resolution" is the measured sum of file timestamp resolution and clock
resolution seen in Java.

Java version    filesystem  failures resolution  min delta   max delta
1.8.0_212-b04   btrfs     98.6%       1 ms        3.6 ms      6.6 ms
1.8.0_212-b04   ext4        82.6%       3 ms        1.1 ms      4.1 ms
1.8.0_212-b04   xfs         23.8%       4 ms        3.7 ms      3.9 ms
1.8.0_212-b04   zfs         23.1%       3 ms        4.8 ms      5.0 ms
11.0.3+7        btrfs       98.1%       3 us        0.7 ms      4.7 ms
11.0.3+7        ext4        98.1%       6 us        0.7 ms      4.7 ms
11.0.3+7        xfs         98.5%       7 us        0.1 ms      8.0 ms
11.0.3+7        zfs         98.4%       7 us        0.7 ms      5.2 ms

Mac OS
1.8.0_212       APFS        0%          1 s
11.0.3+7        APFS        0%          6 us

The observed delta is not distributed according to a normal gaussian
distribution but rather random in the observed range between "min delta"
and "max delta".

Run this test after measuring file timestamp resolution in
FS.FileAttributeCache to auto-configure JGit since it's unclear what
mechanism is causing this effect.

In FileSnapshot#isRacyClean use the maximum of the measured timestamp
resolution and the measured "delta" as explained above to decide if a
given FileSnapshot is to be considered racily clean. Add a 30% safety
margin to ensure we are on the safe side.

Change-Id: I1c8bb59f6486f174b7bbdc63072777ddbe06694d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge "Constants for objects and info/{http-,}alternates"
Jonathan Nieder [Fri, 2 Aug 2019 16:28:54 +0000 (12:28 -0400)]
Merge "Constants for objects and info/{http-,}alternates"

5 years agoConstants for objects and info/{http-,}alternates 75/146675/4
David Turner [Thu, 25 Jul 2019 19:44:34 +0000 (15:44 -0400)]
Constants for objects and info/{http-,}alternates

These are useful to avoid typos, and also for tab completion.

Change-Id: I0f2d267e46b36bc40297c9657c447f3fd8b9f831
Signed-off-by: David Turner <dturner@twosigma.com>
5 years agoUploadPack: move writing of "packfile" header 92/139992/10
Jonathan Tan [Wed, 3 Apr 2019 17:52:48 +0000 (10:52 -0700)]
UploadPack: move writing of "packfile" header

In a subsequent patch, in some cases, PackWriter#writePack will be
responsible for both the "packfile-uris" and "packfile" sections,
meaning that (in these cases) it must write the "packfile" section
header itself.

In preparation for that patch, move the writing of the "packfile"
section header closer to the invocation of PackWriter#writePack when the
entire fetch response is configured to use the sideband. This means that
"packfile" is written *after* objects are counted (and progress messages
sent to the client in sideband 2) when the "sideband-all" feature is
used (whether "packfile-uris" is used or not), and written *before*
objects are counted otherwise.

Having code to write "packfile" in two places is unfortunate but
necessary. When "sideband-all" is not used, object counting has to
happen after "packfile" is written, because "packfile" activates the
sideband that allows counting progress to be transmitted. When
"packfile-uris" is used, object counting has to happen before "packfile"
is written, because object counting determines whether to send
"packfile-uris" or "packfile". When "sideband-all" is used but
"packfile-uris" is not used, either way works; this commit uses
"packfile-uris" behavior in this case.

Also make the naming of the sideband-activating methods in PacketLineOut
more consistent.

Change-Id: Ifbfd26cc26af10c41b77758168833702d6983df1
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
5 years agoReuse FileUtils to recursively delete files created by tests 91/146191/13
Matthias Sohn [Tue, 16 Jul 2019 14:34:56 +0000 (16:34 +0200)]
Reuse FileUtils to recursively delete files created by tests

Replace redundant complex implementation of recursive delete by the one
in FileUtils.

Change-Id: Iced1468b96c4f32381a9cf0c651b2bf6a9a9af35
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix FileAttributeCache.toString() 70/146670/1
Matthias Sohn [Fri, 26 Jul 2019 13:53:29 +0000 (15:53 +0200)]
Fix FileAttributeCache.toString()

We should not list the complete cache but only show the cache entry at
hand.

Change-Id: I22be2a4dcbf0145155e23f2389bfcf5662cf23a6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoAdd test for racy git detection in FileSnapshot 01/146001/25
Matthias Sohn [Fri, 12 Jul 2019 07:49:13 +0000 (09:49 +0200)]
Add test for racy git detection in FileSnapshot

Repeat the test 10000 times to get statistics if measured
fsTimestampResolution is working in practice to detect racy git
situations.

Add a class to compute statistics for this test. Log delta between
lastModified and time when FileSnapshot failed to detect modification.
This happens if the racy git limit determined by measuring filesystem
timestamp resolution and clock resolution is too small. If it would be
correct FileSnapshot would always detect modification or mark it
modified if time since modification is smaller than the racy git limit.

Change-Id: Iabe7af1a7211ca58480f8902d4fa4e366932fc77
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge "JGit pgm tests must quote paths on the command line"
David Pursehouse [Thu, 25 Jul 2019 23:27:56 +0000 (19:27 -0400)]
Merge "JGit pgm tests must quote paths on the command line"

5 years agoJGit pgm tests must quote paths on the command line 73/146573/2
Thomas Wolf [Wed, 24 Jul 2019 18:36:51 +0000 (20:36 +0200)]
JGit pgm tests must quote paths on the command line

The JGit pgm tests parse the command line internally using Linux
semantics, treating '\' as an escape. File paths therefore must
be quoted, otherwise Windows paths are destroyed. See the
attachment[1] on bug 548598.

[1] https://bugs.eclipse.org/bugs/attachment.cgi?id=279387

Bug: 544326
Change-Id: If42e29c8e808b0983fba2843a34c3ea3dd0e9246
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoPreUploadHookChain: Use list instead of array internally 56/145656/5
Ivan Frade [Mon, 8 Jul 2019 22:31:49 +0000 (15:31 -0700)]
PreUploadHookChain: Use list instead of array internally

The newly introduced ProtocolV2HookChain is implemented using lists
instead of arrays.

Update PostUploadHookChain to keep the hook chains implementation
consistent.

Change-Id: I5ae0c923f117ac48558a989464f5d5d868d81f76
Signed-off-by: Ivan Frade <ifrade@google.com>
5 years agoPostUploadHookChain: Use a list instead of array internally 55/145655/5
Ivan Frade [Mon, 8 Jul 2019 22:09:30 +0000 (15:09 -0700)]
PostUploadHookChain: Use a list instead of array internally

The newly introduced ProtocolV2HookChain is implemented using lists
instead of arrays.

Update PostUploadHookChain to keep hook chain implementations
consistent.

Change-Id: Ic5694feab943e8949896b93103dbf427716c9bd7
Signed-off-by: Ivan Frade <ifrade@google.com>
5 years agoMerge "UploadPack: add getProtocolV2Hook() method"
Jonathan Tan [Wed, 24 Jul 2019 17:37:45 +0000 (13:37 -0400)]
Merge "UploadPack: add getProtocolV2Hook() method"

5 years agoMerge "ProtocolV2HookChain: Allow to create a chain of protocol V2 hooks"
Jonathan Tan [Wed, 24 Jul 2019 17:37:07 +0000 (13:37 -0400)]
Merge "ProtocolV2HookChain: Allow to create a chain of protocol V2 hooks"

5 years agoRepeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times 00/146000/14
Matthias Sohn [Fri, 12 Jul 2019 07:46:25 +0000 (09:46 +0200)]
Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times

This should help to detect if measured fsTimeResolution is too small.

Change-Id: Id1f54dbdedb52b17859904e47776fa3a5887b8be
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit 21/146221/8
Matthias Sohn [Thu, 18 Jul 2019 11:26:22 +0000 (13:26 +0200)]
Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit

Use the same JDT core settings as used in org.eclipse.jgit but ignore
non-externalized strings.

Change-Id: If30013c76a197e571601a8abc882ac6a99592374
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoAdd missing javadoc in org.eclipse.jgit.junit 12/146312/3
Matthias Sohn [Thu, 18 Jul 2019 11:25:39 +0000 (13:25 +0200)]
Add missing javadoc in org.eclipse.jgit.junit

Change-Id: Ib709ef050bec31c87f542fb2cc977863dda93ef9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoJschConfigSessionFactory: [findbugs] Set synchronized 11/144011/5
Masaya Suzuki [Sun, 31 Mar 2019 17:37:25 +0000 (10:37 -0700)]
JschConfigSessionFactory: [findbugs] Set synchronized

Set synchronized to make the config access consistent.

> Inconsistent synchronization of
org.eclipse.jgit.transport.JschConfigSessionFactory.config; locked 80%
of time

In order to make JschConfigSessionFactory threadsafe, synchronize this
method as well.

Change-Id: I32d1bfc2e98363d254992144e795ce72fe1e8846
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
5 years agoMerge "UploadPackTest: use Consumer to set up UploadPack"
Jonathan Tan [Fri, 19 Jul 2019 18:37:56 +0000 (14:37 -0400)]
Merge "UploadPackTest: use Consumer to set up UploadPack"

5 years agoEnhance RepeatRule to report number of failures at the end 99/145999/12
Matthias Sohn [Fri, 12 Jul 2019 07:45:09 +0000 (09:45 +0200)]
Enhance RepeatRule to report number of failures at the end

In order to enable counting how frequently a test fails if repeated add
option abortOnFailure. If it is true the test aborts on the first
failure. Otherwise it runs the configured number of repetitions and, if
there was any failure, throws a RepeatException reporting how many of
the test repetitions failed.

Change-Id: Ic47de44d4a6273fddf04b9993ad989903efb40c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix FileSnapshotTests for filesystem with high timestamp resolution 76/145876/17
Matthias Sohn [Wed, 10 Jul 2019 14:17:21 +0000 (16:17 +0200)]
Fix FileSnapshotTests for filesystem with high timestamp resolution

When filesystem timestamp resolution is very high some tests don't work
since runtime of the test setup is too long to reach a racily clean
FileSnapshot. Hence skip these tests when timestamp resolution is higher
than 10 millisecond.

Change-Id: Ie47dd10eda22037b5c1ebff6b6becce0654ea807
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoRetry deleting test files in FileBasedConfigTest 35/146235/4
Matthias Sohn [Wed, 17 Jul 2019 08:11:05 +0000 (10:11 +0200)]
Retry deleting test files in FileBasedConfigTest

Change-Id: I304b2b6f2e39f72f620bba53aead60256aed3660
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMeasure filesystem timestamp resolution already in test setup 75/145875/17
Matthias Sohn [Wed, 10 Jul 2019 14:22:15 +0000 (16:22 +0200)]
Measure filesystem timestamp resolution already in test setup

This helps to avoid some time critical tests can't prepare the test
fixture intended since measuring timestamp resolution takes time.

Change-Id: Ib34023e682a106070ca97e98ef16789a4dfb97b4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoRefactor FileSnapshotTest to use NIO APIs 74/145874/14
Matthias Sohn [Wed, 10 Jul 2019 12:25:20 +0000 (14:25 +0200)]
Refactor FileSnapshotTest to use NIO APIs

- use Path instead of File
- create test directories, files and output stream using Files methods
- delete unused list "files"

Change-Id: I8c5c601eca9f613efb5618d33b262277df92a06a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMeasure stored timestamp resolution instead of time to touch file 54/145654/17
Matthias Sohn [Mon, 8 Jul 2019 08:20:16 +0000 (10:20 +0200)]
Measure stored timestamp resolution instead of time to touch file

Measure granularity of timestamps stored in the filesystem by setting
and then getting lastModified timestamp until the read value changed.
Increase increment exponentially to limit number of iterations starting
with 1 microsecond since Java's FileTime (up to Java 12) truncates
timestamps to 1 microsecond resolution. The chosen algorithm yields 2000
steps between 1 ms and 2.5 s.

Also measure clock resolution and add that for the total timestamp
resolution. This avoids systematic measurement errors introduced by
doing IO to touch a file.

Change-Id: I9b37138619422452373e298d9d8c7cb2c384db3f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoHandle CancellationException in FileStoreAttributeCache 63/146363/1
Matthias Sohn [Fri, 19 Jul 2019 12:43:52 +0000 (14:43 +0200)]
Handle CancellationException in FileStoreAttributeCache

Change-Id: If5985fbf04f630b1d72a1bafd508e0e15e1436be

5 years agoFix FileSnapshot#saveNoConfig 62/146362/1
Matthias Sohn [Fri, 19 Jul 2019 12:42:40 +0000 (14:42 +0200)]
Fix FileSnapshot#saveNoConfig

We should not use configuration when creating FileSnapshot when
accessing FileBasedConfig.

Change-Id: Ic521632870f18bb004751642b9d30648dd94049a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoUploadPack: add getProtocolV2Hook() method 95/145295/8
Ivan Frade [Mon, 8 Jul 2019 21:44:26 +0000 (14:44 -0700)]
UploadPack: add getProtocolV2Hook() method

A caller cannot install a second hook in the UploadPack without
overwriting whatever is already there.

Offer a method to get the current protocol v2 hook, so it can be chained
with new hooks.

Change-Id: Icb06f94ec52b8c8714f509b5b8622d6db42960fb
Signed-off-by: Ivan Frade <ifrade@google.com>
5 years agoProtocolV2HookChain: Allow to create a chain of protocol V2 hooks 94/145294/5
Ivan Frade [Tue, 2 Jul 2019 12:22:02 +0000 (14:22 +0200)]
ProtocolV2HookChain: Allow to create a chain of protocol V2 hooks

UploadPack only supports one protocol-v2 hook. There are already cases
where more than one is needed.

Offer a Chain class to compose ProtocolV2Hooks, as other hooks do. It
looks like a single hook but it calls all its members.

Change-Id: Idd173ca7df6672079ac0de03c67f77abac376538
Signed-off-by: Ivan Frade <ifrade@google.com>
5 years agoUse Instant for smudge time in DirCache and DirCacheEntry 84/146284/1
Matthias Sohn [Thu, 18 Jul 2019 01:36:18 +0000 (03:36 +0200)]
Use Instant for smudge time in DirCache and DirCacheEntry

Change-Id: I98050a51baf4726c5717ef62ce7f026173666bdf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoUse Instant instead of milliseconds for filesystem timestamp handling 37/145437/15
Matthias Sohn [Tue, 2 Jul 2019 23:07:14 +0000 (01:07 +0200)]
Use Instant instead of milliseconds for filesystem timestamp handling

This enables higher file timestamp resolution on filesystems like ext4,
Mac APFS (1ns) or NTFS (100ns) providing high timestamp resolution on
filesystem level.

Note:
- on some OSes Java 8,9 truncate milliseconds, see
https://bugs.openjdk.java.net/browse/JDK-8177809, fixed in Java 10
- UnixFileAttributes truncates timestamp resolution to microseconds when
converting the internal representation to FileTime exposed in the API,
see https://bugs.openjdk.java.net/browse/JDK-8181493
- WindowsFileAttributes also provides only microsecond resolution

Change-Id: I25ffff31a3c6f725fc345d4ddc2f26da3b88f6f2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoUpgrade maven-javadoc-plugin to 3.1.1 58/145658/3
David Pursehouse [Tue, 9 Jul 2019 02:00:51 +0000 (11:00 +0900)]
Upgrade maven-javadoc-plugin to 3.1.1

Change-Id: If1681581798d1f8b314b506680a75ec7becc1241
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoUpgrade ecj to 3.18.0 87/144587/6
David Pursehouse [Fri, 21 Jun 2019 00:57:40 +0000 (09:57 +0900)]
Upgrade ecj to 3.18.0

Change-Id: I785fb9b32b7720c0552da6a6e8f2b7b810f4d3e2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoUpgrade wagon-ssh to 3.3.3 03/144303/8
David Pursehouse [Tue, 18 Jun 2019 00:07:13 +0000 (09:07 +0900)]
Upgrade wagon-ssh to 3.3.3

Change-Id: I6f97dc478f4f62b2bf4a0667fb2dd8f8bdcf2707
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoWorkaround SecurityException in FS#getFsTimestampResolution 36/145436/12
Matthias Sohn [Wed, 3 Jul 2019 21:00:14 +0000 (23:00 +0200)]
Workaround SecurityException in FS#getFsTimestampResolution

On Android FS#getFsTimestampResolution always throws a
SecurityException, handle this by falling back to the fallback timestamp
resolution.

Bug: 548947
Change-Id: I0ee6cb3c20e189bdc8d488434a930427ad6f2df2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution 26/145126/13
Matthias Sohn [Wed, 26 Jun 2019 22:39:24 +0000 (00:39 +0200)]
Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution

Bug: 548682
Change-Id: I48840d3a68cf1db92c056d218a0d5ed0b9ea4c45
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFS: ignore AccessDeniedException when measuring timestamp resolution 99/144899/13
Matthias Sohn [Wed, 26 Jun 2019 07:10:31 +0000 (09:10 +0200)]
FS: ignore AccessDeniedException when measuring timestamp resolution

It seems on cygwin creating a file under a writable directory can fail
with AccessDeniedException. Log a warning in this case and fallback to
worst case timestamp resolution of 2 seconds.

Bug: 548648
Change-Id: Ic50c31ce9dc9ccadd4db5247df929418ac62d45c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoAdd debug trace for FileSnapshot 73/145873/9
Matthias Sohn [Wed, 10 Jul 2019 08:19:01 +0000 (10:19 +0200)]
Add debug trace for FileSnapshot

Checking lastModified is time critical hence debug trace is the only way
to analyze issues since debugging is impractical.

Also add configuration for buffering of log4j output to reduce runtime
impact when debug trace is on. Limit buffer to 1MiB and comment this
configuration out since we may not always want to use buffering.

Change-Id: Ib1a0537b67c8dc3fac994a77b42badd974ce6c97
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoUse FileChannel.open to touch file and set mtime to now 97/144897/8
Matthias Sohn [Tue, 25 Jun 2019 23:11:12 +0000 (01:11 +0200)]
Use FileChannel.open to touch file and set mtime to now

Use options
- StandardOpenOption.CREATE to create touched file if not existing
- StandardOpenOption.SYNC to enforce synch of data and meta data changes
- StandardOpenOption.WRITE

Also set mtime explicitly in FileUtils#touch to the current system time.
This should fix that the previous implementation didn't work on
- locally cached Windows network share (CSC-CACHE filesystem) mapped as
a drive
- nfsv4 mounts on Linux
and that it didn't create unborn file like Linux command "touch".
Apache common's and Guava's touch() use the same approach.

Immediately after creating the probe file used to measure timestamp
resolution touch it. This ensures we always use the local system clock
when measuring filesystem timestamp resolution. This should prevent that
clock skew could influence the measured timestamp resolution in case of
a mounted network filesystem.

Bug: 548598
Change-Id: Iaeaf5967963f582395a195aa637b8188bfadac60
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoPersist filesystem timestamp resolution and allow manual configuration 72/144672/14
Matthias Sohn [Fri, 21 Jun 2019 16:12:14 +0000 (18:12 +0200)]
Persist filesystem timestamp resolution and allow manual configuration

To enable persisting filesystem timestamp resolution per FileStore add a
new config section to the user global git configuration:

- Config section is "filesystem"
- Config subsection is concatenation of
  - Java vendor (system property "java.vm.vendor")
  - runtime version (system property "java.vm.version")
  - FileStore's name
  - separated by '|'
  e.g.
    "AdoptOpenJDK|1.8.0_212-b03|/dev/disk1s1"
  The prefix is needed since some Java versions do not expose the full
  timestamp resolution of the underlying filesystem. This may also
  depend on the underlying operating system hence concrete key values
  may not be portable.
- Config key for timestamp resolution is "timestampResolution" as a time
  value, supported time units are those supported by
  DefaultTypedConfigGetter#getTimeUnit

If timestamp resolution is already configured for a given FileStore
the configured value is used instead of measuring the resolution.

When timestamp resolution was measured it is persisted in the user
global git configuration.

Example:

[filesystem "AdoptOpenJDK|1.8.0_212-b03|/dev/disk1s1"]
timestampResolution = 1 seconds

If locking the git config file fails retry saving the resolution up to 5
times in order to workaround races with another thread.

In order to avoid stack overflow use the fallback filesystem timestamp
resolution when loading FileBasedConfig which creates itself a
FileSnapshot to help checking if the config changed.

Note:
- on some OSes Java 8,9 truncate to milliseconds or seconds, see
https://bugs.openjdk.java.net/browse/JDK-8177809, fixed in Java 10
- UnixFileAttributes up to Java 12 truncates timestamp resolution to
microseconds when converting the internal representation to FileTime
exposed in the API, see https://bugs.openjdk.java.net/browse/JDK-8181493
- WindowsFileAttributes also provides only microsecond resolution up to
Java 12

Hence do not attempt to manually configure a higher timestamp resolution
than supported by the Java version being used at runtime.

Bug: 546891
Bug: 548188
Change-Id: Iff91b8f9e6e5e2295e1463f87c8e95edf4abbcf8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoUploadPackTest: use Consumer to set up UploadPack 91/139991/5
Jonathan Tan [Wed, 3 Apr 2019 00:00:12 +0000 (17:00 -0700)]
UploadPackTest: use Consumer to set up UploadPack

Use a Consumer instead of several nullable variables to further
configure UploadPack. This is in preparation for a test in a subsequent
patch needing further customization of the UploadPack object before
invoking it.

Change-Id: I074dff92c711a5ba74558bb4b06c42c115fb9b7f
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
5 years agoSupport "sideband-all" in protocol v2 fetch 79/135579/6
Jonathan Tan [Tue, 22 Jan 2019 21:17:12 +0000 (13:17 -0800)]
Support "sideband-all" in protocol v2 fetch

Allow the client to specify "sideband-all" in a fetch v2 request,
indicating that the whole response is to be multiplexed (with a sideband
indicator on every non-flush and non-delim pkt) instead of only the
packfile being multiplexed. This allows, for example, progress messages
to be sent at any point in the response.

This implements the "sideband-all" feature documented in
Documentation/technical/protocol-v2.txt in Git.

Change-Id: I3e7f21c88ff0982b1b7ebb09c9ad6c742c4483c8
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
5 years agoUploadPack: remove pckOut instance field 78/135578/5
Jonathan Tan [Tue, 22 Jan 2019 21:17:12 +0000 (13:17 -0800)]
UploadPack: remove pckOut instance field

It is difficult to track what's happening with the pckOut instance
field, so replace it with a local variable in #upload instead.

Change-Id: Ibd9225b28334b7133eccdc6d82b26fc96cbde299
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
5 years agoUploadPackTest: refactor capability config test 77/135577/5
Jonathan Tan [Tue, 22 Jan 2019 21:17:12 +0000 (13:17 -0800)]
UploadPackTest: refactor capability config test

UploadPackTest.java contains tests that check behavior when
"allowfilter" and "allowrefinwant" are not set, are set, and are not set
but the client insists on using them anyway. Because another capability
is to be included in a subsequent patch, refactor the common code in
these tests.

Remove setBoolean calls with "false", as they are no-ops.

Also take the opportunity to eliminate the overspecification of the
"fetch=" line returned by the capability advertisement.

Change-Id: I289bbd11c902a513cd8d53bc34767e61ebbd5f17
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
5 years agoIncrease bazel timeout for long running tests 23/146123/1
Matthias Sohn [Mon, 10 Jun 2019 21:35:20 +0000 (23:35 +0200)]
Increase bazel timeout for long running tests

EolRepositoryTest and GcCommitSelectionTest timed out frequently when
running unit tests using bazel with the default timeout "moderate"
(300s). Increase timeout of these tests to "long" (900s).

Change-Id: I43588cf950f55b50f868d9fe9c66d22bd428a54c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoBazel: Fix lint warning flagged by buildifier 22/146122/1
David Ostrovsky [Tue, 18 Jun 2019 07:37:51 +0000 (09:37 +0200)]
Bazel: Fix lint warning flagged by buildifier

This change is fixing confusing name warning: [1].

  ./org.eclipse.jgit.test/tests.bzl:12: confusing-name:
  Never use 'l', 'I', or 'O' as names (they're too easily confused
  with 'I', 'l', or '0').

And is also fixing: "All calls to rules or macros should pass arguments
by keyword position argument" warning: [2].

  ./org.eclipse.jgit.test/BUILD:42: positional-args: All calls to rules
  or macros should pass arguments by keyword (arg_name=value) syntax.

[1] https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#confusing-name
[2] https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#positional-args

Change-Id: If5c28ec8a1ddc1d1b1035bd07b838a2a564aea4f
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
5 years agoUpdate bazlets to latest version 21/146121/1
David Ostrovsky [Tue, 18 Jun 2019 07:17:16 +0000 (09:17 +0200)]
Update bazlets to latest version

This is needed to make build tool chain compatible with the latest
Bazel releases.

Change-Id: I9822b5fe5f934457e6069217d687b3cf4764b7b7
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
5 years agoBazel: Add missing dependencies for ArchiveCommandTest 20/146120/1
David Pursehouse [Tue, 16 Jul 2019 02:41:05 +0000 (11:41 +0900)]
Bazel: Add missing dependencies for ArchiveCommandTest

Dependencies on commons-compress, xz, and jgit-archive are required
for the build to succeed.

Change-Id: I42f3721078a240ad93b8dcab909e66b9bfff0b56
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoBazel: Remove FileTreeIteratorWithTimeControl from BUILD file 19/146119/1
David Pursehouse [Tue, 16 Jul 2019 02:19:09 +0000 (11:19 +0900)]
Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file

FileTreeIteratorWithTimeControl was deleted in a024759, but was
not removed from the BUILD file, thus causing the bazel build to
fail.

Change-Id: I892c0ffcac947298d0d6009374ee2c5d9afefb66
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agosshd: add missing javadoc in SshTestGitServer 81/146081/1
Thomas Wolf [Mon, 15 Jul 2019 11:25:33 +0000 (13:25 +0200)]
sshd: add missing javadoc in SshTestGitServer

Change-Id: Ie2e207eb05e0f6da8018153f8a5dd636e8f35f4c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agosshd: shared reference in JGitClientSession must be volatile 48/146048/3
Thomas Wolf [Sat, 13 Jul 2019 13:14:17 +0000 (15:14 +0200)]
sshd: shared reference in JGitClientSession must be volatile

The proxy handler may be re-set from an unspecified I/O thread.
Declare the shared variable as volatile.

Change-Id: I4e7ce393ae2cdc7f1cd4edf40c137da6d6c50ad5
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agosshd: correct the protocol version exchange 47/146047/3
Thomas Wolf [Sat, 13 Jul 2019 08:57:11 +0000 (10:57 +0200)]
sshd: correct the protocol version exchange

RFC 4253 section 4.2 allows an ssh server to send additional lines
before its server identification string. Apache MINA sshd enforces
for these lines the constraints specified for the server identification
line, too: no NUL characters and not longer than 255 characters. That
is too strict. RFC 4253 doesn't mandate this, and it also doesn't
make sense given the rationale for these lines in RFC 4253: a TCP
wrapper may not be aware of SSH restrictions, and may not adhere to
these constraints.

Be more lenient when parsing the server's protocol version. Allow
NULs and longer lines in the preamble, and also handle line endings
more leniently. Only enforce the restrictions for the actual server
identification line.

Bug: 545939
Change-Id: I75955e9d8a8daef7c04fc0f39539c2ee93514e1c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoTreeRevFilter: Refresh code to latest coding standards 26/146026/1
Ivan Frade [Fri, 12 Jul 2019 22:59:54 +0000 (15:59 -0700)]
TreeRevFilter: Refresh code to latest coding standards

Use brackets in all "if" statements and remove the "final" from local
variables and method arguments.

https://wiki.eclipse.org/EGit/Contributor_Guide#Coding_standards

Change-Id: I185f3112848fc1218cd7adb9828488f03fa4ddfc
Signed-off-by: Ivan Frade <ifrade@google.com>
5 years agoAdd support for nanoseconds and microseconds for Config#getTimeUnit 71/144671/11
Matthias Sohn [Fri, 21 Jun 2019 15:58:56 +0000 (17:58 +0200)]
Add support for nanoseconds and microseconds for Config#getTimeUnit

Change-Id: I0a5828438810dd23790cba52d7ae2e055c6a3fc9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoOptionally measure filesystem timestamp resolution asynchronously 38/144638/12
Matthias Sohn [Fri, 21 Jun 2019 11:37:32 +0000 (13:37 +0200)]
Optionally measure filesystem timestamp resolution asynchronously

In order to avoid blocking on the main thread during measurement
interactive applications like EGit may want to measure the filesystem
timestamp resolution asynchronously.

In order to enable measurement in the background call
FileStoreAttributeCache.setAsyncfileStoreAttrCache(true)
before the first access to cached FileStore attributes.

Bug: 548188
Change-Id: I8c9a2dbfc3f1d33441edea18b90e36b1dc0156c7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoDelete unused FileTreeIteratorWithTimeControl 09/145909/1
Matthias Sohn [Thu, 11 Jul 2019 08:00:23 +0000 (10:00 +0200)]
Delete unused FileTreeIteratorWithTimeControl

The only usage of this test iterator was removed in df637928d. Hence
delete this iterator and associated test.

Change-Id: I47710133ec3edc675c21db210960c024982668c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFileSnapshot#equals: consider UNKNOWN_SIZE 86/145686/2
Han-Wen Nienhuys [Tue, 9 Jul 2019 12:49:30 +0000 (14:49 +0200)]
FileSnapshot#equals: consider UNKNOWN_SIZE

Add a unittest.

In commit I5485db55 ("Fix FileSnapshot's consideration of file size"),
the special casing of UNKNOWN_SIZE was forgotten.

This change, together with I493f3b57b ("Measure file timestamp
resolution used in FileSnapshot") introduced a regression that would
occasionally surface in Gerrit integration tests marked UseLocalDisk,
with the symptom that creating the Admin user in NoteDb failed with a
LOCK_FAILURE.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I7ffd972581f815c144f810481103c7985af5feb0

5 years agoFix typos in Javadoc 36/145636/1
Michael Keppler [Sun, 25 Nov 2018 19:15:53 +0000 (20:15 +0100)]
Fix typos in Javadoc

Change-Id: I225e04aefd02e56a62e16f3db53fdda77d5e7253
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
5 years agoCorrect @since in RevWalk for the --first-parent methods 64/145564/2
Thomas Wolf [Sat, 6 Jul 2019 15:34:35 +0000 (17:34 +0200)]
Correct @since in RevWalk for the --first-parent methods

Fixes PDE API checks complaining: the methods were added
in JGit 5.5.0.

Change-Id: I9ff860c3408c6bb3891fa0da7547394d0fe9d0b6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoTimeout measuring file timestamp resolution after 2 seconds 05/144605/2
Matthias Sohn [Fri, 21 Jun 2019 09:00:05 +0000 (11:00 +0200)]
Timeout measuring file timestamp resolution after 2 seconds

It was reported that measuring file timestamp resolution may hang
indefinitely on nfs. Hence timeout this measurement at the known worst
filesystem timestamp resolution (FAT) of 2 seconds.

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