Commit Graph

80 Commits

Author SHA1 Message Date
Matthias Sohn 5d64d3d83a Fix javadoc in org.eclipse.jgit.lfs.server
Change-Id: I0c52536ebeeb8e71d95c6420f6db7055ff082dfa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-12-17 20:59:24 +01:00
David Pursehouse 171f84a041 Use constants from StandardCharsets instead of hard-coded strings
Instead of hard-coding the charset strings "US-ASCII", "UTF-8", and
"ISO-8859-1", use the corresponding constants from StandardCharsets.

UnsupportedEncodingException is not thrown when the StandardCharset
constants are used, so remove the now redundant handling.

Because the encoding names are no longer hard-coded strings, also
remove redundant $NON-NLS warning suppressions.

Also replace existing usages of the constants with static imports.

Change-Id: I0a4510d3d992db5e277f009a41434276f95bda4e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-12-07 20:02:59 +09:00
David Pursehouse 5f94e44308 LfsServerText: Fix formatting of invalidPathInfo message
The message is formatted as:

  Invalid pathInfo '/abc' does not match '/{SHA-256}'

but should be:

  Invalid pathInfo: '/abc' does not match '/{SHA-256}'

(i.e. including a colon) to be consistent with other messages.

Change-Id: Ic38aa7d33dd02d7954b95c331a73919a90c69991
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-12-07 20:02:59 +09:00
David Pursehouse b433f2722f Move repeated LFS Gson handling to common class
LfsProtocolServlet and FileLfsServlet both implement the same
setup of the Gson object.

Factor it out to a common class and reuse it.

Change-Id: I5696404fad140cbff1b712ebb04a7e8bba60e4b4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-12-07 20:02:59 +09:00
David Pursehouse a7e20cc77f FileLfsServlet: Do not pretty print json response
Pretty printing the response is useful for human readers, but most
(if not all) of the time, the response will be read by programs.

Remove it to avoid the additional overhead of the formatting and
extra bytes in the response. Adjust the test accordingly.

Note that LfsProtocolServlet already doesn't use pretty printing,
so this change makes FileLfsServlet's behavior consistent. In fact,
both classes now have duplicate Gson handling; this will be cleaned
up in a separate change.

Change-Id: I113a23403f9222f16e2c0ddf39461398b721d064
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-12-07 08:42:13 +09:00
Matthias Sohn f0c119de4f Merge branch 'stable-4.9'
* stable-4.9:
  Ignore warning for minor version change without API change
  Silence boxing warning
  Prepare 4.5.5-SNAPSHOT builds
  JGit v4.5.4.201711221230-r
  Fix LockFile semantics when running on NFS
  Honor trustFolderStats also when reading packed-refs
  Prepare 4.5.4-SNAPSHOT builds
  JGit v4.5.3.201708160445-r

Change-Id: Icc33d2e36f140e8714fce088379673a8834ae9de
2017-11-24 01:18:13 +01:00
Matthias Sohn 03abd1dff2 Ignore warning for minor version change without API change
- this is a new warning option in Eclipse 4.7 and higher
- we always change version of all bundles in a release to keep release
engineering simple

Change-Id: Ic7523d77b67b2802f1bab3bc70af250d712a034f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-11-24 01:12:14 +01:00
Matthias Sohn 6b544da293 Prepare 4.10.0-SNAPSHOT builds
Change-Id: I5ca462d1db18a2c5c9382cfb9c83972510fa2b88
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-10-08 11:35:54 +02:00
Matthias Sohn 8180183289 Prepare 4.9.1-SNAPSHOT builds
Change-Id: Ic49fd093d3fe4324c4d83aba74033040fcaa37a6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-10-08 11:25:06 +02:00
Matthias Sohn 6877730fa0 JGit v4.9.0.201710071750-r
Change-Id: I487f6aa3d0c4ef1d57f91cdc36177d994ae24c51
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-10-07 23:46:52 +02:00
Matthias Sohn 41baa7a791 Partially revert c0ad77d8 "Enhance Eclipse save actions"
Do not automatically organize imports using a save action since this
seems to be buggy and removed some annotations org.eclipse.jgit.pgm
needs to use args4j.

Change-Id: I5a91292c3b9241ce2dde3e4ecce14ad460097129
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-08-30 03:07:18 +02:00
Matthias Sohn 9906f09868 Partially revert c0ad77d8 "Enhance Eclipse save actions"
Revert the following save actions which were introduced in c0ad77d8:
- always use braces around blocks
- remove unused imports

