summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
Commit message (Collapse)AuthorAgeFilesLines
* Introduce new RawText constructor and RawParseUtils.lineMapOrBinaryHan-Wen Nienhuys2018-05-122-2/+26
| | | | | | | | | | | This makes binary detection exact in ResolveMerger and DiffFormatter This has the same intention as Id4342a199628d9406bfa04af1b023c27a47d4014 but preserves backward compatibility of the signature of RawParseUtils.lineMap. Change-Id: Ia24a4e716592bab3363ae24e3a46315a7511154f Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Mark CrissCrossMergeTest as flakyJonathan Nieder2018-05-081-0/+5
| | | | | | | | | | | | It often fails on my machine, both in maven and bazel. This patch marks the test flaky[1] in bazel so that "bazel test" can run it a few times before declaring failure. [1] https://docs.bazel.build/versions/master/be/common-definitions.html#test.flaky Bug: 534285 Change-Id: Ibe5414fefbffe4e8f86af7047608d51cf5df5c47
* Remove trivial cases of using deprecated RefDatabase.getRefs()Matthias Sohn2018-04-251-3/+3
| | | | Change-Id: I2d3e426a3391923f8a690ac68fcc33851f3eb419 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Suppress boxing warningMatthias Sohn2018-04-251-0/+1
| | | | Change-Id: I90226674320841774ad691c84609e3fe71bf7852 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Remove unnecessary semicolonMatthias Sohn2018-04-251-1/+1
| | | | Change-Id: I3677ecb106ade209e756cec2c6f4232a416bfb44 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Remove unused code and link to deprecated codeJonathan Tan2018-04-251-20/+1
| | | | | | | Eclipse reports these as errors, so remove them. Change-Id: Ic53d8003f9faef38fe776af5a73794e7bb1dfc49 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* Teach UploadPack "no-progress" in "fetch"Jonathan Tan2018-04-231-0/+42
| | | | | | | | Add support for the "no-progress" parameter in the "fetch" command in the fetch-pack/upload-pack protocol v2. Change-Id: I6a6d6b1534f44845254b81d0e1f5c4ba2ac3d10b Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* Teach UploadPack "thin-pack" in "fetch"Jonathan Tan2018-04-231-0/+31
| | | | | | | | Add support for the "thin-pack" parameter in the "fetch" command in the fetch-pack/upload-pack protocol v2. Change-Id: I39a37b2b66a16929137d35c718a3acf2afb6b0b5 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* Teach UploadPack basic "fetch" commandJonathan Tan2018-04-231-2/+258
| | | | | | | | | | | | | | | | | | | | Add basic support for the "fetch" command in the fetch-pack/upload-pack protocol v2. This patch teaches "have" and "done". The protocol specification (Documentation/technical/protocol-v2.txt in the Git project) states: want <oid> Indicates to the server an object which the client wants to retrieve. Wants can be anything and are not limited to advertised objects. It is unspecified whether the server should respect the uploadpack.allowtipsha1inwant option etc. when serving packfiles. This patch is conservative in that the server respects them. Change-Id: I3dbec172239712ef9286a15b8407e86b87ea7863 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* Teach UploadPack "ref-prefix" in "ls-refs"Jonathan Tan2018-04-231-0/+39
| | | | | | | | Add support for the "ref-prefix" parameter in the "ls-refs" command in the fetch-pack/upload-pack protocol v2. Change-Id: If9cf93b2646f75d50a11b5f482594f014d59a836 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* Implement ls-refs in UploadPackJonathan Tan2018-04-231-0/+81
| | | | | | | | | | | | | Implement support for Git protocol v2's "ls-refs" command and its "symrefs" and "peel" parameters. This adds support for this command to UploadPack but the git://, ssh://, and git:// transports do not make use of it yet. That will have to wait for later patches. Change-Id: I8abc6bcc6ed4a88c165677ff1245625aca01267b Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
* Implement protocol v2 with no capabilities in UploadPackJonathan Tan2018-04-201-0/+64
| | | | | | | | | | | | | | | | | | Add initial support for protocol v2 of the fetch-pack/upload-pack protocol. This protocol is described in the Git project in "Documentation/technical/protocol-v2.txt". This patch adds support for protocol v2 (without any capabilities) to UploadPack. Adaptations of callers to make use of this support will come in subsequent patches. [jn: split from a larger patch; tweaked the API to make UploadPack handle parsing the extra parameters and config instead of requiring each caller to do such parsing] Change-Id: I79399fa0dce533fdc8c1dbb6756748818cee45b0 Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
* PacketLineIn, PacketLineOut: Add support for delim-pktJonathan Tan2018-04-202-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most pkt-lines (data-pkts) have the form pkt-len pkt-payload where pkt-len is a string of 4 hexadecimal digits representing the size in bytes of the pkt-line. Since this size includes the size of the pkt-len, no data-pkt has a length less than 4. A pkt-line with a length field less than 4 can thus be used for other purposes. In Git protocol v1, the only such pkt-line was flush-pkt = "0000" which was used to mark the end of a stream. Protocol v2 (see Documentation/technical/protocol-v2.txt in git.git) introduces a second special pkt-line type: delim-pkt = "0001" used to mark the end of a section within a stream, for example to separate capabilities from the content of a command. [jn: split out from a larger patch that made use of this support] Change-Id: I10e7824fa24ed74c4f45624bd490bba978cf5c34 Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
* Add RefDatabase#getRefsByPrefix methodJonathan Tan2018-04-201-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | The existing RefDatabase#getRefs abstract method (to be implemented by ref database backends) has the following issues: - It returns a map with a key (the name of the ref with the prefix removed) which is potentially superfluous (it can be derived by the caller if need be) and confusing (in that the prefix is removed). - The prefix is required to end with a '/', but some backends (e.g. reftable) have fast search by prefix regardless of what the last character of the prefix is. Add a new method #getRefsByPrefix that does not have these issues. This is non-abstract with a default implementation that uses #getRefs (for backwards compatibility), but ref database backends can reimplement it. This also prepares for supporting "ref-prefix" in the "ls-refs" command in the fetch-pack/upload-pack protocol v2, which does not require that the prefix end with a '/'. Change-Id: I4c92f852e8c1558095dd460b5fd7b602c1d82df1 Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
* Handle Gerrit Change-Ids for merge commitsThomas Wolf2018-04-181-15/+57
| | | | | | | | Otherwise successful, non-conflicting merges will never get a Gerrit Change-Id. Bug: 358206 Change-Id: I9b599ad01d9f7332200c1d81a1ba6ce5ef990ab5 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Merge "Push: Ensure ref updates are processed in input order"David Pursehouse2018-04-131-1/+59
|\
| * Push: Ensure ref updates are processed in input orderDave Borowitz2018-04-131-1/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various places on the client side of the push were creating unordered maps and sets of ref names, resulting in ReceivePack processing commands in an order other than what the client provided. This is normally not problematic for clients, who don't typically care about the order in which ref updates are applied to the storage layer. However, it does make it difficult to write deterministic tests of ReceivePack or hooks whose output depends on the order in which commands are processed, for example if informational per-ref messages are written to a sideband.[1] Add a test that ensures the ordering of commands both internally in ReceivePack and in the output PushResult. [1] Real-world example: https://gerrit-review.googlesource.com/c/gerrit/+/171871/1/javatests/com/google/gerrit/acceptance/git/PushPermissionsIT.java#149 Change-Id: I7f1254b4ebf202d4dcfc8e59d7120427542d0d9e
* | Allow '@' as last character of refChristian Halstrick2018-04-121-0/+2
|/ | | | | | | Previously @ was allowed e.g. in branch names, but not as the last character. The case that @ is the last character was not handled. Change-Id: Ic33870b22236f7a5ec7b54007f1b0cefd9354bfb
* Significantly speed up FileTreeIterator on WindowsThomas Wolf2018-03-251-0/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Getting attributes of files on Windows is an expensive operation. Windows stores file attributes in the directory, so they are basically available "for free" when a directory is listed. The implementation of Java's Files.walkFileTree() takes advantage of that (at least in the OpenJDK implementation for Windows) and provides the attributes from the directory to a FileVisitor. Using Files.walkFileTree() with a maximum depth of 1 is thus a good approach on Windows to get both the file names and the attributes in one go. In my tests, this gives a significant speed-up of FileTreeIterator over the "normal" way: using File.listFiles() and then reading the attributes of each file individually. The speed-up is hard to quantify exactly, but in my tests I've observed consistently 30-40% for staging 500 files one after another, each individually, and up to 50% for individual TreeWalks with a FileTreeIterator. On Unix, this technique is detrimental. Unix stores file attributes differently, and getting attributes of individual files is not costly. On Unix, the old way of doing a listFiles() and getting individual attributes (both native operations) is about three times faster than using walkFileTree, which is implemented in Java. Therefore, move the operation to FS/FS_Win32 and call it from FileTreeIterator, so that we can have different implementations depending on the file system. A little performance test program is included as a JUnit test (to be run manually). While this does speed up things on Windows, it doesn't solve the basic problem of bug 532300: the iterator always gets the full directory listing and the attributes of all files, and the more files there are the longer that takes. Bug: 532300 Change-Id: Ic5facb871c725256c2324b0d97b95e6efc33282a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Rename RecursiveMergerTest and ResolveMergerTest to reduce confusionDavid Pursehouse2018-03-242-2/+2
| | | | | | | | | | | | | | | | The class names imply that RecursiveMergerTest tests the RecursiveMerger and ResolveMergerTest tests the ResolveMerger. In fact, both of them include coverage of both strategies; the difference is that RecursiveMergerTest is only testing criss-cross merges. The tests cannot be combined into a single class because the criss-cross test methods have additional data points. Instead, rename the classes to more meaningful names. Change-Id: I7ca8a03a3b7e351e2d4fcaca3b3186c098a3ca66 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* ResolveMergerTest: Use @DataPoints instead of @DataPointDavid Pursehouse2018-03-241-6/+4
| | | | | | | | | | | Define strategiesUnderTest as an array of MergeStrategy using the @DataPoints annotation, rather than two separate variables each annotated as @DataPoint. This makes the implementation consistent with RecursiveMergerTest. Change-Id: I9f1d525b38cb59634ba054c7779dc4af1fc46e25 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* UploadPackTest: Fix name hiding introduced by If72b4b422David Pursehouse2018-03-201-26/+26
| | | | | | | | The local variable 'remote' hides the class scope variable of the same name. Change-Id: I7410c33678677ce2a14691772466d91e8139e3fa Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Merge branch 'stable-4.11'David Pursehouse2018-03-161-2/+10
|\ | | | | | | | | | | | | | | * stable-4.11: ObjectIdSerializer: Support serialization of known non-null ObjectId Change-Id: Ie430fa2c5d13ae698d884a37d0d03884ebbf25ec Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
| * ObjectIdSerializer: Support serialization of known non-null ObjectIdDavid Pursehouse2018-03-151-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation of ObjectIdSerializer, added in change I7599cf8bd, is not equivalent to the original implementation in Gerrit [1]. The Gerrit implementation provides separate methods to (de)serialize instances of ObjectId that are known to be non-null. In these methods, no "marker" is written to the stream. Replacing Gerrit's implementation with ObjectIdSerializer [2] broke persistent caches because it started writing markers where they were not expected [3]. Since ObjectIdSerializer is included in JGit 4.11 we can't change the existing #write and #read methods. Keep those as-is, but extend the Javadoc to clarify that they support possibly null ObjectId instances. Add new methods #writeWithoutMarker and #readWithoutMarker to support the cases where the ObjectId is known to be non-null and the marker should not be written to the serialization stream. Also: - Replace the hard-coded `0` and `1` markers with constants that can be linked from the Javadocs. - Include the marker value in the "Invalid flag before ObjectId" exception message. [1] https://gerrit-review.googlesource.com/c/gerrit/+/9792 [2] https://gerrit-review.googlesource.com/c/gerrit/+/165851 [3] https://gerrit-review.googlesource.com/c/gerrit/+/165952 Change-Id: Iaf84c3ec32ecf83efffb306fdb4940cc85740f3f Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Teach UploadPack to support filtering by blob sizeJonathan Tan2018-03-151-0/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Teach UploadPack to advertise the filter capability and support a "filter" line in the request, accepting blob sizes only, if the configuration variable "uploadpack.allowfilter" is true. This feature is currently in the "master" branch of Git, and as of the time of writing, this feature is to be released in Git 2.17. This is incomplete in that the filter-by-sparse-specification feature also supported by Git is not included in this patch. If a JGit server were to be patched with this commit, and a repository on that server configured with RequestPolicy.ANY or RequestPolicy.REACHABLE_COMMIT_TIP, a Git client built from the "master" branch would be able to perform a partial clone. Change-Id: If72b4b422c06ab432137e9e5272d353b14b73259 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* | RepoCommandSymlinkTest#testLinkFileBare: Use try-with-resourceDavid Pursehouse2018-03-151-34/+36
| | | | | | | | | | Change-Id: I72756d92dc5ea54ad009dddb9cebbcd6d1a0b4f8 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | RepoCommandTest: Refactor to use try-with-resourceDavid Pursehouse2018-03-151-395/+373
| | | | | | | | | | Change-Id: If37ce4447feb431169a75594194a7ef02e362d4e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | ReceivePackAdvertiseRefsHookTest#testSuccess: Open TransportLocal in t-w-rDavid Pursehouse2018-03-151-17/+19
| | | | | | | | | | Change-Id: I198ff2ff36de482445141b5ce489204a9c2f4933 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | AutoLFInputStreamTest: Use try-with-resourceDavid Pursehouse2018-03-141-25/+28
| | | | | | | | | | Change-Id: I162bfa6b2f87f2ce9154f3ed6bb628c4cda88f50 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Use CHARSET in FileOutputStream instead of hard-coded "UTF-8"David Pursehouse2018-03-132-2/+4
| | | | | | | | | | Change-Id: I63ad25e1ebd94081c8848f4d21044cf9041f971d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | TemporaryBufferTest: Suppress "should be managed by try-with-resource"David Pursehouse2018-03-131-1/+12
| | | | | | | | | | | | | | | | | | | | In most of the tests, the temporary buffer is explicitly destroyed in a finally block after being closed. This is not possible if using the try-with-resource construct, because the variable is not accessible in the finally block scope. Change-Id: I3bab30695ddd12e1a0ae107989638428fe3ef551 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Open auto-closeable resources in try-with-resourceDavid Pursehouse2018-03-1325-450/+372
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an auto-closeable resources is not opened in try-with-resource, the warning "should be managed by try-with-resource" is emitted by Eclipse. Fix the ones that can be silenced simply by moving the declaration of the variable into a try-with-resource. In cases where we explicitly call the close() method, for example in tests where we are testing specific behavior caused by the close(), suppress the warning. Leave the ones that will require more significant refcactoring to fix. They can be done in separate commits that can be reviewed and tested in isolation. Change-Id: I9682cd20fb15167d3c7f9027cecdc82bc50b83c4 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Implement --force option in FetchCommand and CLI fetch commandMatthias Sohn2018-03-131-0/+19
| | | | | | | | Change-Id: I42cdb57b8fb54ce466d1958391f12f911045327f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8David Pursehouse2018-03-1128-200/+200
| | | | | | | | | | Change-Id: I6714fc3666e1bced22abba94ceb700477349586e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Remove deprecated IgnoreNode#isIgnored methodMatthias Sohn2018-03-101-14/+0
| | | | | | | | | | | | Parameter negateFirstMatch is not honored anymore Change-Id: Idff1a92643c1431c7e34a7730f8414135e1ac196 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Fix misspelled class name: EmtpyCommitException -> EmptyCommitExceptionDavid Pursehouse2018-03-101-3/+3
| | | | | | | | | | Change-Id: I55196020146f26951988988c14ac9a6f85061ae2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Remove deprecated ArchiveCommand#putEntry methodMatthias Sohn2018-03-091-5/+0
| | | | | | | | | | | | | | Use #putEntry(Closeable, ObjectId, String, FileMode, ObjectLoader)} instead. Change-Id: I2c58c07da00c6033c583eb2dc6c3a0889661f5f5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Prepare 5.0.0-SNAPSHOT buildsMatthias Sohn2018-03-082-47/+47
|/ | | | | Change-Id: I2d2f50ed8a12f310e7cac68eed5536bd460c403f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Prepare 4.11.1-SNAPSHOT buildsMatthias Sohn2018-03-082-47/+47
| | | | | Change-Id: Id9aa6b7e8f56de5183b6cd57ef0e790ec9debd4d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* JGit v4.11.0.201803080745-rv4.11.0.201803080745-rMatthias Sohn2018-03-082-2/+2
| | | | | Change-Id: Ie24a33bc8a24c30db06fe7b175f405efb95776ec Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix DiffFormatter for diffs against working tree with autocrlf=trueThomas Wolf2018-03-071-0/+98
| | | | | | | | | | | | | | The WorkingTreeSource produced an ObjectLoader that returned inconsistent sizes: the file size in getSize(), but then a correctly filtered smaller stream in openStream(). This resulted either in an IOE "short read of block" or in an EOFException depending on the resulting filtered size. Fix this by ensuring that getSize() does return the size of the filtered stream. Bug: 530106 Change-Id: I7c7c85036047dc10030ed29c1d5a6c7f34f2bdff Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* MergeHeadMsgTest: Open FileOutputStream in try-with-resourceDavid Pursehouse2018-03-071-15/+7
| | | | | Change-Id: I8efa549b98bf661665dc29d48d0e5661b0e8530c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Use StandardCharsets.UTF_8 in testsDavid Pursehouse2018-03-075-6/+8
| | | | | | | Replace hard-coded "UTF-8" string with the constant. Change-Id: Ie812add2df28e984090563ec7c6e2c0366616424 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* IndexDiffWithSymlinkTest: Open InputStream in try-with-resourceDavid Pursehouse2018-03-071-6/+4
| | | | | Change-Id: I5f49f80debb2259f665748408cd3604f869fa3ef Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* HugeFileTest: Open RandomAccessFile in try-with-resourceDavid Pursehouse2018-03-071-23/+23
| | | | | Change-Id: Iecb9a7348b40c91fa45c051c2a9c4eb47e4bdeca Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* GetTextTest: Open InputStream in try-with-resourceDavid Pursehouse2018-03-061-16/+10
| | | | | Change-Id: I3b68686de2d852b1f0b19c267a4e527229b40316 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* FileSnapshotTest: Open FileOutputStream in try-with-resourceDavid Pursehouse2018-03-061-4/+1
| | | | | Change-Id: I187dd61e3e7d6f141722bf1af86a7fe04711057d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* EditListTest: Open InputStream in try-with-resourceDavid Pursehouse2018-03-061-8/+5
| | | | | Change-Id: Ib5b86e332ec674dec5460a9629d94d9f94c31c24 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* EGitPatchHistoryTest: Open BufferedReader in try-with-resourceDavid Pursehouse2018-03-061-19/+19
| | | | | Change-Id: I74aede463c7b0a478a1e0e8b680c206d3964061d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* T0003_BasicTest: Use CommitBuilder.setEncoding(Charset)David Pursehouse2018-03-061-1/+2
| | | | | Change-Id: I1c4cdd4b856d715a204030d2de25ef91977186c2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>