]> source.dussan.org Git - jgit.git/log
jgit.git
5 years agoMerge branch 'stable-5.1' into stable-5.2 51/148851/2
Matthias Sohn [Tue, 3 Sep 2019 21:41:03 +0000 (23:41 +0200)]
Merge branch 'stable-5.1' into stable-5.2

* stable-5.1:
  Prepare 5.1.12-SNAPSHOT builds
  JGit v5.1.11.201909031202-r
  Prepare 4.11.10-SNAPSHOT builds
  JGit v4.11.9.201909030838-r
  Bazel: Update bazlets to the latest master revision
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  BatchRefUpdate: repro racy atomic update, and fix it
  Delete unused FileTreeIteratorWithTimeControl
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Silence API warnings

Change-Id: Iac5dc9683cea97db04d20f27c10f2e103d3ae7b5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoPrepare 5.1.12-SNAPSHOT builds 49/148849/1
Matthias Sohn [Tue, 3 Sep 2019 20:56:39 +0000 (22:56 +0200)]
Prepare 5.1.12-SNAPSHOT builds

Change-Id: I353ac3f23024063722abc7340bc9a6df3c615741
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoJGit v5.1.11.201909031202-r 21/148821/1 v5.1.11.201909031202-r
Matthias Sohn [Tue, 3 Sep 2019 16:01:55 +0000 (18:01 +0200)]
JGit v5.1.11.201909031202-r

Change-Id: I288acf670160b9bcd2d04f572a902b5838b4d4f8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-5.0' into stable-5.1 06/148806/2
Matthias Sohn [Tue, 3 Sep 2019 14:02:44 +0000 (16:02 +0200)]
Merge branch 'stable-5.0' into stable-5.1

* stable-5.0:
  Prepare 4.11.10-SNAPSHOT builds
  JGit v4.11.9.201909030838-r
  Bazel: Update bazlets to the latest master revision
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  BatchRefUpdate: repro racy atomic update, and fix it
  Delete unused FileTreeIteratorWithTimeControl
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Silence API warnings

Change-Id: I172136a031ff0730e575327cafb3527c9650a71d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-4.11' into stable-5.0 97/148797/2 stable-5.0
Matthias Sohn [Tue, 3 Sep 2019 13:54:54 +0000 (15:54 +0200)]
Merge branch 'stable-4.11' into stable-5.0

* stable-4.11:
  Prepare 4.11.10-SNAPSHOT builds
  JGit v4.11.9.201909030838-r
  Bazel: Update bazlets to the latest master revision
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  BatchRefUpdate: repro racy atomic update, and fix it
  Delete unused FileTreeIteratorWithTimeControl
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Silence API warnings

Change-Id: Ifb6a4dbea2f48fd2ffa66eb737d61920aefedfbd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoPrepare 4.11.10-SNAPSHOT builds 94/148794/1 stable-4.11
Matthias Sohn [Tue, 3 Sep 2019 12:49:20 +0000 (14:49 +0200)]
Prepare 4.11.10-SNAPSHOT builds

Change-Id: Ic98bd87d96ce627d38e1ecc2c3cb28b517ab489e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoJGit v4.11.9.201909030838-r 87/148787/1 v4.11.9.201909030838-r
Matthias Sohn [Tue, 3 Sep 2019 12:37:49 +0000 (14:37 +0200)]
JGit v4.11.9.201909030838-r

Change-Id: Ie60468569074197d49e19cbd0ffaedfe88f3d74e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-4.10' into stable-4.11 86/148786/1
Matthias Sohn [Tue, 3 Sep 2019 12:23:29 +0000 (14:23 +0200)]
Merge branch 'stable-4.10' into stable-4.11

* stable-4.10:
  Bazel: Update bazlets to the latest master revision
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  BatchRefUpdate: repro racy atomic update, and fix it
  Delete unused FileTreeIteratorWithTimeControl
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Silence API warnings