Other than I expected save actions are run globally on edited files -
and not only on edited code lines only.

Hence revert the save action "Convert control statement bodies to
blocks" which would affect a large number of code lines not affected by
the change editing some small part of a class. This would generate a
large number of changes which may lead to many unnecessary conflicts.
Total number of affected lines across jgit would be around 10k lines.

Also revert "Remove unused imports" since it erroneously removes imports
of some annotations needed by pgm classes using args4j.

Change-Id: I879a47f68e664129e6124cf25c1ae1f6a2d7a5aa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-08-30 01:24:47 +02:00
Matthias Sohn c0ad77d84c Enhance Eclipse save actions
Add the following Eclipse save actions executed when saving modified
lines. This should help to reduce manual work needed to maintain a clean
and consistent code style:
- organize imports
- always use braces around blocks
- add missing annotations
  - @Override including implementation of interface methods
  - @Deprecated
- remove
  - unused imports
  - unnecessary $NON-NLS$ tags
  - redundant type arguments

Also add default values for new settings that were introduced in recent
Eclipse versions up to Neon since we updated save rules the last time.

Change-Id: Idc90b249df044d0552f04edf01a5f607c4846f50
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-08-28 11:52:45 -04:00
David Pursehouse 4940ea14b7 Add missing newlines at ends of Java files
Change-Id: Iead36f53d57ead0eb3edd3f9efb63b6630c9c20c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-07-25 10:37:21 +01:00
Matthias Sohn df9ce4b981 Prepare 4.9.0-SNAPSHOT builds
Change-Id: I52a4153d573799e861ab104939f51fac1aceb9ee
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-05-30 13:42:07 +02:00
David Pursehouse decb6d01cc Remove unused clirr-maven-plugin from LFS pom.xml files
Change-Id: I7252b6c89d91ac675c0e02e4d17ba0212b617098
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-05-12 08:30:45 +09:00
David Pursehouse c80d8c5901 Bazel: Restrict src globs to Java source files
Generating the src list with an unrestricted wildcard causes all
files in the source tree to be included. This results in junk files
such as .orig (generated during merge conflict resolution) to be
included, which causes in a build error:

  in srcs attribute of java_library rule //org.eclipse.jgit:jgit:
  file '//org.eclipse.jgit:src/org/eclipse/jgit/gitrepo/RepoCommand.java.orig'
  is misplaced here (expected .java, .srcjar or .properties).

Modify the globs to only include Java source files.

Change-Id: Iaef3db33ac71d71047cd28acb0378e15cb09ece9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-04-13 14:14:55 +09:00
Matthias Sohn b3cc05d886 Remove unused API filters
Change-Id: I1e00d71395228265aad4071b023024ee1bf855d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-09 23:43:43 +02:00
Matthias Sohn aec22e74cf Prepare 4.8.0-SNAPSHOT builds
Change-Id: Ifea6750e79d417a8a2a891b3b5f96d68c7200011
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-05 14:49:49 +02:00
David Pursehouse 2d0ce094b4 Remove Buck build
Buck will be replaced with Bazel

Change-Id: I3cf07d7aaaa2a58bac34e16c50af5416693254ac
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-03-22 01:41:21 +01:00
Jonathan Nieder bc5014faec bazel: Add explicit targets for library dependencies
This provides a place to declare visibility restrictions and
transitive dependencies for each library.

Other targets should only declare dependencies on what they directly
use, making dependencies easier to maintain.

Trim the dependencies of org.eclipse.jgit:jgit to follow that rule.
It declares dependencies on Apache httpcomponents and the servlet
API but doesn't use them.

Tested:
* 'bazel build //...' succeeds
* applying the change https://gerrit-review.googlesource.com/90843
  to a copy of Gerrit, following the instructions there, and running
  'bazel test //...' in that copy of Gerrit still succeeds

Change-Id: I3ab958ce8b3227019cdbe4cc81e0f042e1541034
2017-03-19 18:51:03 -07:00
Matthias Sohn 3df65a387e Silence API error reported in LfsProtocolServlet
Breaking API for API implementors (not clients) in a minor release is ok
following OSGi semantic versioning rules.

Change-Id: I14bb4a3084b237b4cd893a130e148148cd1e5df9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-03-09 20:43:12 +01:00
David Pursehouse 5094c1a5c8 LfsProtocolServlet: Pass HTTP Authorization header to getLargeFileRepository
This allows implementations to reject operations that do not
include proper authentication.

