Commit Graph

6292 Commits

Author SHA1 Message Date
David Pursehouse fbf6ce65ba Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8
Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
David Pursehouse f5d7f93b52 Bazel: Increase severity of MissingFail to ERROR
All instances of this potential bug have been cleaned up in
preceding commits. Increase the severity to ERROR so that it
is easier to detect reoccurences.

Change-Id: I25beebcea1f01f468e0f2b1d24a83511029c077c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
David Pursehouse 981e403e59 TestProtocolTest: Add missing calls to fail()
Error Prone reports:

  Not calling fail() when expecting an exception masks bugs

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

Change-Id: I58ad45a87dcf7d646dce056d20776d62faafbfef
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
David Pursehouse 0b292b9085 BlockListTest: Add missing calls to fail()
Error Prone reports:

  Not calling fail() when expecting an exception masks bugs

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

Change-Id: I518b524de7cd3802f03b80450cad02ab3f79d57b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-29 13:16:58 +09:00
David Pursehouse 302717c30b DirCacheBuilderTest#testBuildRejectsUnsetFileMode: Add missing fail()
Error Prone reports:

  Not calling fail() when expecting an exception masks bugs

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

Change-Id: Ic89f9daef3c31bfbfd1f3c003cb90a373cd74847
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-29 13:02:26 +09:00
David Pursehouse f02844caae DirCacheCheckoutTest#testCheckoutHierarchy: Add missing call to fail()
Error Prone reports:

  Not calling fail() when expecting an exception masks bugs

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

Change-Id: I463510342bb6e6b99b31a0fe264d953340784393
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-29 12:59:03 +09:00
David Pursehouse 00698f9e27 ConfigTest: Fix tests for getting empty config value as int
The tests were set up to expect an IllegalArgumentException when
the Config.getInt method was called with a section.key that has
not been set, or explicitly set to an empty string.

However, the IllegalArgumentException never gets thrown because
the getInt method returns the provided default ("1"), and because
there was no call to "fail" after getInt, the incorrect behavior
of the test was not noticed.

Remove the try/catch around getInt, and instead assert that the
expected default value is returned.

Found by Error Prone, which reported:

  Not calling fail() when expecting an exception masks bugs

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

Change-Id: Ie8e692aba9fb8523241fb8f298d57493923d9f78
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-29 12:54:37 +09:00
David Pursehouse 873b0b7754 FileResolverTest#testNotAGitRepository: Fail when exception is not thrown
Error Prone reports:

  Not calling fail() when expecting an exception masks bugs

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

Change-Id: I9ac844aa6c5a620d9b5d21d2e242347b3788b96a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-29 12:47:01 +09:00
Jonathan Tan 1bb430dc21 UploadPack: support deepen-since in protocol v2
Support the deepen-since parameter when requested by a client using
protocol v2. This is done by:
 - adding a DepthWalk.RevWalk#setDeepenSince method
 - updating DepthGenerator to recognize when deepen-since is set
 - recording in DepthWalk.Commit whether a commit is a boundary commit

Existing users of DepthWalk such as UploadPack previously recognized
boundary commits by comparing their depths against the threshold, not
tracking whether any parents were truly excluded. This behavior is
preserved - UploadPack considers a commit as boundary if its depth is
equal to the threshold *or* a parent was excluded (whether by depth or
by deepen-since).

Change-Id: I852bba6b1279f9cc8aee38282e9339d62b8dcddc
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2018-09-27 14:43:05 -07:00
Jonathan Tan 953cf2c9da DepthGenerator: remove redundant depth check
In DepthGenerator, commits are always added to the "pending" queue
either at depth 0 (in the constructor) or after a depth check (in
next()), so it is redundant to check for depth after removing them from
the queue. Remove the check.