Change-Id: If672b4f0c350f4e8ff7e1e706485cffd8137236d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-4.9' into stable-4.10 80/148780/2 stable-4.10
Matthias Sohn [Tue, 3 Sep 2019 12:21:04 +0000 (14:21 +0200)]
Merge branch 'stable-4.9' into stable-4.10

* stable-4.9:
  Bazel: Update bazlets to the latest master revision
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file

Change-Id: I8bb74aacc1c010cfed9a0c8acffb520724f0e395
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-4.9' into stable-4.10 79/148779/2
Matthias Sohn [Tue, 3 Sep 2019 11:24:28 +0000 (13:24 +0200)]
Merge branch 'stable-4.9' into stable-4.10

* stable-4.9:
  BatchRefUpdate: repro racy atomic update, and fix it
  Delete unused FileTreeIteratorWithTimeControl
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Silence API warnings

Change-Id: Id5bf44645655fca40ad22bb1f1ad20a7c2e8f6db
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoBazel: Update bazlets to the latest master revision 78/148778/1 stable-4.9
David Pursehouse [Tue, 3 Sep 2019 11:35:47 +0000 (20:35 +0900)]
Bazel: Update bazlets to the latest master revision

The latest revision includes various fixes to allow the build
to work with recent versions of Bazel.

Change-Id: I72c100b99762010946d9b2784286af560bbdf185
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoBazel: Remove FileTreeIteratorWithTimeControl from BUILD file 77/148777/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>
(cherry picked from commit e54fde8616f53a6fab5201db4a0c7e67dd0145c5)

5 years agoBatchRefUpdate: repro racy atomic update, and fix it 06/148706/8
Han-Wen Nienhuys [Sat, 31 Aug 2019 19:33:58 +0000 (21:33 +0200)]
BatchRefUpdate: repro racy atomic update, and fix it

PackedBatchRefUpdate was creating a new packed-refs list that was
potentially unsorted. This would be papered over when the list was
read back from disk in parsePackedRef, which detects unsorted ref
lists on reading, and sorts them. However, the BatchRefUpdate also
installed the new (unsorted) list in-memory in
RefDirectory#packedRefs.

With the timestamp granularity code committed to stable-5.1, we can
more often accurately decide that the packed-refs file is clean, and
will return the erroneous unsorted data more often. Unluckily timed
delays also cause the file to be clean, hence this problem was
exacerbated under load.

The symptom is that refs added by a BatchRefUpdate would stop being
visible directly after they were added. In particular, the Gerrit
integration tests uses BatchRefUpdate in its setup for creating the
Admin group, and then tries to read it out directly afterward.

The tests recreates one failure case. A better approach would be to
revise RefList.Builder, so it detects out-of-order lists and
automatically sorts them.

Fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=548716 and
https://bugs.chromium.org/p/gerrit/issues/detail?id=11373.

Bug: 548716
Change-Id: I613c8059964513ce2370543620725b540b3cb6d1
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoDelete unused FileTreeIteratorWithTimeControl 65/148765/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>
(cherry picked from commit a024759cf5bf1cd6b9beb4f790d484943761a7e1)

5 years agoFix RacyGitTests#testRacyGitDetection 64/148764/1
Matthias Sohn [Tue, 18 Jun 2019 09:32:59 +0000 (11:32 +0200)]
Fix RacyGitTests#testRacyGitDetection

This test case assumed file system timestamp resolution of 1 second. On
filesystems with a finer resolution this test fails since the index
entry is only smudged if the file index entry's lastModified and the
lastModified of the git index itself are within the same filesystem
timer tick. Fix this by ensuring that these timestamps are identical
which should work for any filesystem timer resolution.

Bug: 548188
Change-Id: Id84d59e1cfeb48fa008f8f27f2f892c4f73985de
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
(cherry picked from commit 1159f9dd7c80a53c2509cd75d997a6afed37f9a6)

