Commit Graph

6487 Commits

Author SHA1 Message Date
Ivan Frade 7d7b8dec56 Move protocol v0/v1 parsing to its own class and request objects
Protocol v0/v1 parsing code doesn't have any real dependency on UploadPack.

Move it to its class and use a request object to read the data in
UploadPack.

This makes the code easier to test, keeps similar structure than protocol v2,
reduces the line count of UploadPack and paves the way to remove the
members as implicit parameters in it.

Change-Id: I8188da8bd77e90230a7e37c02d800ea18463694f
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-15 16:27:55 -07:00
Han-Wen Nienhuys 8a5b044a99 InternalPushConnection: don't swallow RuntimeException
Uncaught exceptions are handled by java.lang.Thread's handler, which
prints it to stderr.

This is useful because InternalPushConnection is used in tests, and
during development, the server side may have programming errors that
manifest as RuntimeExceptions.

Before this change, all types of failures would lead to a uniform
failure message "test://test/conn0: push not permitted" on the client.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I0983cbeb86d36fa7a9313373f5fce54971f804ec
2018-10-15 16:45:19 +02:00
Matthias Sohn 89388d67f8 Fix file handle leak in ObjectDownloadListener.onWritePossible
5c134f4d removed closing the input stream when we reached end of the
stream. This caused file handle leaks.

Bug: 540049
Change-Id: I48082b537077c7471fc160f59aa04deb99687d9b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-13 19:46:38 -04:00
David Pursehouse 33744a2dfe Merge branch 'stable-4.6' into stable-4.7
* stable-4.6:
  Replace Findbugs with Spotbugs in org.eclipse.jgit/pom.xml
  Replace FindBugs with SpotBugs

Change-Id: I24417e4ebbba31f7ff6896d585ef807327411392
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-13 09:18:03 +09:00
David Pursehouse 27f7a590d1 Merge branch 'stable-4.5' into stable-4.6
* stable-4.5:
  Replace Findbugs with Spotbugs in org.eclipse.jgit/pom.xml
  Replace FindBugs with SpotBugs

Change-Id: I1c077e8f3530ac717b1603d3307fd15d4335b8fe
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-13 09:16:55 +09:00
David Pursehouse 2db49bc679 Replace Findbugs with Spotbugs in org.eclipse.jgit/pom.xml
Change-Id: If9cb0de7a0e7bd95eac7daeee140a18385192a48
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-13 09:14:57 +09:00
David Pursehouse 07bff0ef3e Merge "Upgrade maven-surefire plugins to 2.22.1" 2018-10-12 20:08:58 -04:00
Ivan Frade e82cb5a6d3 FirstWant: tighten first-want line validation
First-want line parsing accepts lines with an optional whitespace, when
the spec is strict requiring a white space.

Validate the line enforcing that there is a white space between oid and
capabilities list.

Change-Id: I45ada67030e0720f9b402c298be18c7518c799b1
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-12 15:41:00 -07:00
Jonathan Nieder 208a3fc8e1 Merge "Move first line parsing for v0/v1 pack negotiation out of UploadPack" 2018-10-12 17:23:32 -04:00
Ivan Frade 6aca8899a5 Move first line parsing for v0/v1 pack negotiation out of UploadPack
In protocol v0/v1 pack negotiation, the first want line contains the
options the client wants in effect. This parsing is done in UploadPack
but it doesn't have any interaction with that class.

Move the code to its own class and package, mark the current one
as deprecated (it is public API) and add unit tests.

Take the chance to move the parsing code from the constructor to a
factory method, making the class a simple container of results.

Change-Id: I1757f535dda78a4111a1c12c3a3b455a4b6f0c51
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-12 13:59:06 -07:00
David Pursehouse f5961cc5d9 Upgrade maven-surefire plugins to 2.22.1
Change-Id: Ic53997223de82b8e0c4df96624889ffb9715822a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-12 18:55:38 +09:00
David Pursehouse 4da3b9368b Upgrade error_prone_core to 2.3.2
Change-Id: Icd9b08ad0c922e3e0a436f2a0a7fd60019ee22ae
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-11 19:38:29 +09:00
David Pursehouse b3adaf7741 PackOutputStream: Suppress Error Prone's ShortCircuitBoolean warning
The usage of non-short-circuit logic is intentional, per the inline
comment added in change Ib4b35e357 as a follow-up to Ie3761ffb4 which
was a previously rejected attempt to "fix" a similar warning that had
been raised by FindBugs.

