Commit Graph

6525 Commits

Author SHA1 Message Date
Matthias Sohn dff99a272a Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Prepare 4.11.5-SNAPSHOT builds
  JGit v4.11.4.201810060650-r
  Fix configuration of maven-javadoc-plugin
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

* Fix todos in SubmoduleAddTest

Change-Id: I53272081094b8948a40a1ce409af08b6ef330c1e
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 16:56:12 +02:00
Matthias Sohn 23ebbe5662 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Prepare 4.11.5-SNAPSHOT builds
  JGit v4.11.4.201810060650-r
  Fix configuration of maven-javadoc-plugin
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

* Fix configuration of maven-javadoc-plugin for site generation

Change-Id: Ic6ff8d324867ee41f15a5b890c7eee5092e8453e
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 16:40:46 +02:00
Matthias Sohn 620370ab6a Prepare 4.11.5-SNAPSHOT builds
Change-Id: Ifbe76e14264e8b547930e2320e8e81d728bd6e38
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 14:17:48 +02:00
Matthias Sohn c2a866b109 JGit v4.11.4.201810060650-r
Change-Id: I5700ebd341b6b997a7757b17e7d731c4ce608ec2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 14:05:29 +02:00
Matthias Sohn 816bcd259e Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Fix configuration of maven-javadoc-plugin

Change-Id: I80db074c45e840f15e227a400ef637b85084e711
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 11:00:17 +02:00
Matthias Sohn f07e48cc10 Fix configuration of maven-javadoc-plugin
Since maven-javadoc-plugin additionalJOption replaces additionalparam to
pass additional options to JavaDoc.

See https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html#additionalJOption

Change-Id: Iddff5873520a181bcb9edf285b0c8db532e930ee
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 10:55:47 +02:00
Matthias Sohn f016e32471 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Ibd759f5d425f714e79b3137ff8e5b0f989933de0
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 02:26:05 +02:00
Matthias Sohn c0a973657f Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Ie59e34eb591a827d1ce8e483eec6d390a3c81702
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:52:38 +02:00
Matthias Sohn bf7a611dac Prepare 4.9.7-SNAPSHOT builds
Change-Id: I20e7bd6bdebcdb55a8c771314759bd8f98f04ef6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:32:40 +02:00
Matthias Sohn 73e6a93ba2 JGit v4.9.6.201810051924-r
Change-Id: Ib39aaae26da17aa37d654b24c1defd45126f4ea2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:24:42 +02:00
Matthias Sohn 7d94b446fe Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Ia7a826399d8d5b8a0eb7169b40e98a6f5c207a4c
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:16:08 +02:00
Matthias Sohn a8bd7dcc58 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Id6fabec4d0b682a7e20a46e88cbc05432efca062
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:03:20 +02:00
Matthias Sohn 4a68f1a3c7 Prepare 4.7.6-SNAPSHOT builds
Change-Id: I99b59116999742d8d6cdba26287ea7c6eba11a30
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 00:36:30 +02:00
Matthias Sohn 9c90816cd9 JGit v4.7.5.201810051826-r
Change-Id: I60c7a2eff3dab5083f71df0d9465a4e94b5e2513
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 00:27:38 +02:00
Ivan Frade e4c28665b6 BaseReceivePack: Validate incoming .gitmodules files
The main concern are submodule urls starting with '-' that could pass as
options to an unguarded tool.

Pass through the parser the ids of blobs identified as .gitmodules
files in the ObjectChecker. Load the blobs and parse/validate them
in SubmoduleValidator.

Change-Id: Ia0cc32ce020d288f995bf7bc68041fda36be1963
Signed-off-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-05 23:49:00 +02:00
Ivan Frade 3ed3eafbd1 ObjectChecker: Report .gitmodules files found in the pack
In order to validate .gitmodules files, we first need to find them
in the incoming pack.

Do it in the ObjectChecker stage. Check in the tree objects if they
point to a .gitmodules file and report the tree id and the .gitmodules
blob id.

This can be used later to check if the file is in the root of the
project and if the contents are good.

While we're here, make isMacHFSGit more accurate by detecting variants
of filenames that vary in case.

[jn: tweaked NTFS and HFS+ checking; added more tests]

Change-Id: I70802e7d2c1374116149de4f89836b9498f39582
Signed-off-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-05 21:45:54 +02:00
Ivan Frade db9f7b028d SubmoduleAddCommand: Reject submodule URIs that look like cli options
In C git versions before 2.19.1, the submodule is fetched by running
"git clone <uri> <path>". A URI starting with "-" would be interpreted
as an option, causing security problems. See CVE-2018-17456.

Refuse to add submodules with URIs, names or paths starting with "-",
that could be confused with command line arguments.