5 years agoChange RacyGitTests to create a racy git situation in a stable way 63/148763/1
Masaya Suzuki [Mon, 24 Dec 2018 03:31:10 +0000 (19:31 -0800)]
Change RacyGitTests to create a racy git situation in a stable way

By using File#setLastModified, we can create a racy git situation
stably.

Tested with --runs_per_test=100

Bug: 526111
Change-Id: I60b3632d353e19f335668325aa603640be423f58
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
(cherry picked from commit df637928d2ef4b9ee06af7e37344c7848f870ce4)

5 years agoSilence API warnings 42/148742/2
Matthias Sohn [Mon, 2 Sep 2019 23:27:02 +0000 (01:27 +0200)]
Silence API warnings

Change-Id: I27fd62de51ca0eedcc7e2e256487bda1e18bce8a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-5.1' into stable-5.2 00/148600/1
Jonathan Nieder [Fri, 30 Aug 2019 01:15:23 +0000 (18:15 -0700)]
Merge branch 'stable-5.1' into stable-5.2

* stable-5.1:
  Return a new instance from openSystemConfig and openUserConfig

Change-Id: I93afa16b14e3e2d127705e3378fb703d6c329694
Signed-off-by: Jonathan Nieder <jrn@google.com>
5 years agoReturn a new instance from openSystemConfig and openUserConfig 73/148373/4
Matthias Sohn [Mon, 26 Aug 2019 20:43:11 +0000 (22:43 +0200)]
Return a new instance from openSystemConfig and openUserConfig

Move the handling of cached user and system config to getSystemConfig
and getUserConfig methods and revert the implementation of
openSystemConfig and openUserConfig to the old stateless
implementation.

This ensures the open methods respect the passed-in parent config, which
may be different on each invocation. Additionally, returning a new
instance matches the behavior of the previous implementation of the
default system reader, which downstream callers may be depending on.

Move the implementation of the new caching methods getSystemConfig and
getUserConfig up to SystemReader. This avoids that we break the ABI for
subclasses of SystemReader.

Also see [1] which fixed a similar problem with Gerrit's custom
SystemReader.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/225458

Change-Id: If54a2491932d8fc914d4649cb73c9e837c5b8ad0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-5.1' into stable-5.2 35/148235/1
Matthias Sohn [Fri, 23 Aug 2019 14:00:38 +0000 (16:00 +0200)]
Merge branch 'stable-5.1' into stable-5.2

* stable-5.1:
  Prepare 5.1.11-SNAPSHOT builds
  JGit v5.1.10.201908230655-r
  Use AtomicReferences to cache user and system level configs
  Fix copy-paste typo in CloneCommand#cleanup

Change-Id: Ie383633de334e65901ed4c6deb2d59cfcce98e16

5 years agoPrepare 5.1.11-SNAPSHOT builds 31/148231/1
Matthias Sohn [Fri, 23 Aug 2019 13:47:03 +0000 (15:47 +0200)]
Prepare 5.1.11-SNAPSHOT builds

Change-Id: I8608580424d0e523dcace63f83ae530ba78dbb15
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoJGit v5.1.10.201908230655-r 18/148218/2 v5.1.10.201908230655-r
Matthias Sohn [Fri, 23 Aug 2019 10:52:08 +0000 (12:52 +0200)]
JGit v5.1.10.201908230655-r

Change-Id: I68d15ebd6054bdeaf62e14cddb87724828db7943
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoUse AtomicReferences to cache user and system level configs 12/148112/6
Matthias Sohn [Thu, 22 Aug 2019 08:23:50 +0000 (10:23 +0200)]
Use AtomicReferences to cache user and system level configs

This ensures that only one instance of user and one instance of system
config is set.

Change-Id: Idd00150f91d2d40af79499dd7bf8ad5940f87c4e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix copy-paste typo in CloneCommand#cleanup 48/148148/3
Adrien Bustany [Thu, 22 Aug 2019 15:11:45 +0000 (17:11 +0200)]
Fix copy-paste typo in CloneCommand#cleanup

