aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit
Commit message (Collapse)AuthorAgeFilesLines
* LfsConnectionFactoryTest: remove unnecessary castMatthias Sohn2024-10-011-2/+4
| | | | Change-Id: I08ed51b13aa269a4f6b64ac723b6bd7649c6591c
* DirCacheCheckout: use a LinkedHashMap instead of HashMapThomas Wolf2022-03-191-8/+0
| | | | | | | | | | | This guarantees that updates are checked out in git order, which is important for LFS if a .lfsconfig file is used. That file comes early in git order, and the LFS smudge filter will consider the working tree version. To ensure that on branch switches the correct version of that file is used, the checkout order must be stable and should be the git order. Change-Id: I20f6d11bf08558f9d5adfd2be71e36321460038c Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* [checkout] Use .gitattributes from the commit to be checked outThomas Wolf2022-03-071-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JGit used only one set of attributes constructed from the global and info attributes, plus the attributes from working tree, index, and HEAD. These attributes must be used to determine whether the working tree is dirty. But for actually checking out a file, one must use the attributes from global, info, and *the commit to be checked out*. Otherwise one may not pick up definitions that are only in the .gitattributes of the commit to be checked out or that are changed in that commit with respect to the attributes currently in HEAD, the index, or the working tree. Maintain in TreeWalk different Attributes per tree, and add operations to determine EOL handling and smudge filters per tree. Use the new methods in DirCacheCheckout and ResolveMerger. Note that merging in JGit actually used the attributes from the base, not those from ours, which looks dubious at least. It now uses those from ours, and for checking out the ones from theirs. The canBeContentMerged() determination was also done from the base attributes, and is newly done from the ours attributes. Possibly this should take into account all three attributes, and only if all three agree the item can be content merged, a content merge should be attempted? (What if the binary/text setting changes between base, ours, or theirs?) Also note that JGit attempts to perform content merges on non-binary LFS files; there it used the filter attribute from base, too, even for the ours and theirs versions. Newly it takes the filter attribute from the correct tree. I'm not convinced doing content merges on potentially huge files like LFS files is really a good idea. Add tests in FilterCommandsTest and LfsGitTest to verify the behavior. Open question: using index and working tree as fallback for the attributes of ours (assuming it is HEAD) is OK. But does it also make sense for base and theirs in merging? Bug: 578707 Change-Id: I0bf433e9e3eb28479b6272e17c0666e175e67d08 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Support for "lfs.url" from ".lfsconfig"Matthias Fromme2022-03-032-21/+515
| | | | | | | | | | | - New class LfsConfig to enrich repository configuration by settings from ".lfsconfig" file respecting configuration file precedence. - Adapted LfsConnectionFactory to use LfsConfig instead of directly using configuration from repository to calculate url of the lfs repository Bug: 578020 Change-Id: I156f4ec137c2e428136a2ca9b8a4011ecee2d915
* Support LFS Server URL without .git suffixNail Samatov2022-02-081-0/+132
| | | | | | | | | | | | | | | | | | | | According to Git LFS documentation, URLs with and without .git suffix should be supported. By default, Git LFS will append .git/info/lfs to the end of a Git remote URL. To build the LFS server URL it will use: Git Remote: https://git-server.com/foo/bar LFS Server: https://git-server.com/foo/bar.git/info/lfs Git Remote: https://git-server.com/foo/bar.git LFS Server: https://git-server.com/foo/bar.git/info/lfs Fix the LfsConnectionFactory accordingly. Move a utility method to add the ".git" suffix if not present yet from FileResolver to StringUtils and use it. Bug: 578621 Change-Id: I8d3645872d5f03bb8e82c9c73647adb3e81ce484 Signed-off-by: Nail Samatov <sanail@yandex.ru> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* LFS: handle invalid pointers betterThomas Wolf2021-03-011-0/+141
| | | | | | | | | | | | Make sure that SmudgeFilter calls LfsPointer.parseLfsPointer() with a stream that supports mark/reset, and make sure that parseLfsPointer() resets the stream properly if it decides that the stream content is not a LFS pointer. Add a test. Bug: 570758 Change-Id: I2593d67cff31b2dfdfaaa48e437331f0ed877915 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* LFSPointerTest: suppress errorprone error [SelfComparison]Matthias Sohn2021-02-041-0/+1
| | | | | | | | The test #testCompareToSame tests comparing against self intentionally. Suppress the error raised by errorprone. Change-Id: If8d70a51ab34ffb6d7f0c9d409746aee8b031408 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LFS: make pointer parsing more robustThomas Wolf2021-01-311-3/+266
| | | | | | | | | | | | | | | | | Parsing an LFS pointer must check the input more to not run into exceptions. LfsPoint.parseLfsPointer() is used in various places to determine whether a blob is a LFS pointer; it is not only called with valid LFS pointers. Tighten the validations and return null if they fail. All callers already do check for a null return value. Also, LfsPointer implemented Comparable but did not override equals(). This is rather unusual and actually warned against in the javadoc of Comparable. Implement equals() and hashCode(). Add more tests. Bug: 570744 Change-Id: I90ca264d0a250275cf1907e9dcfcee5eab80df0f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Update EDL 1.0 license headers to new short SPDX compliant formatMatthias Sohn2020-01-045-190/+25
| | | | | | | | | | This is the format given by the Eclipse legal doc generator [1]. [1] https://www.eclipse.org/projects/tools/documentation.php?id=technology.jgit Bug: 548298 Change-Id: I8d8cabc998ba1b083e3f0906a8d558d391ffb6c4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8David Pursehouse2018-09-301-2/+2
| | | | | Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8David Pursehouse2018-09-041-3/+3
| | | | | Change-Id: I3b748620f067582afef20f144feebe40d0332be2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8David Pursehouse2018-03-111-2/+2
| | | | | Change-Id: I6714fc3666e1bced22abba94ceb700477349586e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LongObjectIdTest: Open OutputStreamWriter in try-with-resourceDavid Pursehouse2018-03-071-7/+9
| | | | | Change-Id: Ic7c2109204f94c70b933191b46d4a8f2c16a1533 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LFSPointerTest: Open ByteArrayOutputStream in try-with-resourceDavid Pursehouse2018-03-031-6/+7
| | | | | Change-Id: Ib15a838e735f8b960e0ed635d6d9b0caf97f4791 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Use constants from StandardCharsets instead of hard-coded stringsDavid Pursehouse2017-12-072-4/+4
| | | | | | | | | | | | | | | | 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>
* Suppress "Unlikely argument type for equals()" warnings in testsDavid Pursehouse2017-11-061-0/+1
| | | | | | | | | | | | | | | | | | | This new warning was introduced in Eclipse 4.7 Oxygen [1]. The only instances of the warning are in test code that is asserting that some class does not compare equal to Strings. As in the Gerrit project [2] these asserts are arguably overkill, but arguably also a reasonable test of an equals implementation. Ignore the warning in these cases. Note that if the project is opened in an earlier version of Eclipse, a warning "Unsupported @SuppressWarnings" will be emitted. [1] https://www.eclipse.org/eclipse/news/4.7/M6/ [2] https://gerrit-review.googlesource.com/#/c/gerrit/+/110339/ Change-Id: I08ea33d71e6009cf0f37e6492a475931f447256b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LongObjectIdTest: Add back self comparison testDavid Pursehouse2017-08-181-0/+2
| | | | | | | | | | | | | The test was removed in 4886621 to prevent a warning from error-prone. Add it back but rewrite it in a way that does not cause the warning. This reverts commit 4886621261c3b5fa2d9c75fd72d19ac186c9f970. Change-Id: Id3994e2d882a9d08bf548b7778406f8a80fbf830 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LongObjectIdTest: Remove self comparison testDavid Ostrovsky2017-03-181-1/+0
| | | | | | | | | | | | This fixes test flagged by error prone: LongObjectIdTest.java:294: error: [SelfComparison] An object is compared to itself assertEquals(0, id1.compareTo(id1)); Change-Id: Ife339c92b9570db2471a2fc029b3bfa114044790 Signed-off-by: David Ostrovsky <david@ostrovsky.org>
* 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>
* Add LfsPointerFilter TreeFilterDariusz Luksza2017-01-101-0/+214
| | | | | | | | | | | | | | | 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>
* Fix encoding of LFSPointer filesChristian Halstrick2016-11-241-0/+71
| | | | | | | | | | 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
* Implement SHA-256 abstractionMatthias Sohn2016-02-043-0/+1115
The Large File Storage extension specified by GitHub [1] uses SHA-256 to compute the ID of large files stored by the extension. Hence implement a SHA-256 abstraction similar to the SHA-1 abstraction used by JGit. [1] https://git-lfs.github.com/ Bug: 470333 Change-Id: I3a95954543c8570d73929e55f4a884b55dbf1b7a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>