summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs/src
Commit message (Collapse)AuthorAgeFilesLines
* Format @NonNull on return value as method annotationJonathan Nieder2018-10-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Format @Nullable on return value as method annotationJonathan Nieder2018-10-092-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [spotBugs] Fix potential NPE in SmudgeFilter#downloadLfsResourceMatthias Sohn2018-09-131-1/+4
| | | | Change-Id: Ibaf8481a5b1a96ebe1debfd98e1e2201d1005fc0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8David Pursehouse2018-09-043-10/+10
| | | | | Change-Id: I3b748620f067582afef20f144feebe40d0332be2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Specify charset when constructing InputStreamReaderDavid Pursehouse2018-09-022-2/+3
| | | | | | | | | | | | 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>
* refactor: simplify collection.toArray()Michael Keppler2018-08-231-1/+1
| | | | | | | | | | | On recent VMs, collection.toArray(new T[0]) is faster than collection.toArray(new T[collection.size()]). Since it is also more readable, it should now be the preferred way of collection to array conversion. https://shipilev.net/blog/2016/arrays-wisdom-ancients/ Change-Id: I80388532fb4b2b0663ee1fe8baa94f5df55c8442 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
* Propagate failure of ssh command to caller of SshSupportMatthias Sohn2018-06-133-23/+38
| | | | | | | | | | | | When SshSupport.runSshCommand fails since the executed external ssh command failed throw a CommandFailedException. If discovery of LFS server fails due to failure of the git-lfs-authenticate command chain the CommandFailureException to the LfsConfigInvalidException in order to allow root cause analysis in the application using that. Change-Id: I2f9ea2be11274549f6d845937164c248b3d840b2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix issues with LFS on GitHub (SSH)Markus Duft2018-06-122-5/+20
| | | | | | | | | | | | | * URIish seems to have a tiny feature (bug?). The path of the URI starts with a '/' only if the URI has a port set (it seems). * GitHub does not return SSH authorization on a single line as Gerrit does - need to account for that. * Increase the SSH git-lfs-authenticate timeout, as GitHub sometimes responds slower than expected. * Guard against NPE in case the download action does not contain any additional headers. Change-Id: Icd1ead3d015479fd4b8bbd42ed42129b0abfb95c Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
* LFS: Better SSH authentication token timeout handlingMarkus Duft2018-06-091-3/+4
| | | | | | | * Larger eager timeout to compensate for high-latency lines * Respect eager timeout in case the server uses "expiresIn" Change-Id: Id87da1eea874e70b69eaccf35c84af4c3bb50770 Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
* Remove further unnecessary 'final' keywordsHan-Wen Nienhuys2018-05-182-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove it from * package private functions. * try blocks * for loops this was done with the following python script: $ cat f.py import sys import re import os def replaceFinal(m): return m.group(1) + "(" + m.group(2).replace('final ', '') + ")" methodDecl = re.compile(r"^([\t ]*[a-zA-Z_ ]+)\(([^)]*)\)") def subst(fn): input = open(fn) os.rename(fn, fn + "~") dest = open(fn, 'w') for l in input: l = methodDecl.sub(replaceFinal, l) dest.write(l) dest.close() for root, dirs, files in os.walk(".", topdown=False): for f in files: if not f.endswith('.java'): continue full = os.path.join(root, f) print full subst(full) Change-Id: If533a75a417594fc893e7c669d2c1f0f6caeb7ca Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* Remove 'final' in parameter listsHan-Wen Nienhuys2018-05-154-42/+42
| | | | | Change-Id: Id924f79c8b2c720297ebc49bf9c5d4ddd6d52547 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* Remove trivial cases of using deprecated RefDatabase.getRefs()Matthias Sohn2018-04-251-2/+2
| | | | Change-Id: I2d3e426a3391923f8a690ac68fcc33851f3eb419 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge branch 'stable-4.11'David Pursehouse2018-04-091-0/+4
|\ | | | | | | | | | | | | | | * stable-4.11: LFS: Fix potential NPE in LfsPrePushHook Change-Id: If721bd18035870541d216d2dcd9d47484e9af3e5 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
| * LFS: Fix potential NPE in LfsPrePushHookMarkus Duft2018-04-041-0/+4
| | | | | | | | | | | | The NPE occurred in conjunction with a symbolic ref (origin/HEAD). Change-Id: I291636818a121ca00e0df25de5b6fc71a48d447f Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
* | Merge "Introduce SshSupport to centralize SSH related utility code"Matthias Sohn2018-03-121-46/+6
|\ \
| * | Introduce SshSupport to centralize SSH related utility codeMarkus Duft2018-03-121-46/+6
| |/ | | | | | | | | | | | | | | | | | | | | | | As discussed with Thomas here: https://git.eclipse.org/r/#/c/83506/31/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java@349 Move the code from ConfigureGerritAfterCloneTask to SshSupport and eliminate the slightly modified copy of the code from LfsConnectionFactory. Separate EGit commit will eliminate the code from ConfigureGerritAfterCloneTask. Change-Id: Ifb5adb1342e0fc1f2a70cddf693408d4e0ef7906 Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
* | Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8David Pursehouse2018-03-113-8/+9
| | | | | | | | | | Change-Id: I6714fc3666e1bced22abba94ceb700477349586e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Remove deprecated Lfs#Lfs(Path)Matthias Sohn2018-03-101-13/+0
|/ | | | | | Use Lfs#Lfs(Repository) instead. Change-Id: I7303987ed047b42fd1bac8e27ed49333080e556b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LFS: Adjust some API to make integration into tools (EGit,...) easierMarkus Duft2018-03-072-4/+11
| | | | | | | | | | Make the install command accessible without requiring reflection. Expose the isEnabled(Repository) API to be able to check if calling the install command is required for a repository. Change-Id: I17e6eaefb6afda17fea8162cbf0cb86a20506753 Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* SmudgeFilter: Fix Integer boxing warningDavid Pursehouse2018-03-051-1/+2
| | | | | Change-Id: Ic00bcd25b0808a58880a4433d76b3b5a6a4ee5c7 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Add ConfigConstants.CONFIG_SECTION_LFSDavid Pursehouse2018-03-053-9/+12
| | | | | | | | | | | | | | DirCacheCheckout has a warning about non-localised string "lfs". Other classes use org.eclipse.jgit.lfs.lib.Constants but that is not visible to DirCacheCheckout. Add a new constant in ConfigConstants and use that in DirCacheCheckout. Replace existing uses of org.eclipse.jgit.lfs.lib.Constants.LFS with the new constant, except where it is referring to the folder name. Change-Id: I0f21b951babff9a2e579d68c4de0c62ee4bc23d4 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Return this from InstallLfsCommand.setRepository() to allow chainingMatthias Sohn2018-03-041-1/+5
| | | | Change-Id: I105f1f62f2dcdb20a196361190e9c9fe368e8613 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LFS: Enable LFS support for the CLI, better error handlingMarkus Duft2018-03-032-0/+6
| | | | | | | | | | Enable LFS support for the CLI by registering the according filters. Errors during filter creation must be propagated up the call stack, as a failure to create a filter should be treated as fatal if the filter is required. Change-Id: I3833757839bdda97cd01b6c21c1613d199e2692d Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
* Cleanup stream usage WRT filtersMarkus Duft2018-03-032-30/+45
| | | | | | | | As it is right now some streams leak out of the filter construct. This change clarifies responsibilities and fixes stream leaks Change-Id: Ib9717d43a701a06a502434d64214d13a392de5ab Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LFS: support merge/rebase/cherry-pick/diff/compare with LFS filesMarkus Duft2018-03-036-11/+399
| | | | | | | | | | | | Respect merge=lfs and diff=lfs attributes where required to replace (in memory) the content of LFS pointers with the actual blob content from the LFS storage (and vice versa when staging/merging). Does not implement general support for merge/diff attributes for any other use case apart from LFS. Change-Id: Ibad8875de1e0bee8fe3a1dffb1add93111534cae Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LFS: Dramatically improve checkout speed with SSH authenticationMarkus Duft2018-03-014-15/+108
| | | | | | | | | | | | | | | SSH Authentication is quite expensive (~120ms on localhost against Gerrit with LFS plugin). The SSH authentication typically also sends a validity time of the returned token, which allows to re-use it for a certain time, avoiding the expensive authentication on every download request. This improves checkout times by large factors depending on the LFS object amount/sizes. Also make sure that all instances of Gson used by LFS are configured in the same way. Change-Id: I422c94c37021b4322789b3829fa0185e25d683f2 Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
* LFS: pre-push upload supportMarkus Duft2018-02-275-182/+600
| | | | | | | | | | | | If JGit built in LFS support is enabled for the current repository (or user/system), any existing pre-push hook will cause an exception for the time beeing, as only a single pre-push hook is supported. Thus either native pre-push hooks OR JGit built-in LFS support may be enabled currently, but not both. Change-Id: Ie7d2b90e26e948d9cca3d05a7a19489488c75895 Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LFS: Add remote download to SmudgeFilterMarkus Duft2018-02-168-24/+686
| | | | | | | | | | | | | | | Transfer data in chunks of 8k Transferring data byte per byte is slow, running checkout with CleanFilter on a 2.9MB file takes 20 seconds. Using a buffer of 8k shrinks this time to 70ms. Also register the filter commands in a way that the native GIT LFS can be used alongside with JGit. Implements auto-discovery of LFS server URL when cloning from a Gerrit LFS server. Change-Id: I452a5aa177dcb346d92af08b27c2e35200f246fd Also-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
* Fix remaining javadoc errors raised by doclintMatthias Sohn2017-12-213-10/+12
| | | | | | | For now ignore doclint "missing" warnings. Change-Id: I0e5af7a757f4d92ffeeb113f30576a35414d6781 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix javadoc in org.eclipse.jgit.lfsMatthias Sohn2017-12-1724-84/+190
| | | | Change-Id: I97b53c083da6aa31719d9e10369030ee33dd23dc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Use constants from StandardCharsets instead of hard-coded stringsDavid Pursehouse2017-12-072-10/+9
| | | | | | | | | | | | | | | | 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>
* InvalidLongObjectIdException: Fix formatting of messageDavid Pursehouse2017-12-071-1/+1
| | | | | | | | | | | | | The message is formatted as: Invalid id: : abcde... but should be: Invalid id: abcde... Change-Id: Ie15cacdcf2f168edaee262e6cf8061ebfe9d998d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* FileUtils.toPath to convert File to PathMarc Strapetz2017-11-142-2/+3
| | | | | | | | | | | When invoking File.toPath(), an (unchecked) InvalidPathException may be thrown which should be converted to a checked IOException. For now, we will replace File.toPath() by FileUtils.toPath() only for code which can already handle IOExceptions. Change-Id: I0f0c5fd2a11739e7a02071adae9a5550985d4df6 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
* Add missing newlines at ends of Java filesDavid Pursehouse2017-07-251-1/+1
| | | | | Change-Id: Iead36f53d57ead0eb3edd3f9efb63b6630c9c20c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Enable and fix 'Should be tagged with @Override' warningDavid Pursehouse2017-02-192-0/+4
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Don't rely on default locale when using toUpperCase() and toLowerCase()Matthias Sohn2017-01-281-1/+2
| | | | | | | | | | | | | | | | 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>
* Expose LFS operation strings as public constantsDavid Pursehouse2017-01-131-0/+21
| | | | | | | | 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>
* LfsProtocolServlet: Improve error on getLargeFileRepository failureDavid Pursehouse2017-01-141-0/+1
| | | | | | | | 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>
* Add support for refusing LFS request due to invalid authorizationDavid Pursehouse2017-01-132-0/+69
| | | | | | | | | | | | | | | | | | | 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>
* Add LfsPointerFilter TreeFilterDariusz Luksza2017-01-102-3/+111
| | | | | | | | | | | | | | | Add new variation of TreeFilter in order to detect LFS pointer files in the repository. Additionally, update LfsPointer to support the legacy version URL [1] as described in [2], and to allow arbitrary fields in the pointer file. [1] https://hawser.github.com/spec/v1 [2] https://github.com/git-lfs/git-lfs/blob/master/docs/spec.md Change-Id: I621eb058619fb1b78888a54c4b60bb110a722fc3 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* [findBugs] Fix potential NPE in CleanFilterMatthias Sohn2016-12-291-1/+4
| | | | Change-Id: Ibc20e9fc16be62f61748b3f59f6d70c1ebf63671 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix encoding of LFSPointer filesChristian Halstrick2016-11-241-5/+13
| | | | | | | | | | LFS pointer files have to be UTF-8 with \n as line ending character. That is described in [1]. Fix JGit to follow this rules. [1] https://github.com/github/git-lfs/blob/master/docs/spec.md Bug: 507120 Change-Id: Ib6bd13f1cc17f1a3de125249b4f250b7b0692396
* Use AtomicObjectOutputStream in CleanFilterMatthias Sohn2016-10-262-22/+33
| | | | | | | Enhance and use AtomicObjectOutputStream to write temporary files in CleanFilter. Change-Id: I28987dad18255a9067344f94b4e836cbd183e4b1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* CleanFilter: use atomic move to move temporary file to media fileMatthias Sohn2016-10-261-1/+3
| | | | Change-Id: I227a0ed6e4e15ac3d96f96a6cefcaf55680ad8bb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix temporary file leak in CleanFilterMatthias Sohn2016-10-261-0/+2
| | | | | | | The CleanFilter leaked temporary files when a media file already existed before running clean filter. Change-Id: Ie20fce3f40d34095ce58e596d25d8d64fe0cde99 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Use AnyLongObjectId instead of LongObjectId in LFS APIMatthias Sohn2016-10-262-8/+9
| | | | Change-Id: I083ad1ea3e8d3685df7c306854c2498c92b05ffb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Speedup CleanFilter by transferring data in chunks of 8kMatthias Sohn2016-10-261-5/+6
| | | | | | | | Transferring data byte per byte is slow, running add with CleanFilter on a 2.9MB file takes 20 seconds. Using a buffer of 8k shrinks this time to 70ms. Change-Id: I3bc2d8c11fe6cfaffcc99dc2a00643e01ac4e9cc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Content type constants used in lfs should be finalMatthias Sohn2016-10-121-2/+2
| | | | Change-Id: Ia56a9f58e336c25255a81d9402e198e5ce5da442 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Move AtomicObjectOutputStream to lfs/internalChristian Halstrick2016-09-202-0/+129
| | | | | | | | | 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
* Add built-in LFS smudge filter for local caseChristian Halstrick2016-09-203-1/+179
| | | | | | | | | | | | Adds a JGit built-in implementation of the "git lfs smudge" filter. This filter should do the same as the one described in [1] besides that it only supports the local case when the lfs objects are already present in the media directory. Remote cases where download of LFS objects from an LFS server is needed will be done in a later commit. [1] https://github.com/github/git-lfs/blob/master/docs/man/git-lfs-smudge.1.ronn Change-Id: I8ff661d4edd3667ef7f86f3b4fa33e568eb4c8f4