deleteChildren was called on directory instead of gitDir, leading to a
potential null pointer exception if the git directory existed initially.

Bug: 550340
Change-Id: Iafc3b2961253a99862a59e81c7371f7bc564b412
Signed-off-by: Adrien Bustany <adrien-xx-eclipse@bustany.org>
5 years agoMerge branch 'stable-5.1' into stable-5.2 41/148041/1
Matthias Sohn [Wed, 21 Aug 2019 10:02:22 +0000 (12:02 +0200)]
Merge branch 'stable-5.1' into stable-5.2

* stable-5.1:
  Add missing @since tag on FileTreeIterator#getLastModifiedInstant
  Prepare 5.1.10-SNAPSHOT builds
  JGit v5.1.9.201908210455-r
  Avoid sign extension when comparing mtime with Instant#getEpochSecond
  Fix deprecation in DirCache caused by Instant based DirCacheEntry

Change-Id: Id824c0b8b14dad5947ae9da1f90c3471e07b400f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoAdd missing @since tag on FileTreeIterator#getLastModifiedInstant 37/148037/1
Matthias Sohn [Wed, 21 Aug 2019 09:52:20 +0000 (11:52 +0200)]
Add missing @since tag on FileTreeIterator#getLastModifiedInstant

Change-Id: I809399e6a71e0079d2f0007b0d3f00b531d451bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoPrepare 5.1.10-SNAPSHOT builds 36/148036/2
Matthias Sohn [Wed, 21 Aug 2019 09:36:51 +0000 (11:36 +0200)]
Prepare 5.1.10-SNAPSHOT builds

Change-Id: If10afc8e663299a15db8c5fd0574fb51bf7e7ae9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoJGit v5.1.9.201908210455-r 29/148029/1 v5.1.9.201908210455-r
Matthias Sohn [Wed, 21 Aug 2019 08:52:10 +0000 (10:52 +0200)]
JGit v5.1.9.201908210455-r

Change-Id: Iaade207292acb8b27e01aca7e1af97ad7db1e854
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoAvoid sign extension when comparing mtime with Instant#getEpochSecond 14/148014/1
Matthias Sohn [Tue, 20 Aug 2019 22:29:45 +0000 (00:29 +0200)]
Avoid sign extension when comparing mtime with Instant#getEpochSecond

Ensure we use the same type when comparing seconds since the epoch.

This does not prevent that in 2038 timestamps in seconds since the epoch
stored in a 32 bit integer will overflow. Integer.MAX_VALUE translates
to 2038-01-19T03:14:07Z. After this date we'll have an issue since we
store seconds since the epoch in a 32 bit integer in some places.

Bug: 319142
Change-Id: If0c03003d40b480f044686e2f7a2f62c9f4e2fe1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix deprecation in DirCache caused by Instant based DirCacheEntry 96/147996/2
Michael Keppler [Tue, 20 Aug 2019 14:09:12 +0000 (16:09 +0200)]
Fix deprecation in DirCache caused by Instant based DirCacheEntry

Replace the two int variables smudge_s and smudge_ns by an Instant and
use the new method DirCacheEntry.mightBeRacilyClean(Instant).

Change-Id: Id70adbb0856a64909617acf65da1bae8e2ae934a
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge branch 'stable-5.1' into stable-5.2 35/147935/3
Matthias Sohn [Mon, 19 Aug 2019 15:52:02 +0000 (17:52 +0200)]
Merge branch 'stable-5.1' into stable-5.2

