Commit Graph

6646 Commits

Author SHA1 Message Date
Ivan Frade 9694d89ea1 UploadPack: Use request instead of field for depth
One more step in removing state from UploadPack, using the request
object instead.

Unfortunately, hooks get from UploadPack information about the current
request. Changing the hooks to receive the request is a public API
change, so at the moment lets keep a reference to the current request.

This kills half the benefit of using a request object vs fields, but
at least we still get better modularity.

Change-Id: I86803d876a621b727c66ee73f2880c93190629e9
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:13:04 -07:00
Ivan Frade 81a752bef7 UploadPack: Use request instead of field for shallowSince
Change-Id: I1b9fdb6c58c574f66dbd152c1049ddcd52cc1683
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:13:04 -07:00
Ivan Frade 3c974d0251 UploadPack: Use request in computeShallowUnshallow
All data required in this function is available in the request object.
Use that object instead of class members. This reduces class state and
is more readable.

Make the function use a request object and remove the now unnecessary
field "deepenNotRefs".

Change-Id: If861e44c2860a78cf19f456d1b3feb7ddc314cce
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:13:04 -07:00
Ivan Frade b41d7624b8 Move deepenSince and deepenNotRefs up to FetchRequest
These properties are protocol v2 specific, but they have clear default
no-op values and having them in the common superclass simplifies client
code.

Move properties deepenSince and deepenNotRefs up to FetchRequest. In
FetchV0Request, they are initialized with their no-op values (0 for
deepenSince and empty list for deepenNotRefs)

Change-Id: I9d46a6dfbe29ebd794b5a6482033cdc70d411a23
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:12:59 -07:00
Ivan Frade 2bedc6e08b UploadPack: Use request instead of field for filterBlobLimt
filterBlobLimit is not part of the UploadPack state, and as field
of the class is difficult to see where it is set or accessed.

Use the request object instead of a field. This reduces
UploadPack state and makes clearer how the value is used.

Change-Id: I96a04a5a8b31bf2243de701e1fd7ebb4080b49e2
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 11:17:42 -07:00
Ivan Frade ec838fee0c Mark fetch requests fields as final and @NonNull when possible
Mark reference fields as final, annotate constructor parameters and
getters as @NonNull when appropiate and assert the incoming references
are non-null.

Change-Id: I0ef9a513a99313bf461fe9629ce6cc8b409bdedb
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 11:11:26 -07:00
David Pursehouse f894066f6c Upgrade spotbugs to 3.1.7
Change-Id: I2bfeccafe01cf249ac536ded16be734e28cf4ff0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-16 18:38:34 +09:00
Ivan Frade 1a0b48fecd Create FetchRequest superclass with common elements
Some code apply to both, v1 and v2 requests, so it should receive
just a request instance.

Move all common fields to an abstract superclass that can be passed
to "version neutral" functions.

Change-Id: I47c22fb12065bc93767f78175e2b36cc43ccb5c5
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-15 16:37:22 -07:00
Ivan Frade 8460ab8e87 Rename Fetch V2 request wantsIds and options
In FetchV0Request, the fields "wantsIds" and "options" are called
"wantIds" and "clientCapabilities". Those names describe them better.

Rename FetchV2Request fields to follow fetch v0. This will make easier
to extract a superclass later.

Take also the chance to polish the javadoc.

Change-Id: Ia17dbbab8084f39cc529fef9ca5c65e189073767
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-15 16:27:58 -07:00
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