Change-Id: If301476d8fb56a0899e424be3789c7576097d185
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-03-08 19:11:03 -04:00
David Pursehouse 3b4448637f Enable and fix warnings about redundant specification of type arguments
Since the introduction of generic type parameter inference in Java 7,
it's not necessary to explicitly specify the type of generic parameters.

Enable the warning in Eclipse, and fix all occurrences.

Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-02-20 22:47:23 +01:00
David Pursehouse 7ac182f4e4 Enable and fix 'Should be tagged with @Override' warning
Set missingOverrideAnnotation=warning in Eclipse compiler preferences
which enables the warning:

  The method <method> of type <type> should be tagged with @Override
  since it actually overrides a superclass method

Justification for this warning is described in:

  http://stackoverflow.com/a/94411/381622

Enabling this causes in excess of 1000 warnings across the entire
code-base. They are very easy to fix automatically with Eclipse's
"Quick Fix" tool.

Fix all of them except 2 which cause compilation failure when the
project is built with mvn; add TODO comments on those for further
investigation.

Change-Id: I5772061041fd361fe93137fd8b0ad356e748a29c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-02-19 20:05:08 -04:00
Matthias Sohn a4feeb0194 Don't rely on default locale when using toUpperCase() and toLowerCase()
Otherwise these methods may produce unexpected results if used for
strings that are intended to be interpreted locale independently.
Examples are programming language identifiers, protocol keys, and HTML
tags. For instance, "TITLE".toLowerCase() in a Turkish locale returns
"t\u0131tle", where '\u0131' is the LATIN SMALL LETTER DOTLESS I
character.

See
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#toLowerCase--
http://blog.thetaphi.de/2012/07/default-locales-default-charsets-and.html

Bug: 511238
Change-Id: Id8d8f37d84d62239c918b81f8d883ed798d87656
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-01-28 15:06:15 +01:00
David Pursehouse 9d1474431f Implement Bazel build for http-apache, lfs, lfs-server
Test plan:

  $ bazel build all

  $ unzip -t bazel-genfiles/all.zip
    Archive:  bazel-genfiles/all.zip
      testing: libhttp-apache.jar       OK
      testing: libjgit-archive.jar      OK
      testing: libjgit-lfs-server.jar   OK
      testing: libjgit-lfs.jar          OK
      testing: libjgit-servlet.jar      OK
      testing: libjgit.jar              OK
      testing: libjunit.jar             OK
    No errors detected in compressed data of bazel-genfiles/all.zip.

Change-Id: I9e6c60898ccc6d2a4557ec7544c297442a9702b4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-01-22 22:34:12 +01:00
David Pursehouse d3148f300a Make ObjectDownloadListener public
The same was already done for ObjectUploadListener in I5b0fb1220.

Change-Id: Ie8a79f715fe69bed9331962fb478f7e35acf8680
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-01-19 13:42:59 +09:00
Zhen Chen d3148f9410 Add missing slf4j dependency in BUCK file for jgit-lfs-server
Change-Id: I0c7fcae123f94ebd8e5eb2700e3d601a1b199be9
Signed-off-by: Zhen Chen <czhen@google.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-01-14 15:49:14 +09:00
David Pursehouse 55c629a9f3 LfsProtocolServlet#LfsRequest: Add operation type helper methods
Server implementations may need to check what type of operation is
being performed. Add helper methods to make it a bit simpler.

Change-Id: Ia33ed6699ebcb9000ef514ce79bcddbebf94e1c5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-01-14 01:07:52 +01:00
David Pursehouse 56fe217784 Expose LFS operation strings as public constants
So that they can be used either by third party LFS server implementations
or from within other parts of JGit's internal LFS implementation.

Change-Id: I58da6230247204588e017c010ce5b14e4615448d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-01-13 19:23:33 -04:00
David Pursehouse 590141163f LfsProtocolServlet: Improve error on getLargeFileRepository failure
Externalize the error message and make it more specific. Also emit
an error log.

Change-Id: Ie7b1c90c54673bfb8e133fb0aa19a117d4ca6587
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-01-14 00:05:56 +01:00
David Pursehouse 7245aa0316 Add support for refusing LFS request due to invalid authorization
Add a new exception type that server implementations can throw when a
client attempts to make an unauthorized LFS operation, which will result
in HTTP 401 Unauthorized being returned to the client.

An example of this is a Gerrit server that rejects a request to perform
an LFS operation on a ref that is not visible to the caller.