* stable-5.1:
  Fix NPE in RebaseTodoFile#parseComments
  Fix NPE in ObjectIdOwnerMap#get
  Fix NPE in CommitOnlyTest#getHead
  FileUtils#lastModifiedInstant should not log error if path doesn't exist
  Cache user global and system-wide git configurations
  Avoid setup and saving FileStoreAttributes compete for ~/.gitconfig lock
  Add missing dependencies for running FS_POSIXTest in Eclipse
  Fix javadoc for SystemReader#getInstance
  Improve retry handling when saving FileStoreAttributes fails
  Ensure FSTest uses MockSystemReader
  Make supportsAtomicCreateNewFile return true as default
  Update orbit to R20190602212107-2019-06 to enable backports from master
  Handle InvalidPathException in FS_POSIX#createNewFileAtomic
  Ensure root cause of lock creation failures is logged
  Implement toString in MockSystemReader and MockConfig
  LocalDiskRefTreeDatabaseTest shall use MockSystemReader
  Ensure LocalDiskRepositoryTestCase#setup fully uses MockSystemReader
  Ensure we use MockSystemReader in tests
  Override FileBasedConfig's save method in MockConfig
  Remove FileBasedConfig.load(boolean) introduced in d45219ba
  Disable debug log for FS in org.eclipse.jgit.test
  Bazel: enable logging for tests in org.eclipse.jgit.test
  LockFile: log exception if creation of lock file failed
  Stop using deprecated Constants.CHARACTER_ENCODING

Change-Id: I48c585f3c9287be7d6ddb6b01a1955444e13fa31
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix NPE in RebaseTodoFile#parseComments 64/147864/10
Matthias Sohn [Fri, 16 Aug 2019 22:20:01 +0000 (00:20 +0200)]
Fix NPE in RebaseTodoFile#parseComments

Change-Id: I5487f3c2609eaf2a0ddf71ebb2f6c9701fb7600c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix NPE in ObjectIdOwnerMap#get 63/147863/8
Matthias Sohn [Fri, 16 Aug 2019 22:18:50 +0000 (00:18 +0200)]
Fix NPE in ObjectIdOwnerMap#get

Change-Id: I3812961a27ac410d610ef50c73a28f21bb05ae79
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix NPE in CommitOnlyTest#getHead 62/147862/8
Matthias Sohn [Fri, 16 Aug 2019 22:17:51 +0000 (00:17 +0200)]
Fix NPE in CommitOnlyTest#getHead

Change-Id: I05abd00d151cf9834d1a097dd16dc280b62a7edd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFileUtils#lastModifiedInstant should not log error if path doesn't exist 61/147861/8
Matthias Sohn [Fri, 16 Aug 2019 22:16:32 +0000 (00:16 +0200)]
FileUtils#lastModifiedInstant should not log error if path doesn't exist

Change-Id: Id8447735beb24becb41612d3d29d5351f8273d22
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoCache user global and system-wide git configurations 53/147753/11
Matthias Sohn [Wed, 14 Aug 2019 23:25:28 +0000 (01:25 +0200)]
Cache user global and system-wide git configurations

So far the git configuration and the system wide git configuration were
always reloaded when jgit accessed these global configuration files to
access global configuration options which are not in the context of a
single git repository. Cache these configurations in SystemReader and
only reload them if their file metadata observed using FileSnapshot
indicates a modification.

Change-Id: I092fe11a5d95f1c5799273cacfc7a415d0b7786c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
5 years agoAvoid setup and saving FileStoreAttributes compete for ~/.gitconfig lock 22/147522/5
Matthias Sohn [Sun, 11 Aug 2019 00:43:02 +0000 (02:43 +0200)]
Avoid setup and saving FileStoreAttributes compete for ~/.gitconfig lock

FS determines FileStore attributes in a background thread and tries to
save the results to the global git configuration. This competed with
LocalDiskRepositoryTestCase#setup trying to save changes to the same
file requiring the same lock. This frequently led to one of the threads
failing to acquire the lock.

Fix this by first initiating determination of FileStore attributes which
then uses a MockSystemReader not using a userConfig stored to disk which
avoids this race for the lock.