[jn: backported to JGit 4.7.y, bringing portions of Masaya Suzuki's
 dotdot check code in v5.1.0.201808281540-m3~57 (Add API to specify
 the submodule name, 2018-07-12) along for the ride]

Change-Id: I2607c3acc480b75ab2b13386fe2cac435839f017
Signed-off-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-05 21:38:22 +02:00
Matthias Sohn 9dbb18291f Revert "Configure WindowCache settings to use in JGit CLI"
This reverts commit e6375445d1.

Hard coding WindowCache settings wasn't a good idea, this prevents that
custom settings can be configured. Also using virtual memory mapping has
issues on Windows.

Bug: 539789
Change-Id: I37434581f9e3db2f1d7442d893f0dda0c2488d93
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-05 11:09:27 +02:00
Thomas Wolf 569cf1856c Fix handling of core.eol=native and of crlf attribute
EolStreamTypeUtil didn't handle these correctly on Windows.

Add three new tests to verify that the crlf attribute is handled as
described at [1], and that core.eol=native produces the expected
line endings on check-out.

[1] https://git-scm.com/docs/gitattributes

Bug: 497290
Change-Id: Idd9b435e3256c1e3251cc7b966f2f0460e787f07
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-04 19:17:41 -04:00
Matthias Sohn abe43a5841 Silence API warning for method added to interface DepthWalk
Breaking implementers is ok in a minor version update following OSGi
semantic versioning. According to [1] adding a default method is ok if
risk of inheriting a method with the same name from multiple interfaces
is low.

[1] https://wiki.eclipse.org/Evolving_Java-based_APIs_2#Evolving_API_Interfaces

Change-Id: Iad354cb73cfff9a96b9a9852a3c4d9ba0c5df430
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-04 23:02:02 +02:00
Jonathan Nieder c33e392f9b pgm: Add missing dependency on commons-logging
Without this, commands like "jgit repo" that use commons-logging fail.

Change-Id: Ia78198c5e15ac4d6152d832ab2a2498f625486d2
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-01 18:25:22 -04:00
David Pursehouse 65d6bb073a Override int read(byte[], int, int) on test instances of InputStream
This probably doesn't provide any benefit for the tests, but gets
rid of a warning from Error Prone.

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

Change-Id: I584d2e0d18475fad38747b688af6301c423f54a7
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-01 11:19:04 +09:00
David Pursehouse 731d638f69 LfsFactory#LfsInputStream: Override int read(byte[], int, int)
According to Error Prone, the class should also override:

  int read(byte[], int, int)

otherwise multi-byte reads from this input stream are likely to be slow.

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

Change-Id: I33ab8cd30013447f2a0363b3a7b1424b79cb1818
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-01 11:16:05 +09:00
Jonathan Nieder 1f4ab45166 MergeFormatterPass: Remove constructor taking charset name as string
Since this constructor is package-private, so instead of deprecating
it, we can remove it right away.

Change-Id: I84ba72e8c94fb09412bbf7ce73b7eec72f61e964
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-09-30 17:08:32 -07:00
David Pursehouse 7d19b18c7d TextBuiltin#init: Factor out a method to get the log output encoding
Change-Id: I87c5774722bd36ea6fe18c4b7ce22342578fa290
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 17:19:39 +09:00
David Pursehouse a5c0a8dfa5 ConfigConstants: Add constants for i18n.logOutputEncoding
Change-Id: I6073c7fc8ec30840e2ee2e90ac4cfdb136f48b9a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 17:14:50 +09:00
David Pursehouse d54fc955be Bazel: Increase severity of DefaultCharset to ERROR
All existing instances of this issue have been fixed in preceding
commits. Increase its severity to ERROR so that it is easier to
detect reoccurences.

Change-Id: I50f95152857baac5ca44c15493f23b6f9cfac1bf
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 17:02:11 +09:00
David Pursehouse a97e79d95d Explicitly specify charset when constructing PrintWriter
Change-Id: Ie1631784b5eba04edb21f66df284f9e279fd2ec0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 16:59:34 +09:00
David Pursehouse 4316e1c3a9 TextBuiltin: Default to UTF-8 when i18n.logOutputEncoding is not set
Change-Id: I69d82086c052b7ba601e0daab133573ec37c25cf
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 16:04:25 +09:00
David Pursehouse 74789e7786 SidebandInputStream: Specify charset when calling String.getBytes()
Change-Id: I96c3f6b2ef3db9619bb3ae46dfbf8bcff3c1cbca
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
David Pursehouse b65a310abc MergeFormatter{Pass}: Use Charset instead of String
Deprecate constructors and methods taking a character set name as
a String, in favor of new variants taking a Charset.

Change-Id: I616c601daf232fa17610dba1087fd902030d46ea
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
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