Change-Id: I3f6729f954d45d30ce697356d2ab3cc877d3ad54
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-10 11:30:25 +02:00
Matthias Sohn 36536e3396 Add missing @since tags for ObjectChecker.ErrorType
Change-Id: I4d0cd25d6cfaf8b81e58f35e58890ac580eaf9c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-10 11:28:24 +02:00
Matthias Sohn de8de3bbd4 Revert "Remove unused API problem filters"
This reverts commit 37c7fbd661.

These filters weren't unused. Without them Eclipse raises 4 API errors.

Change-Id: I5ce443d40b5f517be4a315479e81246d40af1983
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-10 11:28:16 +02:00
David Pursehouse bcc327df3b Bazel: Require minimum bazel version 0.17.1
Check the bazel version using the checker from bazel_skylib, and
require at least version 0.17.1 which is the minimum version that
does not suffer from the Java API mismatch issue [1].

The implementation is borrowed from the Gerrit project.

[1] https://github.com/bazelbuild/bazel/issues/6027

Change-Id: I224250088a1f5072fcaa3ec81228f4d2cb8cb389
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-10 11:39:56 +09:00
David Pursehouse fbbb0b1e19 Merge "ValidRefNameTest#testNormalizeBranchName: Fix string/ref equality check" 2018-10-09 22:07:14 -04:00
David Pursehouse 37c7fbd661 Remove unused API problem filters
Change-Id: I4fb1d2cf1cea92dd314edc776ddbaa6640c99cf1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-09 20:59:23 -04:00
David Pursehouse b0f2826dfd ValidRefNameTest#testNormalizeBranchName: Fix string/ref equality check
Change-Id: Ibffb0dcaab6ec033b1b69aa27ccb7fdaa32fa925
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-10 09:53:04 +09:00
David Pursehouse db5cc027fd Merge changes from topic 'maven-plugin-updates'
* changes:
  Upgrade wagon-ssh to 3.2.0
  Upgrade maven-jxr-plugin to 3.0.0
  Upgrade maven-shade-plugin to 3.2.0
  Upgrade jacoco-maven-plugin to 0.8.2
  Upgrade maven-project-info-reports-plugin to 3.0.0
  Upgrade maven-enforcer-plugin to 3.0.0-M2
  Upgrade maven surefire plugins to 2.22.0
  Ensure same version of maven-surefire-plugin and maven-surefire-report-plugin
2018-10-09 20:22:27 -04:00
Jonathan Nieder b0991ca805 Format @NonNull on return value as method annotation
For example, instead of using

	public @NonNull String getMyFavoriteString() { ... }

use

	@NonNull
	public String getMyFavoriteString() { ... }

This makes the style more consistent (the existing JGit code base
tends to lean toward the second style) and makes the source code
better reflect how the annotation is parsed, as a METHOD annotation.

Longer term, we should switch to a TYPE_USE annotation and switch to
the first style.

Noticed using a style checker that follows
https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations

Change-Id: I9b9fa08035d805ca660520f812a84d2f47eff507
Reported-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-09 15:56:55 -07:00
Jonathan Nieder 608b6b03b1 Format @Nullable on return value as method annotation
For example, instead of using

	public @Nullable String getMyFavoriteString() { ... }

use

	@Nullable
	public String getMyFavoriteString() { ... }

This makes the style more consistent (the existing JGit code base
tends to lean toward the second style) and makes the source code
better reflect how the annotation is parsed, as a METHOD annotation.

Longer term, we should switch to a TYPE_USE annotation and switch to
the first style.

Noticed using a style checker that follows
https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations

Change-Id: I07f4e67cc149fb8007f696a4663e10d4bfc57e3a
Reported-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-09 15:52:54 -07:00
Jonathan Nieder c58362c174 Avoid using @Nullable to annotate arrays
As described in the javadoc for org.eclipse.jgit.annotations.Nullable:

  Warning: Please do not use this annotation on arrays. Different
  annotation processors treat `@Nullable Object[]` differently: some
  treat it as an array of nullable objects, for consistency with
  versions of `Nullable` defined with `@Target TYPE_USE`, while others
  treat it as a nullable array of objects. JGit therefore avoids using
  this annotation on arrays altogether.

  See the checker-framework manual[1] for details.

  [1] http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#faq-array-syntax-meaning

Change-Id: I14ffcf80adbb8145d797998de2f2fa6ab84c3ae3
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-09 15:52:54 -07:00
Ivan Frade 81b7f0e835 FsckError: Use @Nullable as field annotation (before any modifier)
More consistent with general coding style.

Change-Id: Idd0695c63d0b4a17640460e8c388ce12e952879a
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 14:43:08 -07:00
Ivan Frade 39b27f7c7b DfsFsck: Check that .gitmodules in the repository have valid contents
Previous commits block the addition to the repo of dangerous .gitmodules
files, but some could have been committed before those safeguards where
in place.

Add a check in DfsFsck to validate the .gitmodules files in the repo.
Use the same validation than the ReceivePack, translating the
results to FsckErrors.

Note that *all* .gitmodules files in the storage will be checked, not
only the latest version.

Change-Id: I040cf1f31a779419aad0292ba5e6e76eb7f32b66
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 13:48:47 -07:00
Ivan Frade 7aebb6779c FsckError.CorruptObject: Use @Nullable constructor for errorType
errorType is already null in the caller and callee when unknown, so we
can replace a conditional call to a setter in the only caller with an
unconditionally provided @Nullable constructor parameter.

As a bonus, this lets us mark the field as final.

Change-Id: Ie2f929180e74ffa1aba8ec6caccfa81fbd8bfc04
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 11:53:06 -07:00
Ivan Frade 9372791fcf SubmoduleValidator: Always throw SubmoduleValidationException
The fsck test needs more detail about the error than an IOException
with an explanatory message.

Add an error identifier to the SubmoduleValidatorException and make
it the only throwable exception when parsing a file.

Change-Id: Ic3f0955b497e1681b25e681e1282e876cdf3d2c5
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 11:52:57 -07:00
David Pursehouse 7eb34c175c Replace FindBugs with SpotBugs
SpotBugs [1] is the spiritual successor of FindBugs, carrying on from
the point where it left off with support of its community.

This is a backport of [1] which originally did the replacement on the
master branch. This change updates to the current latest version, so
that we can get the benefit of its checks when pushing changes to the
stable branches.

[1] https://spotbugs.github.io/
[2] https://git.eclipse.org/r/#/c/101312/

Change-Id: Ib73d56b5980b55f4d7e09d87abec3138cac3d3dc
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-09 10:11:25 +09:00
Jonathan Nieder 18dce03a41 Merge branch 'stable-5.1'
* stable-5.1:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Ie0e35231c81a0c53c2051c4c123a5210b5a1c6d3
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:42:09 +00:00
Jonathan Nieder 6dd50d2e1b Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Iaa3160a1307777cc4233d82e50a57c63d75d141c
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:41:38 +00:00
Jonathan Nieder e63ca8d094 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Iaf3b994e763bd02054b820cd87fe68ff83675001
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:41:15 +00:00
Jonathan Nieder eb41de5b25 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Id74c837d6cb728439ccbd6ade71936b493c09e08
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:40:47 +00:00
Jonathan Nieder 8b239e5b75 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Ib3c311f1e8d2db95510292a72f2f49825ffce9d9
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:40:05 +00:00
Jonathan Nieder 9d91bf189e Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  SubmoduleValidator: Remove unused import of ConfigConstants

Change-Id: Id01fd9945e23a9343f96c42db89d5a1b302dad33
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:39:18 +00:00
Jonathan Nieder f282aaa137 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  SubmoduleValidator: Remove unused import of ConfigConstants