Change-Id: I30fcd96bc15100f8ef9b2a9eb3320bb5ace97c67
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoAdd missing dependencies for running FS_POSIXTest in Eclipse 52/147752/2
Matthias Sohn [Wed, 14 Aug 2019 11:25:16 +0000 (13:25 +0200)]
Add missing dependencies for running FS_POSIXTest in Eclipse

Change-Id: I35fcdfab55ff02943f6185b232e01ce9cfe151a9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoFix javadoc for SystemReader#getInstance 54/147754/3
Matthias Sohn [Wed, 14 Aug 2019 23:36:41 +0000 (01:36 +0200)]
Fix javadoc for SystemReader#getInstance

The existing javadoc was copied from another method and not adapted.

Change-Id: I39a7e5d719b2c379de9bd1a4710a55a73700c6f0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoImprove retry handling when saving FileStoreAttributes fails 73/147573/4
Matthias Sohn [Mon, 12 Aug 2019 15:40:39 +0000 (17:40 +0200)]
Improve retry handling when saving FileStoreAttributes fails

- fix handling of interrupts in FileStoreAttributes#saveToConfig
- increase retry wait time to 100ms
- don't wait after last retry
- dont retry if failure is caused by another exception than
LockFailedException

Change-Id: I108c012717d2bcce71f2c6cb9cf0879de704ebc2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMerge "Ensure FSTest uses MockSystemReader" into stable-5.1
David Pursehouse [Mon, 12 Aug 2019 23:37:11 +0000 (19:37 -0400)]
Merge "Ensure FSTest uses MockSystemReader" into stable-5.1

5 years agoEnsure FSTest uses MockSystemReader 76/147576/1
Matthias Sohn [Mon, 12 Aug 2019 22:26:25 +0000 (00:26 +0200)]
Ensure FSTest uses MockSystemReader

Tests shall not modify ~/.gitconfig. When running tests with bazel this
test failed since bazel isolates tests in a sandbox.

Change-Id: I7dd092afd14972da58a95eb7c200d353f0959fa1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoMake supportsAtomicCreateNewFile return true as default 74/140274/10
Vishal Devgire [Tue, 9 Apr 2019 07:31:36 +0000 (13:01 +0530)]
Make supportsAtomicCreateNewFile return true as default

The method org.eclipse.jgit.util.FS.supportsAtomicCreateNewFile()
should default to true as mentioned in docs [1]

org.eclipse.jgit.util.FS_POSIX.supportsAtomicCreateNewFile() method
will set the value to false if the git config
core.supportsatomiccreatenewfile is not set.

It should default to true if the configuration is undefined.

[1]
https://github.com/eclipse/jgit/blob/4169a95a65683e39e7a6a8f2b11b543e2bc754db/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java#L372

Bug: 544164
Change-Id: I16ccf989a89da2cf4975c200b3228b25ba4c0d55
Signed-off-by: Vishal Devgire <vishaldevgire@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoUpdate orbit to R20190602212107-2019-06 to enable backports from master 39/147539/2
Matthias Sohn [Mon, 12 Aug 2019 10:02:59 +0000 (12:02 +0200)]
Update orbit to R20190602212107-2019-06 to enable backports from master

update
- org.apache.httpcomponents.httpclient to 4.5.6.v20190503-0009
- org.apache.httpcomponents.httpcore to 4.4.10.v20190123-2214
- com.jcraft.jsch" version to 0.1.55.v20190404-1902
- org.mockito to 2.23.0.v20190527-1420
  add its dependencies
    - net.bytebuddy.byte-buddy 1.9.0.v20181107-1410
    - net.bytebuddy.byte-buddy-agent 1.9.0.v20181106-1534
- org.objenesis to 2.6.0.v20180420-1519

