Commit Graph

2199 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 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
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
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 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 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
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
Thomas Wolf 50deacdd57 Set TagOpt.AUTO_FOLLOW when not cloning all branches
Otherwise fetching all tags may pull in commits not on the
specified branches. Canonical git also does this.[1]

[1] https://github.com/git/git/blob/b160b6e69/builtin/clone.c#L1124

Bug: 538768
Change-Id: If0ac75fb9fae0c95d1a48b22954c54d4c3c09a47
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-09-15 00:57:13 +02:00
Thomas Wolf 54a502f6c6 Fix fetch refspecs when not cloning all branches
When not all branches are cloned, the fetch refspec for the
remote should not be "+refs/heads/*:refs/remotes/origin/*":
that would fetch all branches on the very next fetch, thus
making a clone with only a subset of the branches rather
pointless.

Instead, produce refspecs for the cloned branches only.

Canonical git also does this for its --single-branch case;
it doesn't have an option to clone only a subset of the branches
(only one or all).

Bug: 466858
Change-Id: Ie871880f757663437efac1e8b3313094f9e629b3
Also-by: Julian Enoch <julian.enoch@ericsson.com>
Signed-off-by: Julian Enoch <julian.enoch@ericsson.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-15 00:57:13 +02:00
Ivan Frade cb4de02e5e Move ls-refs parsing code to the ProtocolV2Parser
Fetch code has been moved to a ProtocolV2Parser, but ls-refs code is
still in UploadPack.

Moving it to the parser makes it easier to test, keeps the parsing
together and makes the two commands follow similar structure.

Change-Id: I573ce543e804ddeb9f83303b4af250b7cddc8cad
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-09-14 08:52:23 -07:00
Matthias Sohn 2fae326aa9 Prepare 5.2.0-SNAPSHOT builds
Change-Id: If8e8ca20e745901a5e0239c16cb4acc7934b4ec8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-06 09:36:00 +02:00
René Scheibe d80a01e6a0 Extend ResetCommandTest
Also check that reflog is enabled by default.
Also check that a file in a folder is reset correctly.

Change-Id: I4bc6649928ce10d7b558901e465e8032b083ade0
Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
2018-09-05 15:32:11 -04:00
David Pursehouse 2173f44158 UploadPackTest: Avoid unnecessarily boxing int into Integer
The statement:

  assertThat(recvStream.available(), is(0));

results in a warning from Eclipse:

  The expression of type int is boxed into Integer

because recvStream.available() returns int, but the hamcrest is()
method takes an Integer.

Replace it with the equivalent JUnit assertion.

Also remove the suppression of another similar warning and fix that
in the same way.

Change-Id: I6f18b304a540bcd0a10aec7d3abc7dc6f047fe80
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-05 08:39:32 +09:00
David Turner 559c68cb01 Parse signature of GPG-signed commits
In order to support GPG-signed commits, add some methods which will
allow GPG signatures to be parsed out of RevCommit objects.

Later, we can add code to verify the signatures.

Change-Id: Ifcf6b3ac79115c15d3ec4b4eaed07315534d09ac
Signed-off-by: David Turner <dturner@twosigma.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-04 20:13:16 +02:00
David Pursehouse 30c6c75421 Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8
Change-Id: I3b748620f067582afef20f144feebe40d0332be2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-04 10:53:10 +09:00
René Scheibe 685f8c8dbe Simplify file creation in ResetCommandTest
Use existing test utility methods instead of nested PrintWriter usage.

Change-Id: I324852c7971ae644fa499f377a31d1cf265c7fd9
Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
2018-09-03 23:21:10 +02:00
David Pursehouse a3cb474c94 Specify charset when constructing InputStreamReader
ErrorProne warns [1] about implicit use of the platform default charset,
which can result in differing behaviour between JVM executions or
incorrect behavior if the encoding of the data source doesn't match
expectations.

[1] http://errorprone.info/bugpattern/DefaultCharset

Change-Id: I0fd489d352170339c3867355cd24324dfdbd4b59
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-02 01:44:36 -05:00
Jonathan Nieder ce38391e09 Merge "Replace useminimalnegotation flag with maxhaves flag" 2018-08-31 20:02:51 -04:00
Minh Thai c398fb2b6b Replace useminimalnegotation flag with maxhaves flag
Client will stop sending haves when the number of haves sent reaches maxhaves.

Change-Id: I1e5b1525be4c67f20a81ca24a2770c20eb5c1271
Signed-off-by: Minh Thai <mthai@google.com>
2018-08-31 16:43:46 -07:00
Ivan Frade a8c38bc767 Extract protocol v2 fetch request parsing to its own class
The parsing code for protocol v2 fetch doesn't have any dependency on
the rest of UploadPack.

Move it to its own class. This makes testing easier (no need to
instantiate the full UploadPack), simplifies the code in UploadPack and
increases modularity.

At the moment, the parser needs to know about the reference database to
validate incoming references. This dependency could be easily removed
moving the validation later in the flow, after the parsing, where other
validations are already happening. Postponing that to keep this patch
about moving unmodified code around.

