Commit Graph

5078 Commits

Author SHA1 Message Date
Jonathan Nieder 863c2687df Merge "Constants for objects and info/{http-,}alternates" 2019-08-02 12:28:54 -04:00
David Turner 59640fb4f0 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>
2019-08-02 12:16:31 -04:00
Jonathan Tan 9110037e3e 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>
2019-07-30 23:37:49 -07:00
Matthias Sohn d17efe880d 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>
2019-07-26 15:53:29 +02:00
Matthias Sohn 130aa31262 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>
2019-07-26 15:49:38 +02:00
Ivan Frade e9dd131d55 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>
2019-07-24 14:09:48 -07:00
Ivan Frade d1f7efcf2b 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>
2019-07-24 14:09:48 -07:00
Jonathan Tan b734412724 Merge "UploadPack: add getProtocolV2Hook() method" 2019-07-24 13:37:45 -04:00
Jonathan Tan 690fc2267b Merge "ProtocolV2HookChain: Allow to create a chain of protocol V2 hooks" 2019-07-24 13:37:07 -04:00
Masaya Suzuki 6272694185 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>
2019-07-22 16:01:39 -07:00
Matthias Sohn 99d351d0cb 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>
2019-07-19 14:45:55 +02:00
Matthias Sohn 37f7679fc9 Handle CancellationException in FileStoreAttributeCache
Change-Id: If5985fbf04f630b1d72a1bafd508e0e15e1436be
2019-07-19 14:45:55 +02:00
Matthias Sohn 72d6e304b8 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>
2019-07-19 14:45:55 +02:00
Ivan Frade 04cecae3da 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>
2019-07-18 10:39:25 -07:00
Ivan Frade 9b7a4a30ca 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>
2019-07-18 10:33:51 -07:00
Matthias Sohn d8d9427277 Use Instant for smudge time in DirCache and DirCacheEntry
Change-Id: I98050a51baf4726c5717ef62ce7f026173666bdf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-07-18 03:36:18 +02:00
Matthias Sohn 95e8264cc8 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>
2019-07-18 03:27:52 +02:00
Matthias Sohn 4db39f5074 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>
2019-07-17 09:42:15 +02:00
Matthias Sohn 79ede0c322 Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution
Bug: 548682
Change-Id: I48840d3a68cf1db92c056d218a0d5ed0b9ea4c45
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-07-17 09:42:14 +02:00
Matthias Sohn be66222d1a 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>
2019-07-17 09:42:14 +02:00
Matthias Sohn 09fec1a102 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>
2019-07-17 09:42:14 +02:00
Matthias Sohn 8a0ed8a004 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>
2019-07-17 09:42:14 +02:00
Matthias Sohn 16760c3e9a 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>
2019-07-17 09:42:14 +02:00
Jonathan Tan 79d776429e 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>
2019-07-16 11:13:30 -07:00
Jonathan Tan c1ed69de4a 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>
2019-07-16 10:05:18 -07:00
Ivan Frade 848d9f0d71 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>
2019-07-12 16:19:10 -07:00
Matthias Sohn 121c957405 Add support for nanoseconds and microseconds for Config#getTimeUnit
Change-Id: I0a5828438810dd23790cba52d7ae2e055c6a3fc9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-07-11 10:12:04 +02:00
Matthias Sohn a950eac23b 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>
2019-07-11 10:12:04 +02:00
Han-Wen Nienhuys 84e6c24e58 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
2019-07-09 15:33:23 +02:00
Michael Keppler 3f41bd9d2f Fix typos in Javadoc
Change-Id: I225e04aefd02e56a62e16f3db53fdda77d5e7253
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2019-07-08 20:04:55 +02:00
Thomas Wolf 758124fa9c 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>
2019-07-06 21:45:19 +02:00
Matthias Sohn 850b9d7540 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>
2019-07-03 21:34:29 +02:00
Masaya Suzuki 3091dc4348 Move ServiceMayNotContinueException handling code from sendPack
All other exceptions are handled in a wrapped sendPack method.
Consolidate the error handling code.

Change-Id: Ieac0ce64960534d009d1e6b025130b021b744794
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-06-27 19:38:54 -04:00
Masaya Suzuki f8267c9edb Move exception handling code to the caller
By doing this, exceptions thrown by sendPack are also covered by the
same code.