As defined in the LFS spec [1] the request may include authentication,
and per RFC 2616 [2], "401 response indicates that authorization has been
refused for those credentials".

[1] https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md
[2] https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Change-Id: I2aa22e2144df5fb7972df0e3285b77b08ecc63f2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-01-13 10:46:15 +09:00
Matthias Sohn 44936a1216 Remove unused API warning filters
Change-Id: If6d343a55245219a652e35c9cfde69349dc09889
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-12-29 00:59:02 +01:00
Matthias Sohn 5fee071f6a Prepare 4.7.0-SNAPSHOT builds
Change-Id: I20754d13007e6591d36aae5766f3a9a82b24e120
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-12-27 01:45:50 +01:00
Matthias Sohn 3857c3168f Prepare 4.6.1-SNAPSHOT builds
Change-Id: I6b05a6f6c3f92365c272e1bdaf76093ca01f2d58
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-12-24 15:51:54 +01:00
Matthias Sohn 73a4325149 JGit v4.6.0.201612231935-r
Change-Id: Iaa88fe1b195dfe6be99a7b4cb064684e75563715
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-12-24 01:42:38 +01:00
Jacek Centkowski c7d8fbfaad Expose getObjectToTransfer method of FileLfsServlet
Providing own implementation to doGet/doPut methods is troublesome when
this method is private.

Change-Id: I098cdc5cb90410eaaebc56c88c2d9e168584dd6d
Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-12-06 16:57:16 +09:00
David Pursehouse c62933bf59 Merge branch 'stable-4.5'
* stable-4.5:
  Use the same variable to check and extract LFS object id

Change-Id: I314bd4373f40843c68853b3999f60d85e08628d9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-12-06 16:55:28 +09:00
Jacek Centkowski 8f60297861 Use the same variable to check and extract LFS object id
It is easier to maintain when the same variable is used for both check
and extraction of LFS object id.

Change-Id: I5406f9bc4a085aa164c4565a9667ad2925105190
Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
2016-11-24 11:32:48 +01:00
Matthias Sohn 52fa09c8d4 Add missing @since tags for new API
Change-Id: Iaf83f66637d6a13e4a6d096ba8529553af7e30ed
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-11-14 16:10:40 -08:00
David Pursehouse a45cfee7a3 Organize imports
Change-Id: I7c545d06b1bced678c020fab9af1382bc4416b6e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-11-14 13:25:20 -08:00
David Pursehouse f5a40c26ac FileLfsServlet: Make sendError protected
Change-Id: Id89b3cd0da86a535946feb15254737bbf8d855d4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-11-13 14:31:17 -08:00
David Pursehouse dfa6895687 Make ObjectUploadListener public
Change-Id: I5b0fb1220bc0e5c660f1b5373abc5868d985c60b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-11-13 14:31:17 -08:00
Matthias Sohn cb617e7ffc Prepare 4.5.1-SNAPSHOT builds
Change-Id: I3305e8a09a3fb06f25a316cff2bdbb551d3ade68
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-09-21 17:05:27 +02:00
Matthias Sohn e7142a3937 JGit v4.5.0.201609210915-r
Change-Id: Idc02a1a1d74f84605d764c239803f0cfbad94eb7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-09-21 15:06:18 +02:00
Matthias Sohn ab79ce91c1 Change JGit minimum execution environment to JavaSE-1.8
Bug: 500059
Change-Id: I47f3f6749a67da52029f84e002d9b155ed56d2b7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-09-20 11:32:36 +02:00
Christian Halstrick e4e39a6d05 Move AtomicObjectOutputStream to lfs/internal
The class AtomicObjectOutputStream should be available to all lfs
related classes, not only to the server side. Move the class from
org.eclipse.jgit.lfs.server.fs to org.eclipse.jgit.lfs.internal to
achieve that.

Change-Id: I028e1c9ec7c21f316340b21d558b9a6b77e2060d
2016-09-20 10:58:20 +02:00
Matthias Sohn 9d4ffcc1ab Prepare 4.6.0-SNAPSHOT builds
Change-Id: Id2eafc331ee32c332c2a9b867b05c260beb0d10f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-09-19 17:06:42 +02:00
Matthias Sohn 5a4dcceb7b Improve JavaDoc for LfsProtocolServlet.getLargeFileRepository
Guide implementors which exception to throw in case of errors.

Change-Id: I74fb76cdf6b7cdef513f3fe8c144572e869cc533
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-09-01 16:57:45 -04:00