Change-Id: I7ad29a6b99caa7c12c06f5a7f30ab6a5f6e44dc7
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-08-31 15:31:36 -07:00
David Pursehouse 6196eb6825 Merge branch 'stable-5.1'
* stable-5.1:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: Ie9d77a7716591246b87fb59ac85214417fe8309d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 16:55:21 +09:00
David Pursehouse b6f3bdefce Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I7c2fc7d694d7d891cac96cb805c89c8bdf7c5cbf
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 16:11:37 +09:00
David Pursehouse 0718d22cf4 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I5ebb1058927ea5a478eae9e44b7d96f123a22523
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 15:45:42 +09:00
David Pursehouse b67aacda2f Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I500dd4e63302abb19ad669988b3a427cef8ef3d4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 15:21:10 +09:00
David Pursehouse c4c7770d04 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I37e936de0c06d4b9f17724ac4f1feb83f6c15ae3
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 13:58:15 +09:00
David Pursehouse a074203fa9 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I17436237cd66ca1c2800ad5ab0142f4a2bc07328
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 13:14:28 +09:00
David Pursehouse b270e4b740 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I414ade902dc38b696c566dd604000e3d289f3973
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 09:25:43 +09:00
Ivan Frade e665e3fcd4 UploadPack: avoid conflating shallow commit lists in protocol v2
At the moment there are two copies of the client shallow commit list:
one in the request and another in the clientShallowCommits member of
the class.

The verifyShallowCommit function was removing missing object ids
from the member but not the request list, and code afterwards was
using the request's version.

In practice, this didn't cause trouble because these shallow commits
are used as endpoint for a walk, and missing ids are just never reached.

Change-Id: I70a8f1fd46de135da09f16e5d954693c8438ffcb
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-08-30 13:09:50 -07:00
David Pursehouse 487571e604 Bazel: Format all build files with buildifier 0.15.0
Change-Id: I8343b723da6e40d5ae7fc45c84f64c31276bd5dc
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-30 15:27:20 +09:00
David Pursehouse ee56e5fc04 ChangeIdUtilTest: Remove unused notestCommitDashV
This test was never being run. Since it was introduced it was
named "notest.." which meant it didn't run with JUnit3, and
since it is not annotated @Test it also doesn't run with JUnit4.

When compiling with Bazel 0.6.0, error-prone raises an error
that the public method is not annotated with @Ignore or @Test.

Given that the test has never been run anyway, we can just
remove it.

Bug: 525415
Change-Id: Ie9a54f89fe42e0c201f547ff54ff1d419ce37864
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-30 15:25:38 +09:00
Matthias Sohn a6d641a03b Prepare 5.1.0-SNAPSHOT builds
Change-Id: If57fcce14f5ba3ef2a2602515e2f89b8f22a742b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-29 13:51:08 +02:00
Matthias Sohn a7ad89e974 JGit v5.1.0.201808281540-m3
Change-Id: Ie86c46a828b55a2235056b9a5bc2c6c450b95ed0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-28 21:41:37 +02:00
Christian Halstrick 074168f2de Merge "Cleanup existing tests" 2018-08-27 07:16:58 -04:00
Matthias Sohn 851f239951 Merge branch 'stable-5.0'
* stable-5.0:
  Silence API warning for new ObjectIdSerializer introduced in 4.11.1
  Ignore API warnings
  Fix photon target platform to use photon version of org.eclipse.osgi
  Update Photon orbit repository to R20180606145124
  Suppress warning for trying to delete non-empty directory
  Fix fetching with duplicate ref updates
  Fetch(Process): should tolerate duplicate refspecs
  FetchCommandTest: test add/update/delete fetch

Change-Id: I9e7fa37b100a7ea3cbe4104802d36c6f38df9e08
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-25 16:14:22 +02:00
Matthias Sohn cde0e31381 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Silence API warning for new ObjectIdSerializer introduced in 4.11.1
  Ignore API warnings
  Fix photon target platform to use photon version of org.eclipse.osgi
  Update Photon orbit repository to R20180606145124
  Suppress warning for trying to delete non-empty directory
  Fix fetching with duplicate ref updates
  Fetch(Process): should tolerate duplicate refspecs
  FetchCommandTest: test add/update/delete fetch

Change-Id: I2497f99b7d0686a0e0f773c39c8725e813ce9d4a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-25 08:56:45 +02:00
Matthias Sohn 6670ff1663 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Ignore API warnings
  Fix photon target platform to use photon version of org.eclipse.osgi
  Update Photon orbit repository to R20180606145124
  Suppress warning for trying to delete non-empty directory
  Fix fetching with duplicate ref updates
  Fetch(Process): should tolerate duplicate refspecs
  FetchCommandTest: test add/update/delete fetch

Change-Id: I47671108574fcd10fe016a58e38c038af54a6748
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-25 07:55:55 +02:00
René Scheibe dbe01e8852 Cleanup existing tests
Renamed and restructured tests for improved clarity.

Bug: 479266
Change-Id: Ic9d05ddf722bddd148fa9d9c19248dd53d97f1e4
Signed-off-by: René Scheibe <rene.scheibe@gmail.com>
2018-08-24 22:39:07 +02:00