CQ: 18303 (objenesis)
CQ: 18703 (httpclient)
CQ: 18704 (httpcore)
CQ: 19588 (jsch)
CQ: 20214 (mockito)
CQ: 20215 (butebuddy)
CQ: 20216 (bytebuddy-agent)
Change-Id: I8d76375de867e32b7818449f843b7c053a717b5e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoHandle InvalidPathException in FS_POSIX#createNewFileAtomic 42/147542/1
Matthias Sohn [Mon, 12 Aug 2019 10:18:16 +0000 (12:18 +0200)]
Handle InvalidPathException in FS_POSIX#createNewFileAtomic

Bug: 547400
Change-Id: Ic3541e360a2968ba3532a3d3fa4828b0d0463c02
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoEnsure root cause of lock creation failures is logged 24/147524/3
Matthias Sohn [Mon, 12 Aug 2019 05:14:54 +0000 (07:14 +0200)]
Ensure root cause of lock creation failures is logged

Change-Id: I91cdf1e085a29c0aabd6d22c6ebe848b2d75f42c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoImplement toString in MockSystemReader and MockConfig 73/147473/2
Matthias Sohn [Sat, 10 Aug 2019 21:46:50 +0000 (23:46 +0200)]
Implement toString in MockSystemReader and MockConfig

This helps when debugging.

Change-Id: I3d72e1ea207ba60be77a7a9a840abb71ade1271c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoLocalDiskRefTreeDatabaseTest shall use MockSystemReader 72/147472/2
Matthias Sohn [Sat, 10 Aug 2019 21:45:43 +0000 (23:45 +0200)]
LocalDiskRefTreeDatabaseTest shall use MockSystemReader

It missed to call the setup() method of its super class which prepares
the MockSystemReader

Change-Id: I39858749f8d0115fc6ac7edc8847ffb2bbc85c33
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoEnsure LocalDiskRepositoryTestCase#setup fully uses MockSystemReader 71/147471/2
Matthias Sohn [Sat, 10 Aug 2019 21:44:39 +0000 (23:44 +0200)]
Ensure LocalDiskRepositoryTestCase#setup fully uses MockSystemReader

FS#getFileStoreAttributes used the real userConfig and not the mocked
one. This led to test errors when running tests with Bazel since it
sandboxes tests which prevents they can write to ~/.gitconfig.

Fix this by first preparing the MockedSystemReader and the mocked config
before calling FS#getFileStoreAttributes.

Also fix ConfigTest which broke due to this change since it inherits
from LocalDiskRepositoryTestCase and calls its setup method which was
changed here. We can no longer assert by comparing plain text since FS
adds FileStoreAttributes to the mocked userConfig. Also the default
options seen by this test changed since we now use a mocked config.

Change-Id: I76bc7c94953fe979266147d3b309a68dda9d4dfe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoEnsure we use MockSystemReader in tests 70/147470/2
Matthias Sohn [Sat, 10 Aug 2019 21:34:58 +0000 (23:34 +0200)]
Ensure we use MockSystemReader in tests

If we use the default system reader FileStoreAttributes cannot persist
attributes in userConfig when tests run in Bazel due to sandboxing.
Hence we need to ensure that all tests use MockSystemReader (and
especially a mocked userConfig).

Change-Id: Ic1ad8e2ec5a150c5433434a5f6667d6c4674c87d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoOverride FileBasedConfig's save method in MockConfig 69/147469/2
Matthias Sohn [Sat, 10 Aug 2019 21:48:42 +0000 (23:48 +0200)]
Override FileBasedConfig's save method in MockConfig

This ensures we don't try to persist MockConfig using its superclasses
save() method which fails with an NPE since MockConfig has no backing
file.

Change-Id: Ifba2d24c9438bb30d3828ed31a4c131f940b45eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoRemove FileBasedConfig.load(boolean) introduced in d45219ba 68/147468/2
Matthias Sohn [Sat, 10 Aug 2019 21:28:07 +0000 (23:28 +0200)]
Remove FileBasedConfig.load(boolean) introduced in d45219ba

We can't add this method to the super class StoredConfig since that
abstracts from filesystem storage. MockSystemReader.MockConfig is a
StoredConfig and is also used by tests for dfs based storage. Hence
remove this leaky abstraction.