Change-Id: I6a7d19602d6d9099928ee52de727743b9717f262
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:38:59 +00:00
David Pursehouse 26e7a74601 SubmoduleValidator: Remove unused import of ConfigConstants
Change-Id: I6afe5690bf9d1f1f4d414aa618daefc8b48d217e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-09 08:29:26 +09:00
Jonathan Nieder 8ef8b71db9 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  SubmoduleValidator: Permit missing path or url

Change-Id: I989ac2c0c124c82385fc7cac7e0544ec225f7589
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 21:49:24 +00:00
Jonathan Nieder 830e0d6b8c Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  SubmoduleValidator: Permit missing path or url

Change-Id: I94fdaf45abbf7665f9eddc14b1a7f7144aafeadf
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 21:49:09 +00:00
Jonathan Nieder d3eaf1007b SubmoduleValidator: Permit missing path or url
A .gitmodules file can include a submodule without a path to configure
the URL for a submodule that is only present on other branches.

A .gitmodules file can include a submodule with no URL and no path to
reserve the name for a submodule that existed in earlier history but
is not available from any URL any more.

"git fsck" permits both of these cases.  Permit them in JGit as well
(instead of throwing NullPointerException).

Change-Id: I3b442639ad79ea7a59227f96406a12e62d3573ae
Reported-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 21:40:56 +00:00
Michael Keppler 03ccdb0782 RefAdvertiser: Add Javadoc for usage of send(Collection)
This was not updated with the original introduction of the new method.

Bug: 534731
Change-Id: Ic4589c3a209109a829fbb706a9bf38845134e904
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-10-08 08:45:11 +02:00
David Pursehouse 0527495db8 Upgrade wagon-ssh to 3.2.0
Change-Id: I8e268e516626b2eb2fcca5ec5cb83ea408401bb8
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
David Pursehouse 8eae450890 Upgrade maven-jxr-plugin to 3.0.0
Change-Id: Id85c6cfc27f8d0ae01f74bfdb675db58cb5d0410
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
David Pursehouse 49194e3608 Upgrade maven-shade-plugin to 3.2.0
Change-Id: Iab1edce2f40aaa78729ded35cc0b94bed408069a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
David Pursehouse 28de908ebe Upgrade jacoco-maven-plugin to 0.8.2
Change-Id: Icac28cdee81d8c6067dbd382695a8bd3999053e0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
David Pursehouse 1b56ee87ba Upgrade maven-project-info-reports-plugin to 3.0.0
Change-Id: I316dcdb8dee192c33d272aa2a7ed860ef613b8a1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
David Pursehouse e2ab04e781 Upgrade maven-enforcer-plugin to 3.0.0-M2
Change-Id: I9d5ce4a5432d5cbea2c915a84044d8ade3a7f48b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
David Pursehouse 3ac9e790ad Upgrade maven surefire plugins to 2.22.0
Change-Id: Iaf56c448d35042a60d6ce1cc5f4ed6a10a44aa3f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
David Pursehouse 8d040d6ba9 Ensure same version of maven-surefire-plugin and maven-surefire-report-plugin
The version of maven-surefire-report-plugin was controlled by a project
property, but the maven-surefire-plugin version was set explicitly.

Rename maven-surefire-report-plugin-version to maven-surefire-version,
and use the same property for both plugins' versions.

Change-Id: Ib2aea36f3db969cd038c071d0cd35f9056642518
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 13:51:47 +09:00
Jonathan Nieder 51d656586b SubmoduleAddCommand: Remove double-check of submodule name
Since v4.7.5.201810051826-r~3 (SubmoduleAddCommand: Reject submodule
URIs that look like cli options, 2018-09-24), SubmoduleAddCommand
checks submodule names for ".." path components in
assertValidSubmoduleName.  This additional check for the same is
redundant.

Change-Id: I993326a370978880b690dc133a81fa3025935bcb
Signed-off-by: Jonathan Nieder <jrn@gmail.com>
2018-10-07 22:14:02 -04:00
David Pursehouse 8309f5011e Merge branch 'stable-5.1'
* stable-5.1:
  Update API warning filter to 5.1.3

Change-Id: I5d88e41308dc3076e17463d949efdabcf602305a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-08 10:54:09 +09:00