Change-Id: I3509f2d832af1410f307e931577e4d07e32b014e
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-06-27 19:38:45 -04:00
Masaya Suzuki ca360ea2b5 Do not ignore secondary failure
When another exception is thrown while handling another exception, that
exception can be attached to the original exception since Java 7
(Throwable#getSuppressed). Attach the secondary exception to the
original exception instead of throwing it away.

Change-Id: Ia093b8207714f2638e0343bc45a83d4342947505
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-06-27 19:38:36 -04:00
Dave Borowitz 4973f05252 RevWalk: Add a setFirstParent that mimics C git's --first-parent
RevWalk does not currently provide a --first-parent equivalent and the
feature has been requested.

Add a field to the RevWalk class to specify whether walks should
traverse first parents only. Modify Generator implementations to support
the feature.

Change-Id: I4a9a0d5767f82141dcf6d08659d7cb77c585fae4
Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Alex Spradlin <alexaspradlin@google.com>
2019-06-27 16:27:33 -07:00
Jonathan Tan cbccfed4b3 UploadPack: support lazy fetches if no bitmap
If a client clones with "--filter=blob:none", the checkout that "git
clone" automatically does causes the client to fetch all blobs at HEAD.
When fetching from a non-bitmapped repository, this will fail if an
object walk is ever needed, because JGit currently rejects such requests
- see the commit message of d3021788d2 ("Use bitmaps for non-commit
reachability checks", 2017-11-10) for more information.

Rejecting such requests in the absence of bitmaps is probably
overzealous: it is true that the server would prefer to have bitmaps in
this case, but there might be a small proportion of repos (for example,
very small repos or newly created ones) that do not have bitmaps, yet
the server would still like to have partial clones for them.

So, allow such requests, performing the object walk reachability check
if necessary. Limit this to servers with "uploadpack.allowFilter"
configured, so that servers wanting to support partial clone have this
functionality, and servers that do not support partial clone do not have
to pay the object walk reachability check cost.

Change-Id: I51964bafec68696a799625d627615b4f45ddbbbf
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2019-06-25 09:22:47 -07:00
David Pursehouse dad9e1ff95 GlobalBundleCache: Fix ClassNewInstance warning from Error Prone
Error Prone reports:

  [ClassNewInstance] Class.newInstance() bypasses exception checking;
  prefer getDeclaredConstructor().newInstance()

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

This was the only occurrence of the warning in the code base; now it's
fixed, increase the severity to ERROR to prevent future occurrences.

Change-Id: Ic04d1c5d2bd458bbb4bb399d6ce9d147bd48d0b1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-22 18:44:23 +09:00
Michael Keppler 4b0c192f2d Fix bundle localization of Apache SSH bundle
The placeholders in manifest and plugin.properties did not match. To
avoid similar issues, all placeholders have been changed to
Bundle-Vendor and Bundle-Name now.

Bug:548503
Change-Id: Ibd4b9bc237b323e614506b97e5fbc99416365040
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2019-06-21 17:54:06 +02:00
David Pursehouse 99a5fa2283 IncorrectObjectTypeException: Fix typos in constructors' Javadoc
Change-Id: Ib63310a603ba432e65d0c46e4b6b8d440ca6a115
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-20 08:41:34 +09:00
René Scheibe 8f9697b4c1 Fix "reset -hard" bug that folders could not be deleted
The deleted code is not required as removed files are deleted correctly in
doCheckout() anyway.

The deleted code failed in case a non-empty directory had to be deleted.
file.delete() returned false, triggering an exception.

Bug: 479266
Change-Id: I011bb3882ff0c35b238aa3eccad7889041210277
Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
2019-06-19 11:52:02 +02:00
René Scheibe b4edf9ec14 Fix "reset -hard" bug that folders could not be created
Creating a folder failed in case a file with the same name already
existed.

Bug: 479266
Change-Id: Ia987660ec0968ad4081dbd5a60e80660539497e3
Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-19 11:51:24 +02:00
David Pursehouse f18b5010fc Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8
Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-19 10:43:01 +02:00
Matthias Sohn 9387288a86 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>
2019-06-19 10:43:00 +02:00
Matthias Sohn 2d0a1adf05 Update Maven plugins and cleanup Maven warnings
update Maven plugins
- jacoco-maven-plugin to 0.8.4
- japicmp-maven-plugin to 0.14.1
- maven-compiler-plugin to 3.8.1
- maven-deploy-plugin to 3.0.0-M1
- maven-enforcer-plugin to 3.0.0-M2
- maven-install-plugin to 3.0.0-M1
- maven-jar-plugin to 3.1.2
- maven-javadoc-plugin to 3.1.0
- maven-jxr-plugin to 3.0.0
- maven-pmd-plugin to 3.12.0
- maven-resources-plugin to 3.1.0
- maven-shade-plugin to 3.2.1
- maven-source-plugin to 3.1.0
- maven-surefire-plugin to 3.0.0-M3
- spotbugs-maven-plugin to 3.1.12
- tycho to 1.3.0
- tycho-pack200a-plugin to 1.3.0
- tycho-pack200b-plugin to 1.3.0

Cleanup Maven warnings
- pin version of all used Maven plugins
- remove deprecated way to declare minimum Maven version

Change-Id: If23e2e2bb03e5e1e7b1eb9d4924a8faa0aa3704e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-18 16:55:44 +02:00
David Ostrovsky 7607465006 [Java 11] Remove dependency on javax.xml.bind package
Replace javax.xml.bind.DatatypeConverter, that is not available any
more in Java 11 and later with Hex utility from non optional Bouncy
Castle library.

Bug: 540790
Change-Id: I9903c00ecc1a434e9795b8ba9267f02628fdc0e9
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2019-06-18 02:22:21 +02:00
David Pursehouse 6d0168a414 Make inner classes static where possible
As reported by Error Prone:

An inner class should be static unless it references members of its
enclosing class. An inner class that is made non-static unnecessarily
uses more memory and does not make the intent of the class clear.

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

Change-Id: Ib99d120532630dba63cf400cc1c61c318286fc41
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
(cherry picked from commit ee40efcea4)
2019-06-17 07:48:34 +02:00
David Pursehouse 430be89307 Error Prone: Increase severity of NonOverridingEquals to ERROR
Error Prone reports the warning on several classes:

   [NonOverridingEquals] equals method doesn't override Object.equals;
   if this is a type-specific helper for a method that does override
   Object.equals, either inline it into the callers or rename it to
   avoid ambiguity.

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

Most of these are in the public API, so we can't rename or inline them
without breaking the API. FileSnapshot is not part of the public API,
but clients may be using it anyway, so we also shouldn't change that.

Suppress all the warnings instead. Having the check at severity ERROR
will at least make sure we don't introduce any new occurrences.

Change-Id: I92345c11256f06b4fa03ccc13337f72af5a43591
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-17 09:40:11 +09:00
David Pursehouse 383fe1e467 GitDateParser#ParseableSimpleDateFormat: Make formatStr private final
ParseableSimpleDateFormat is an enum, and enums must be immutable,
hence the member should be final. At the same time, make it private
since it does not need to be publicly visible.

Change-Id: I7e181f591038d556f1123b6e37adf8441059e99a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-17 08:18:12 +09:00
David Pursehouse 9e499dad6d PacketLineIn: Suppress comparison warnings for END and DELIM
Reference comparison is intentional. The END and DELIM string
constants are used as sentinels and will always be the same
instances.

Suppress both ReferenceEquality and StringEquality warnings.

Change-Id: I4ce0495702c56b3911f42f26c2f81d28073cbe19
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-17 08:18:12 +09:00
David Pursehouse 50c0275aba FileSnapshot#toString: Suppress ReferenceEquality warnings
Reference comparison with EMPTY and MISSING_FILE is intended; these
are static instances used as markers, and will always be the same
instances.

Change-Id: Ic27f5b797bdb9370cf8f6b3b7bb3f1523d4a454c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-17 08:18:12 +09:00
Matthias Sohn f6c989665e Fix API problem filters
Change-Id: I0f7a72934022346c9903d7dc5ec11e959cc8dac3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-17 00:35:10 +02:00
Matthias Sohn 395e072a34 Delete unused API problem filters
Change-Id: Id8dcc337aab4ec6a11a2bb60b85d0db42986b80b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-16 02:25:33 +02:00
Pavel Flaška e456fba8ac Walk tag chains for --include-tag options
When cloning repository with --single-branch option, tag chains are not
packed and pack file is broken in some cases.

Typical test-case:
git tag -a test_tag <commit-id>
git tag -a test_prev_tag test_tag
git tag -d test_tag

git clone --single-branch <repository>
fatal: did not receive expected object <test_tag_id>

The reason for that is missing object for original test_tag reference,
which was deleted.

Problem description:
When pack-objects is given --include-tag, it peels each tag reference
down to a commit. If the commit is prepared to be packed, we we have to
include such tag too. The problem is when the tag points to through some
chain of other tag to commit. Then, the inner tags are not added leading
to broken pack.

Fix:
When going to commit, we have to check and add any of the tags on the
way (if they were not selected, which may happen with --single-branch
option).

Change-Id: I1682d4a2c52d674f90a1b021e0f6c3524c5ce5bc
Signed-off-by: Pavel Flaška <Pavel.Flaska@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-16 02:17:20 +02:00
Ivan Frade 67b7771708 NetscapeCookieFile: Make hash static and group overloaded write
Issues reported by downstream analyzers.

The "hash" method can be static.

It is a good practice to group overloaded methods. Move the write(URL)
method with the other writes.

Change-Id: Ia42c0d7081333edcb77e58d5e627929d29672490
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-06-15 21:55:40 +02:00
Ivan Frade 83b0efbae6 NetscapeCookieFile: Javadoc fixes
Downstream analyzers reported empty fields in the javadoc. I corrected
few more details:

* Fill empty javadoc fields.
* Use <p> to separate description paragraphs.
* End description paragraphs with a period.
* Remove period at the end of field descriptions.

Change-Id: I749e4b821fc855999caddc442ac788fa514386ea
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-06-15 21:55:40 +02:00
Ivan Frade 96bd5ad8a3 Config: Handle reference-equality warning (and empty javadoc)
Reported by downstream analyzers. Suppress the warning on reference
equality for isMissing and fill an empty javadoc field.

Change-Id: I3494423daf2a53ca10e0a9c66553f00204c35396
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-06-15 21:55:39 +02:00
David Pursehouse 0f9063941c ObjectWalk: Prefer boolean operators over logical operators in comparisons
Using the | and & operators in boolean conditions results in a warning
from Error Prone:

  [ShortCircuitBoolean]
  Prefer the short-circuiting boolean operators && and || to & and |.
  see https://errorprone.info/bugpattern/ShortCircuitBoolean

Change-Id: I182f986263b8b9ac189907f4bd1662b4092a52d8
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-15 21:55:39 +02:00
David Pursehouse 2eeabde94a BasePackFetchConnection: Prefer boolean operators over logical operators in comparisons
Using the | and & operators in boolean conditions results in a warning
from Error Prone:

  [ShortCircuitBoolean]
  Prefer the short-circuiting boolean operators && and || to & and |.
  see https://errorprone.info/bugpattern/ShortCircuitBoolean

Change-Id: I6cccca3fdd28bf93b302a9b8a66e68ac912cb60d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-15 21:55:39 +02:00
David Pursehouse 858736df37 PackWriter: Prefer boolean operators over logical operators in comparisons
Using the | and & operators in boolean conditions results in a warning
from Error Prone:

  [ShortCircuitBoolean]
  Prefer the short-circuiting boolean operators && and || to & and |.
  see https://errorprone.info/bugpattern/ShortCircuitBoolean

Change-Id: I4275c60306e43c74030c4465ba02cb853ad444e1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-15 21:55:39 +02:00
Matthias Sohn 16fd3feefc Prepare 5.5.0-SNAPSHOT builds
Change-Id: I177d637e552a79014816dc5d2ef5ccda506adb39
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-13 03:01:15 +02:00
Matthias Sohn f3b7c2beae Prepare 5.4.1-SNAPSHOT builds
Change-Id: I8620d03c1cd5c1d0ad04e7607553e9aa18def9bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-12 17:35:11 +02:00
Matthias Sohn 3dad0682be JGit v5.4.0.201906121030-r
Change-Id: Ie68828af68d07cf8e3fe778d39436f539f1c73d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-12 16:29:11 +02:00
Matthias Sohn 0e9361f066 JGit v5.4.0.201906120450-r
Change-Id: Iea17cba848d4e53d69d34e952a2476c375721aa4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-12 10:50:14 +02:00
David Pursehouse 0f4554f126 Increase severity of OperatorPrecedence to ERROR, and fix instances
Fix all remaining instances of the OperatorPrededence warning, by adding
parentheses to make the precedence explicit.

Change-Id: Ib296dfed09f9be042d0ff0f7fad8214e4dd766b4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-12 09:28:54 +09:00
Matthias Sohn c177c6f4c5 Merge branch 'master' into stable-5.4
* master:
  Handle missing "ours" stage in WorkingTreeIterator.hasCrLfInIndex()
  Config: Add helper method to check for empty value
  ErrorProne: Increase severity of FutureReturnValueIgnored to ERROR
  FS_Win32: Add missing parentheses on if-blocks
  Upgrade spotbugs to 3.1.12
  Abbreviated{Long}ObjectId: Make operator precedence explicit
  GC: Update TODO comments
  FS_POSIX: Fix reference comparison of Boolean.FALSE
  Increase bazel timeout for long running tests
  Use bazelisk to switch between used bazel version
  Bump minimum Bazel version to 0.26.1
  Bazel: Bump skylib library version to 0.8.0
  Retry loading config when locked by another process
  Make pull --rebase on an unborn branch do a checkout
  Warn if configured cookie file is missing
  Handle escaped CR-LF in git config files
  DescribeCommand: use glob match instead of path match
  Fix off-by-one error in RebaseTodoFile when reading a todo file
  Consistently use "!isEmpty()" to detect non-empty list
  TransportHttp: Check for non-empty list with "!isEmpty()" rather than
    "size() > 0"
  TransportHttp: Fix comparison of size with ">= 0"
  NetscapeCookieFileTest: Split HttpCookiesMatcher to own class
  Bazel: Add missing dependency on mockito for TransportHttpTest
  Determine hard-linking and nlink support per FileStore
  Support reading and writing cookies.
  Repository: Add getIdentifier() method to avoid instanceof operator
  Update to Orbit R20190602212107
  PacketLineIn: Deprecate the END constant
  PacketLineIn: Add an iterator over strings in the input stream
  Replace most usages of PacketLineIn.END with PacketLineIn.end()
  PacketLineIn: Deprecate DELIM constant
  Replace trivial reference comparison of PacketLineIn.{DELIM,END}
  PacketLineIn: Rename isDelim to isDelimiter
  ProtocolV2ParserTest: Fix typo in comment
  Upgrade Bouncy Castle to 1.61
  Update to Orbit R20190531194818 and rollback update to Ant 1.10.6
  cli: Add the --always option to describe
  DescribeCommand: Support the "always" option
  cli: Add the --tags option to describe
  DescribeCommand: Consistenly omit the default value
  Remove excess blank line in FileUtilsTest
  PacketLineIn: Add helper methods to check for END and DELIM
  UploadPackTest: Rename variable to avoid hiding class member
  UploadPackTest: Add missing <> operator on instantiation of ArrayList
  BitmapCalculator: javadoc fixes
  RevWalkUtils: add progress callback to findBranchesReachableFrom
  Upgrade maven-source-plugin to 3.1.0
  Upgrade maven-jar-plugin to 3.1.2
  Upgrade jacoco-maven-plugin to 0.8.4
  BitmapCalculator and its test: add missing license header
  RevWalk: new method createReachabilityChecker()

Change-Id: I4d76c7c0dbe6411c842f3468b709f7df51789c08
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-11 23:30:26 +02:00
Thomas Wolf 1cfcde4853 Handle missing "ours" stage in WorkingTreeIterator.hasCrLfInIndex()
In a delete-modify conflict with the deletion as "ours" there may be
no stage 2 in the index. Add appropriate null checks. Add a new test
for this case, and verify that the file gets added with a single LF
after conflict resolution with core.autocrlf=true. This matches the
behavior of canonical git for this case.

Bug: 547724
Change-Id: I1bafdb83d9b78bf85294c78325e818e72fae53bc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-06-11 14:42:46 +02:00
David Pursehouse fd8d779b5e Config: Add helper method to check for empty value
Rename MAGIC_EMPTY_VALUE to MISSING_ENTRY, make it private, and add
a helper method to check if a given string is that value.

This avoids that callers trigger the "reference equality" warning
from Error Prone.

Change-Id: Idc76f78c0cf1828aa48d02ee33911a4b5df50355
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-11 10:51:40 +09:00
David Pursehouse 518dc86380 FS_Win32: Add missing parentheses on if-blocks
Change-Id: I70504484f20aee103e51c852d71cd41b54093793
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-11 10:51:30 +09:00
David Pursehouse 4e8a3df68f Abbreviated{Long}ObjectId: Make operator precedence explicit
Change-Id: Iafd616d3fdc81ac3072f776061548be195270d85
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-11 10:37:18 +09:00
David Pursehouse 9c97a586bf GC: Update TODO comments
The TODO comments say "in 5.0", but 5.0 was already released without
resolving them. Remove "in 5.0" on the assumption that the mentioned
improvements still need to be done at some point.

Change-Id: I3eb429803e2266de3fc490e1f3912991c08aa1ad
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-11 10:37:18 +09:00
David Pursehouse e5217400de FS_POSIX: Fix reference comparison of Boolean.FALSE
Change-Id: Ic205d017b365ea85983d0b0d9d033fcf7e6bf6ab
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-11 09:22:17 +09:00
Michael Keppler e9abe09809 Retry loading config when locked by another process
When loading the config, a FileNotFoundException may occur if the file
exists but cannot be read (see [1]). This is the case on Windows with a
virus scanner checking the file. Therefore if the file exists and that
exception is thrown, retry multiple times, similar to how this was
already implemented for IOException.

[1] https://docs.oracle.com/javase/8/docs/api/java/io/FileNotFoundException.html

Bug: 529522
Change-Id: Ic5dc3b7b24bb0005d6256ed00513bc7c0b91e613
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-10 19:59:17 +02:00
Thomas Wolf 8a2e221096 Make pull --rebase on an unborn branch do a checkout
A merging pull on an unborn branch was already supported. But a
rebasing pull failed. If the user has pull.rebase = true in his
user config, the pull would try to rebase. Rebasing needs a parent
commit, though. Native git handles this case:

  git init
  git remote add origin <URI>
  git pull --rebase origin master

Check up front in PullCommand for the unborn head and just do a
checkout in this case. MergeCommand already has similar code.

Bug: 544965
Change-Id: I1277e1ac0b0364b4623fd791f3d6b07bd5f58fca
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-06-10 16:33:39 +02:00
Matthias Sohn 786380bd5e Warn if configured cookie file is missing
We logged a stack trace if the configured http.cookieFile was missing.
Instead only log a warning.

Bug: 548081
Change-Id: I42e39f5ad8ffce7b43162e5068f60af073b8a126
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-09 12:27:18 +02:00
Thomas Wolf f24ad3da66 Handle escaped CR-LF in git config files
Canonical git treats CR-LF in config files as LF.[1][2] JGit does so,
too, except when escaped as a line continuation. Correct this and
treat the sequence \-CR-LF as a line continuation.

[1] https://github.com/git/git/commit/db2c075d9
[2] https://github.com/git/git/blob/v2.21.0/config.c#L485

Bug: 545850
Change-Id: I51e7378a22c21b3baa3701163c423d04c900af5a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-08 01:43:22 +02:00
Thomas Wolf 10ab407fa6 DescribeCommand: use glob match instead of path match
Otherwise tags may fail to match if their name contains slashes.
Canonical git also uses its wildcard matcher in glob mode.[1]

[1] https://github.com/git/git/blob/v2.21.0/builtin/describe.c#L182

Bug: 546703
Change-Id: I122c7959974fa1fc6a53dfc65837e4314a8badd4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-06-07 17:19:07 +02:00
Thomas Wolf d2600693bd Fix off-by-one error in RebaseTodoFile when reading a todo file
Commit messages of length 1 were not read. 'lineEnd' is the offset
of the last character in the line before the terminating LF or CR-LF,
and 'nextSpace' is actually the offset of the character _after_ the
next space. With a one-character commit message, nextSpace == lineEnd.

The code also assumes the commit message to be optional, but actually
failed in that case because it read beyond the line ending. Fix that,
too.

Add a test case for reading a todo file.

Bug: 546245
Change-Id: I368d63615930ea2398a6230e756442fd88870654
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-06-07 16:19:31 +02:00
David Pursehouse 00f840dcd1 Consistently use "!isEmpty()" to detect non-empty list
Replace "size() > 0" with "!isEmpty()" where appropriate.

In the Status implementation we can drop the check; the subsequent
loop will only execute when the list is non-empty anyway.

Change-Id: I355aff551a603373e702a9d44304f087b476263c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-07 12:12:44 +09:00
David Pursehouse b5a1b770a0 TransportHttp: Check for non-empty list with "!isEmpty()" rather than "size() > 0"
Change-Id: Iabb627c8f584346eb8ace3c24afb63b4d1ad3d47
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-07 10:59:46 +09:00
David Pursehouse 9dc1ddf324 TransportHttp: Fix comparison of size with ">= 0"
Error Prone reports:

  [SizeGreaterThanOrEqualsZero] Comparison of a size >= 0 is always true,
  did you intend to check for non-emptiness?

  see https://errorprone.info/bugpattern/SizeGreaterThanOrEqualsZero

Change-Id: Ie964771cacca4b15569eb45f6e273ad2a7e2e49c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-07 10:57:15 +09:00
Thomas Wolf 1609ce7593 Determine hard-linking and nlink support per FileStore
It's quite possible that JGit can use the hard-linking mechanism
for atomic file creation on some volumes but not on others.
Ultimately it depends on the file systems on the mounted volumes.

Cache the information per FileStore instead of using a single
global flag. Also catch FileSystemException, it may be thrown
if the operating system reports a failure. The previously caught
AccessDeniedException is a sub-class of FileSystemException.

Bug: 547332
Change-Id: I1ef672b3468b0be79e71674344f16f28f9d11ba1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-06-06 19:06:09 +02:00
Konrad Windszus d7bd2e700c Support reading and writing cookies.
The git config entries "http.cookieFile" and
"http.saveCookies" are correctly evaluated.

Bug: 488572
Change-Id: Icfeeea95e1a5bac3fa4438849d4ac2306d7d5562
Signed-off-by: Konrad Windszus <konrad_w@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-06 19:02:17 +02:00
David Pursehouse 84c315b2a0 PackWriter: Make internal class static
When Error Prone checks are enabled, the "ClassCanBeStatic" warning is
triggered:

  Inner class is non-static but does not reference enclosing class
  see https://errorprone.info/bugpattern/ClassCanBeStatic

Change-Id: I5a0e3bf0cf8c28176d9c98914c1c0dfab9c5736f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-06 17:15:10 +02:00
Matthias Sohn d9c569b747 Merge branch 'stable-5.3' into stable-5.4
* stable-5.3:
  Prepare 5.3.3-SNAPSHOT builds
  JGit v5.3.2.201906051522-r
  Prepare 5.1.9-SNAPSHOT builds
  JGit v5.1.8.201906050907-r
  Test detecting modified packfiles
  Enhance fsTick() to use filesystem timer resolution
  Add debug trace to measure time needed to open pack index
  Extend FileSnapshot for packfiles to also use checksum to detect changes
  Wait opening new packfile until it can't be racy anymore
  Avoid null PackConfig in GC
  Add FileSnapshot test testing recognition of file size changes
  Capture reason for result of FileSnapshot#isModified
  Skip FileSnapshotTest#testSimulatePackfileReplacement on Windows
  Tune max heap size for tests
  Fix FileSnapshotTest.testNewFileNoWait() to match its javadoc
  ObjectDirectory: fix closing of obsolete packs
  Update API filters for methods added to fix bugs
  Bazel: Increase severity of most error-prone checks to ERROR
  Enable error-prone checks by default
  Add bazel options to align with gerrit's
  Include filekey file attribute when comparing FileSnapshots
  Measure file timestamp resolution used in FileSnapshot
  Fix FileSnapshot's consideration of file size
  Fix API problem filters
  Fix API problem filters

Change-Id: Ie1c7e4752661aec9e1754660934921224e2408eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-06 17:14:31 +02:00
Matthias Sohn fcfe1299c3 Prepare 5.3.3-SNAPSHOT builds
Change-Id: Idebf272835cb22c21257c88b414ada802629b665
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-05 23:35:14 +02:00
David Ostrovsky 8cd07cb815 Repository: Add getIdentifier() method to avoid instanceof operator
This change is needed to implement permission aware ref database in
Gerrit: [1], that is a pre-requisite to re-enable Git v2 protocol in
Gerrit: [2].

Background: Last year Git v2 protocol was enabled in Gerrit. The fact,
that JGit layer was not calling ref advertise filter for Git v2
protocol, introduced security vulnerability.

The lesson learned from this security incident: Gerrit should not rely
on ref advertise filter being called by JGit to implement crictical
security checks. Instead, the idea is to use the same approach as
currently used by Google's internal code on googlesource.com that
didn't suffer from this vulnerability: provide a custom repository to
JGit. The repository provides a RefDatabase that is permission-aware
and will only ever return refs that the user has access to.

However, due to hard coded instanceof operator usages in JGit code
base, some tests in Gerrit are failing with: [1] in place. This change
addresses this problem.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/212874
[2] https://gerrit-review.googlesource.com/c/gerrit/+/226754

Change-Id: I67c0f53ca33b149442e7ee3e51910d19e3f348d5
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-05 21:50:15 +02:00
Matthias Sohn d6c7c42a1b JGit v5.3.2.201906051522-r
Change-Id: I41b4926f4bfa896ef2a13c35e93e08071ae949a3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-05 21:23:13 +02:00
Matthias Sohn 60d65bbd22 Merge branch 'stable-5.2' into stable-5.3
* stable-5.2:
  Prepare 5.1.9-SNAPSHOT builds
  JGit v5.1.8.201906050907-r
  Test detecting modified packfiles
  Enhance fsTick() to use filesystem timer resolution
  Add debug trace to measure time needed to open pack index
  Extend FileSnapshot for packfiles to also use checksum to detect changes
  Wait opening new packfile until it can't be racy anymore
  Avoid null PackConfig in GC
  Add FileSnapshot test testing recognition of file size changes
  Capture reason for result of FileSnapshot#isModified
  Skip FileSnapshotTest#testSimulatePackfileReplacement on Windows
  Tune max heap size for tests
  Fix FileSnapshotTest.testNewFileNoWait() to match its javadoc
  ObjectDirectory: fix closing of obsolete packs
  Include filekey file attribute when comparing FileSnapshots
  Measure file timestamp resolution used in FileSnapshot
  Fix FileSnapshot's consideration of file size
  Fix API problem filters
  Fix API problem filters

Change-Id: Id79a3a19f9a31dff94d10a406c2b6e08a506931a
2019-06-05 21:18:47 +02:00
Matthias Sohn 4018709eb9 Merge branch 'stable-5.1' into stable-5.2
* stable-5.1:
  Prepare 5.1.9-SNAPSHOT builds
  JGit v5.1.8.201906050907-r
  Test detecting modified packfiles
  Enhance fsTick() to use filesystem timer resolution
  Add debug trace to measure time needed to open pack index
  Extend FileSnapshot for packfiles to also use checksum to detect changes
  Wait opening new packfile until it can't be racy anymore
  Avoid null PackConfig in GC
  Add FileSnapshot test testing recognition of file size changes
  Capture reason for result of FileSnapshot#isModified
  Skip FileSnapshotTest#testSimulatePackfileReplacement on Windows
  Tune max heap size for tests
  Fix FileSnapshotTest.testNewFileNoWait() to match its javadoc
  ObjectDirectory: fix closing of obsolete packs
  Include filekey file attribute when comparing FileSnapshots
  Measure file timestamp resolution used in FileSnapshot
  Fix FileSnapshot's consideration of file size
  Fix API problem filters

Change-Id: I3ac77bfa03f7436de12ab86e1bba29afee5ccd01
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-05 20:58:16 +02:00
Matthias Sohn 57ccca75e6 Prepare 5.1.9-SNAPSHOT builds
Change-Id: I60571e4e0bea04bb2c25ef3d0332a9ab6895db06
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-05 15:23:56 +02:00
Matthias Sohn 2fe587fcfd JGit v5.1.8.201906050907-r
Change-Id: Iae0ffe161df2ca8a800d21688d6b7d7419dfb640
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-05 15:06:56 +02:00
Matthias Sohn b5c594216b Add debug trace to measure time needed to open pack index
Change-Id: Ia698cc06aa3fe6cb7903a687db8885f1b83c3bf2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-04 18:15:17 +02:00
Matthias Sohn 9a7d3b053a Extend FileSnapshot for packfiles to also use checksum to detect changes
If the attributes of FileSnapshot don't detect modification of a
packfile read the packfile's checksum and compare it against the
checksum cached in the loaded packfile.

Since reading the checksum needs less IO than reloading the complete
packfile this may help to reduce the overhead to detect modficiation
when a gc completes while ObjectDirectory scans for packfiles in another
thread.

Bug: 546891
Change-Id: I9811b497eb11b8a85ae689081dc5d949ca8c4be5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-04 18:15:17 +02:00
Matthias Sohn 8bf9c668ad Wait opening new packfile until it can't be racy anymore
If
- pack.waitPreventRacyPack = true (default is false)
- packfile size > pack.minSizePreventRacyPack (default is 100 MB)
wait after a new packfile was written and before it is opened until it
cannot be racy anymore.

If a new packfile is accessed while it's still racy at least the pack's
index will be reread by ObjectDirectory.scanPacksImpl(). Hence it may
save resources to wait one tick of the file system timer to avoid this
reloading. On filesystems with a coarse timestamp resolution it may be
beneficial to skip this wait for small packfiles.

Bug: 546891
Change-Id: I0e8bf3d7677a025edd2e397dd2c9134ba59b1a18
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-04 18:15:17 +02:00
David Pursehouse e8ed59a2ac PacketLineIn: Deprecate the END constant
Deprecate the constant with the intention of making it private in
a future release.

All existing usage of the constant within JGit code has already been
replaced with the recommended alternatives in preceding commits.

Change-Id: I10eb95f3f92cb74f93a26bf1a6edd24615b75c6f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-03 08:07:24 +09:00
David Pursehouse ee747827b0 PacketLineIn: Add an iterator over strings in the input stream
Allows callers to read all lines in the input stream until the
END marker is reached, without having to explicitly check for
the END marker.

Replace all remaining usage of the END marker with the new method.

Change-Id: I51f419c7f569ab7ed01e1aaaf6b40ed8cdc2116b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-03 08:07:24 +09:00
David Pursehouse e0133b9440 Replace most usages of PacketLineIn.END with PacketLineIn.end()
PacketLineIn.END is only referenced in tests. Replace most of those
with a new package visible end() method.

Remaining usages of PacketLineIn.END are in the form:

  while ((line = pckIn.readString()) != PacketLineIn.END) {

and are not trivial replacements, hence are not touched in this change.

Change-Id: Id77c5321ddcad127130b246bde8f08736e60e1ea
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-03 08:07:24 +09:00
David Pursehouse e99aaa5f79 PacketLineIn: Deprecate DELIM constant
Deprecate DELIM with the intention of making it private in a future
release.

Callers that want to test if a packet line string is the delimiter
should use the isDelimiter(String) method.

The only other references to DELIM in the JGit code are in tests. For
those, introduce a package visible delimiter() method.

Change-Id: I21e8bbac0ffb9ef710c9753e23435416b09a4891
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-03 08:07:24 +09:00
David Pursehouse 7377b8dd01 Replace trivial reference comparison of PacketLineIn.{DELIM,END}
Replace reference comparisons of PacketLineIn's DELIM and END strings
with usage of the helper methods isDelimiter() and isEnd().

Change-Id: I52dcfc4ee9097f1bd6970601c716701847d9eebd
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-02 18:32:59 +09:00