This implies we always use the fallback FileStoreAttributes which means
a config file modification is considered racy within the first 2
seconds. This should not be an issue since typically configs change
rarely and re-reading a config within the racy period is relatively
cheap since configs are small.

Change-Id: Ia2615addc24a7cadf3c566ee842c6f4f07e159a5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoDisable debug log for FS in org.eclipse.jgit.test 67/147467/1
Matthias Sohn [Sat, 10 Aug 2019 18:32:07 +0000 (20:32 +0200)]
Disable debug log for FS in org.eclipse.jgit.test

This was enabled unintentionally in 06fc6c7c and spams the test logs. We
can enable this when needed.

Change-Id: I9f3042c0e285ff236be65fcc02bdcfdb90efc3af
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoBazel: enable logging for tests in org.eclipse.jgit.test 99/147399/2
Matthias Sohn [Fri, 9 Aug 2019 22:51:30 +0000 (00:51 +0200)]
Bazel: enable logging for tests in org.eclipse.jgit.test

- use slf4j-simple for logging in test runs
- for log configuration see
https://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html

Change-Id: I9f0a532644b31162c867cd0d63f083296eaf6be5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoLockFile: log exception if creation of lock file failed 98/147398/1
Matthias Sohn [Fri, 9 Aug 2019 22:39:16 +0000 (00:39 +0200)]
LockFile: log exception if creation of lock file failed

Change-Id: I4de75d12ec9e61193494916307289378cdb6220e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
5 years agoStop using deprecated Constants.CHARACTER_ENCODING 24/147324/1
David Pursehouse [Fri, 9 Aug 2019 03:11:41 +0000 (12:11 +0900)]
Stop using deprecated Constants.CHARACTER_ENCODING

Change-Id: I105b8a05bc64f249879a0795a059958553cc60c6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.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 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 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 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 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 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 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 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 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 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>
5 years agoFix RacyGitTests#testRacyGitDetection 36/144336/9
Matthias Sohn [Tue, 18 Jun 2019 09:32:59 +0000 (11:32 +0200)]
Fix RacyGitTests#testRacyGitDetection

This test case assumed file system timestamp resolution of 1 second. On
filesystems with a finer resolution this test fails since the index
entry is only smudged if the file index entry's lastModified and the
lastModified of the git index itself are within the same filesystem
timer tick. Fix this by ensuring that these timestamps are identical
which should work for any filesystem timer resolution.

Bug: 548188
Change-Id: Id84d59e1cfeb48fa008f8f27f2f892c4f73985de
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
5 years agoChange RacyGitTests to create a racy git situation in a stable way 39/144339/3
Masaya Suzuki [Mon, 24 Dec 2018 03:31:10 +0000 (19:31 -0800)]
Change RacyGitTests to create a racy git situation in a stable way

By using File#setLastModified, we can create a racy git situation
stably.

Tested with --runs_per_test=100

Bug: 526111
Change-Id: I60b3632d353e19f335668325aa603640be423f58
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
5 years agoDeprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8 35/144335/3
David Pursehouse [Sat, 29 Sep 2018 05:39:56 +0000 (14:39 +0900)]
Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8

Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
5 years agoFix non-deterministic hash of archives created by ArchiveCommand 72/144172/7
Matthias Sohn [Sun, 16 Jun 2019 21:58:06 +0000 (23:58 +0200)]
Fix non-deterministic hash of archives created by ArchiveCommand

Archives created by the ArchiveCommand didn't produce deterministic
archive hashes. For RevCommits RevWalk.parseTree returns the root tree
instead of the RevCommit hence retrieving the commit's timestamp didn't
work. Instead use RevWalk.parseAny and extract the tree manually.

Archive entries store timestamps with 1 second resolution hence we need
to wait longer when creating the same archive twice and compare archive
hashes. Otherwise hash comparison in tests wouldn't fail without this
patch.

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