This redundancy seems to have been present since the introduction of
server-side shallow clone support in commit 9952223e06 ("Implement
server support for shallow clones", 2011-08-21).

Change-Id: Iad334935293367400c2901a25c0f4bf36c437cf2
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2018-09-27 14:35:29 -07:00
David Pursehouse b2ee02f53b FileRepositoryBuilderTest: Don't explicitly close BufferedWriter in try-with-resource
The BufferedWriter is opened in a try-with-resource and thus will be
automatically closed.

Presumably the close was added to make sure it is closed before the
subsequent test statements are executed. Instead of explicitly closing
it, let the try-with-resource automatically close it, and move the
subsequent statements out of the try-block.

Change-Id: If5fada2f580ef9cbaad3a0b9216b5200b917781a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-27 18:01:03 +09:00
David Pursehouse fa61fd6f61 Explicitly specify charset when constructing FileWriter
Replace explicit construction of FileWriter with calls to the
utility method Files.newBufferedWriter, which allows to specify
the charset.

Also convert to try-with-resource.

Change-Id: I9fa3f612b9b2fc5ac12cd79d6e61ca181120dbf5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 13:33:32 +09:00
David Pursehouse 62012d0bdd Explicitly specify charset when constructing BufferedReader
Replace explicit construction of BufferedReader with calls to the
utility method Files.newBufferedReader, which allows to specify
the charset.

Change-Id: I61b9451dbc8d9cf83fc8a5981292b8fdc713ce37
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 13:33:24 +09:00
David Pursehouse dbabe5f37a Explicitly specify charset in constructor of InputStreamReader
Change-Id: Id43e27c590f41f7435c2ca1d127f27e45745da7f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:31:13 +09:00
David Pursehouse 2f1350c9ac Explicitly specify charset when calling getBytes
Change-Id: Ie492406005be56ccaf4dfb385ae376636404816d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:31:13 +09:00
David Pursehouse a7d3fa3064 Explicitly specify charset in constructor of String
Change-Id: Ie9a9f917503019e7fa51ccbc11a5a3518b74434b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:31:13 +09:00
David Pursehouse ee40efcea4 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>
2018-09-26 08:31:13 +09:00
David Pursehouse 1f14c16ae4 Bazel: Increase severity of ExpectedExceptionChecker to ERROR
Incorrect usage of ExpectedException has been cleaned up in the
preceding commits. Increase the severity from WARN to ERROR so
that it is easier to catch any reoccurences.

Change-Id: I57decf620b37e85413bda53723f839c02b488f2c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:31:13 +09:00
David Pursehouse 6397e220a3 Merge branch 'stable-5.1'
* stable-5.1:
  ObjectDownloadListener#onWritePossible: Add comment on return statement

Change-Id: Ie0b2b4aa4e5629d57b8104b64298d33de76abd82
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:30:49 +09:00
David Pursehouse 41b1a71cf3 Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  ObjectDownloadListener#onWritePossible: Add comment on return statement

Change-Id: Ie7cb0c8a9775626cf2a2daae04b2d1f73a6c5af7
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:19:32 +09:00
David Pursehouse 7893fcb0b4 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  ObjectDownloadListener#onWritePossible: Add comment on return statement

Change-Id: Icacfa8dcd1ced32715fb772c336574318f28ddd1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:18:54 +09:00
David Pursehouse 6b82c9ff7f Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  ObjectDownloadListener#onWritePossible: Add comment on return statement

Change-Id: I2ab21595531bcd487ce6a5cb0a3bc3c6f6f6e518
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:18:27 +09:00
David Pursehouse 8ee64116b8 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  ObjectDownloadListener#onWritePossible: Add comment on return statement

Change-Id: I3dff04d2ea99e5b6331e45e3ea2ccc78fb2d5a02
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:17:59 +09:00
David Pursehouse ffdaa0ff8f Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  ObjectDownloadListener#onWritePossible: Add comment on return statement

Change-Id: Ie3de769209ec8477c97df5f90b8c63c03e023be0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:17:30 +09:00
David Pursehouse 33c9906886 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  ObjectDownloadListener#onWritePossible: Add comment on return statement

Change-Id: Id0833112b0be4e78af375ee1fc78287743d7bc4c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:16:53 +09:00
Matthias Sohn 9c71cda06f Update .mailmap
The .mailmap file is used to map author and committer names and
email addresses to canonical real names and email addresses.
See https://git-scm.com/docs/git-check-mailmap

Change-Id: I720326ad204bd0737e8ace2620ccbd1347114ef4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-25 19:03:22 -04:00
Matthias Sohn 6a2be5c12c Fix @since tag on RefDatabase#getRefsByPrefix
Change-Id: Ic1615e680a131ef178c62c4ea92d2b389a0afd2b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-25 21:58:05 +02:00
David Ostrovsky e5a4c0d17e ObjectDownloadListener#onWritePossible: Add comment on return statement
It is not obvious why this return statement is needed. Clarify with a
comment that otherwise endless loop may show up when recent versions
of Jetty are used.

Change-Id: I8e5d4de51869fb1179bf599bfb81bcd7d745874b
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2018-09-25 03:31:41 -05:00
David Pursehouse 6690a3d191 T0003_BasicTest: Fix incorrect usage of ExpectedException
There should only be one statement after the expect(...) method.

Any additional statements after the statement that is expected to
throw will never be executed in a passing test. This can lead to
inappropriately passing tests where later incorrect assertions are
skipped by the thrown exception.

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

Change-Id: I20fecf8fb7a243e9da097e6d03fbf8cd69151bf0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-25 11:57:26 +09:00
David Pursehouse 0717639485 ProtocolV2ParserTest: Fix incorrect usage of ExpectedException
There should only be one statement after the expect(...) method.

Any additional statements after the statement that is expected to
throw will never be executed in a passing test. This can lead to
inappropriately passing tests where later incorrect assertions are
skipped by the thrown exception.

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

Change-Id: I0d6350fafb281b6bdb04289f4cd5eb4bb159628b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-25 10:42:03 +09:00
Minh Thai c0f89747b6 Using getRefsByPrefix with multiple prefixes
Change-Id: I9901e733797bd661f2485cc42914ad01699617d3
Signed-off-by: Minh Thai <mthai@google.com>
2018-09-24 15:18:58 -07:00
Minh Thai a51e686e47 Query references by multiple prefixes
Support multiple prefixes when querying references to allow
implementor to minimize number of RPC calls.

Change-Id: I5f822fd7eaf9756b44750080d3056de138b64f4a
Signed-off-by: Minh Thai <mthai@google.com>
2018-09-24 15:17:48 -07:00
Michael Keppler 751abf4a50 Fix Mylyn commit message template
The commit message template contains a superfluous blank at the end of
the first line, which is deleted by this change. This is only relevant
for jgit contributors using Eclipse, not for jgit users.

Change-Id: I462deb49c26fb64b3dc2d1d75f1e40ef302b0fc9
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-09-23 04:11:58 -04:00
David Ostrovsky 7d89f0a053 Bazel: Provide toolchain with activated error prone warnings
On recent bazel versions it's trivial to apply package specific checks.
Provide custom java toolchain with all error prone warnings activated.

The list of all error prone warnings was borrowed from here: [1].

Test Plan:

  $ bazel build --java_toolchain //tools:error_prone_warnings_toolchain \
    //...

[1] https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl

Change-Id: I207a368555bfb7ddab8d782d46d563ce779a6211
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-22 19:12:59 +09:00
Marc Strapetz cbc65bd659 Config.set-methods should not touch lines from included files
Bug: 538270
Change-Id: I4128213e83e267eb2667f451b8fb3301dd251656
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-09-20 17:05:40 +02:00
Marc Strapetz f5614d471d Don't inline included configs on FileBasedConfig.save()
Bug: 529825
Change-Id: Id23d4602aa2082d7f2dfe15ae92d7b175b1b8944
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-09-20 17:05:39 +02:00
Marc Strapetz 31abb329b4 ConfigLine.includedFrom stores source, if it was read from included file
This is a base change which prepares for subsequent bugfixes.

Change-Id: Iaadc93df37e45753d700be73669e68c03590adb5
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-09-20 17:05:39 +02:00
Matthias Sohn 4741b072bd Merge branch 'stable-5.1'
* stable-5.1:
  Prepare 5.1.2-SNAPSHOT builds
  JGit v5.1.1.201809181055-r
  Prepare 4.11.4-SNAPSHOT builds
  JGit v4.11.3.201809181037-r
  Prepare 4.9.6-SNAPSHOT builds
  JGit v4.9.5.201809180939-r
  Prepare 4.7.5-SNAPSHOT builds
  JGit v4.7.4.201809180905-r
  Update API problem filter

Change-Id: I50466bd95ac88a5a8f03ef52d9a59be46b13f81e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 17:46:35 +02:00
Matthias Sohn 48e21dc10b Prepare 5.1.2-SNAPSHOT builds
Change-Id: I095d246e27de747a234bc058725454c222be51ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 17:03:49 +02:00
Matthias Sohn b06d2e6a31 JGit v5.1.1.201809181055-r
Change-Id: I2366444fca125139eadb6d513be721167a266d70
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:55:20 +02:00
Matthias Sohn b1ac54034f Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Prepare 4.11.4-SNAPSHOT builds
  JGit v4.11.3.201809181037-r
  Prepare 4.9.6-SNAPSHOT builds
  JGit v4.9.5.201809180939-r
  Prepare 4.7.5-SNAPSHOT builds
  JGit v4.7.4.201809180905-r
  Update API problem filter

Change-Id: I2ee1da73b4eb26f0017dd13a983aca62d4161c61
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:53:01 +02:00
Matthias Sohn a59bf16843 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Prepare 4.11.4-SNAPSHOT builds
  JGit v4.11.3.201809181037-r
  Prepare 4.9.6-SNAPSHOT builds
  JGit v4.9.5.201809180939-r
  Prepare 4.7.5-SNAPSHOT builds
  JGit v4.7.4.201809180905-r
  Update API problem filter

Change-Id: I3f43af45a4c9023f0e8638fa1920db5d69276502
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:50:51 +02:00
Matthias Sohn 35255a2a29 Prepare 4.11.4-SNAPSHOT builds
Change-Id: Id2f83eb3b2070637997cfece59f4f15698267908
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:46:18 +02:00
Matthias Sohn 47ad1f6c8a JGit v4.11.3.201809181037-r
Change-Id: I6b57b02e41f02916127b1866d573a634d6f6d796
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:36:53 +02:00
Matthias Sohn 969af66800 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Prepare 4.9.6-SNAPSHOT builds
  JGit v4.9.5.201809180939-r
  Prepare 4.7.5-SNAPSHOT builds
  JGit v4.7.4.201809180905-r
  Update API problem filter

Change-Id: I6633f1e147444385c999a6ff1d443b8a07d08bfc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:06:39 +02:00
Matthias Sohn 3d7476b1b3 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Prepare 4.7.5-SNAPSHOT builds
  JGit v4.7.4.201809180905-r
  Update API problem filter

Change-Id: I19b9be956b4e9bb1bba303ad879baac250988e8e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:02:22 +02:00
Matthias Sohn 430ff2187c Prepare 4.9.6-SNAPSHOT builds
Change-Id: I9fb8f6cc45409e0884b898187323ac91953754c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:55:12 +02:00
Matthias Sohn 0bd9cb62cc JGit v4.9.5.201809180939-r
Change-Id: I36199607f3ec6e8bb841e9d9eade12251312447c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:44:16 +02:00
Matthias Sohn 78d90902e8 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Prepare 4.7.5-SNAPSHOT builds
  JGit v4.7.4.201809180905-r
  Update API problem filter

Change-Id: Ic353f93864ca4aec315f398f5c3e047dcda23125
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:33:11 +02:00
Matthias Sohn e4dd83a120 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Prepare 4.7.5-SNAPSHOT builds
  JGit v4.7.4.201809180905-r
  Update API problem filter

Change-Id: I9a9abcd2e48e19295d537241c951308cd0210019
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:20:57 +02:00