summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Remove 'final' in parameter listsHan-Wen Nienhuys2018-05-15384-1357/+1357
| | | | | Change-Id: Id924f79c8b2c720297ebc49bf9c5d4ddd6d52547 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* Fixup javadoc and formatting in RawText and RawParseUtilsHan-Wen Nienhuys2018-05-142-25/+30
| | | | | Change-Id: I9d6002941a33ec204d29e4fd920dde965387bb24 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* RawParseUtils#lineMap: Simplify by using null sentinel internallyJonathan Nieder2018-05-141-13/+11
| | | | | | | | | | Add an internal lineMapOrNull helper that returns null when the file is binary. This is simpler than using an exception for control flow and avoids having to override fillInStackTrace to avoid a performance regression. Change-Id: Ib8bb8df6a6bbd60c62cfb3b4c484a962a98b7507
* Store in IndexChangedEvent if it was caused by JGit itselfMatthias Sohn2018-05-135-18/+52
| | | | | | | This allows to differentiate if index was changed by an external git command or by JGit itself. Change-Id: Iae692ba7d9bf01a288b3fb2dc2d07aec9891c712 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Introduce new RawText constructor and RawParseUtils.lineMapOrBinaryHan-Wen Nienhuys2018-05-124-11/+83
| | | | | | | | | | | 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>
* Use a secure random generator to seed nonce for digest authenticationMatthias Sohn2018-05-111-2/+2
| | | | | | | | | | | | | https://tools.ietf.org/html/rfc7616 says: 5.12. Parameter Randomness The security of this protocol is critically dependent on the randomness of the randomly chosen parameters, such as client and server nonces. These should be generated by a strong random or properly seeded pseudorandom source (see [RFC4086]). Change-Id: I4da5316cb1eb3f59ae06c070ce1c3335e9ee87d6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge branch 'stable-4.11'Matthias Sohn2018-05-103-30/+56
|\ | | | | | | | | | | | | | | * stable-4.11: Retry stale file handles on .git/config file Change-Id: I4fe6152c3c40dde9cb88913cc9706852de0fd712 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Merge branch 'stable-4.10' into stable-4.11Matthias Sohn2018-05-103-30/+56
| |\ | | | | | | | | | | | | | | | | | | * stable-4.10: Retry stale file handles on .git/config file Change-Id: Ice5c8ae8c2992243a81da77e166406bc1930fe0e
| | * Merge branch 'stable-4.9' into stable-4.10Matthias Sohn2018-05-103-30/+56
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.9: Retry stale file handles on .git/config file Change-Id: I6db7256dbd1c71b23e1231809642ca21e996e066 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * Merge branch 'stable-4.8' into stable-4.9Matthias Sohn2018-05-103-31/+56
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.8: Retry stale file handles on .git/config file Change-Id: Ib029b5536c038190626e7a7ff43b70f0a5673721
| | | | * Merge branch 'stable-4.7' into stable-4.8Matthias Sohn2018-05-103-31/+56
| | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.7: Retry stale file handles on .git/config file Change-Id: Ib665c094b28eefb8236752bb273de0c2d9bf9578
| | | | | * Merge branch 'stable-4.6' into stable-4.7Matthias Sohn2018-05-103-31/+56
| | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.6: Retry stale file handles on .git/config file Change-Id: If5a21d38224528edfc551b3216daca6a2582e3ac
| | | | | | * Merge branch 'stable-4.5' into stable-4.6Matthias Sohn2018-05-103-31/+56
| | | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.5: Retry stale file handles on .git/config file Change-Id: Ib6e6ec0846c3ef261ec1016bfa6d26d2eadc3f26
| | | | | | | * Retry stale file handles on .git/config fileNasser Grainawi2018-05-103-31/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On a local non-NFS filesystem the .git/config file will be orphaned if it is replaced by a new process while the current process is reading the old file. The current process successfully continues to read the orphaned file until it closes the file handle. Since NFS servers do not keep track of open files, instead of orphaning the old .git/config file, such a replacement on an NFS filesystem will instead cause the old file to be garbage collected (deleted). A stale file handle exception will be raised on NFS clients if the file is garbage collected (deleted) on the server while it is being read. Since we no longer have access to the old file in these cases, the previous code would just fail. However, in these cases, reopening the file and rereading it will succeed (since it will open the new replacement file). Since retrying the read is a viable strategy to deal with stale file handles on the .git/config file, implement such a strategy. Since it is possible that the .git/config file could be replaced again while rereading it, loop on stale file handle exceptions, up to 5 extra times, trying to read the .git/config file again, until we either read the new file, or find that the file no longer exists. The limit of 5 is arbitrary, and provides a safe upper bounds to prevent infinite loops consuming resources in a potential unforeseen persistent error condition. Change-Id: I6901157b9dfdbd3013360ebe3eb40af147a8c626 Signed-off-by: Nasser Grainawi <nasser@codeaurora.org> 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
* | | | | | | | Merge "Add API filter for "non-API type FileRepository" in tests"Matthias Sohn2018-05-051-0/+35
|\ \ \ \ \ \ \ \
| * | | | | | | | Add API filter for "non-API type FileRepository" in testsDavid Pursehouse2018-05-061-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: If805ad4a962e48dd16fbc7eff915fd6539839933 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | | | Replace http://errorprone.info with https://errorprone.infoJonathan Nieder2018-05-041-1/+1
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That site serves from https now. Reported-by: Nicholas Glorioso <glorioso@google.com> Change-Id: I2150a18425a1fe3ab5a022882ffe06ccbde17f16 Signed-off-by: Jonathan Nieder <jrn@google.com>
* | | | | | | | Bazel: Add a target to build jgit commandline toolJonathan Nieder2018-05-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This works well enough for basic testing, especially the "jgit daemon" command: $ bazel build org.eclipse.jgit.pgm:jgit INFO: Analysed target //org.eclipse.jgit.pgm:jgit (39 packages loaded). INFO: Found 1 target... Target //org.eclipse.jgit.pgm:jgit up-to-date: bazel-bin/org.eclipse.jgit.pgm/jgit.jar bazel-bin/org.eclipse.jgit.pgm/jgit INFO: Elapsed time: 15.862s, Critical Path: 14.74s INFO: 42 processes: 32 linux-sandbox, 1 local, 9 worker. INFO: Build completed successfully, 60 total actions $ bazel-bin/org.eclipse.jgit.pgm/jgit rev-list HEAD^..HEAD 2>/dev/null e5ed926e02dd29b5e970d421b63b6921cc1800f5 Still to do: - suppress "Failed to load class "org.slf4j.impl.StaticLoggerBinder" output - add org.eclipse.jgit.pgm.test tests to bazel build - supply package information so that "jgit version" can work Change-Id: Ie89872839fa5aae974d5d39b6776b96332b0e83f
* | | | | | | | ssh: Kill the external process when we're done instead of waiting foreverCarsten Pfeiffer2018-05-021-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 529463 Change-Id: Iaf6fe20a1c759ac5e91a2393d7bc40a94f859e84 Signed-off-by: Carsten Pfeiffer <carsten.pfeiffer@gebit.de>
* | | | | | | | Rename RefDatabase#getAllRefs to getRefsJonathan Nieder2018-04-2914-37/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is easier to type and makes it clearer that it only returns refs and not the pseudo-refs returned by getAdditionalRefs. It also puts us in a better position to add a method to the Repository class later that delegates to this one without colliding with the existing Repository#getAllRefs method that returns a Map<String, Ref>. While at it, clarify the javadoc of getRefs and hasRefs to make the same point. Suggested-by: David Pursehouse <david.pursehouse@gmail.com> Change-Id: I23497c66ac7b5e0c987b91efbc9e9cc29924ca66 Signed-off-by: Jonathan Nieder <jrn@google.com>
* | | | | | | | RefDatabase: add hasRefs convenience methodDavid Pursehouse2018-04-292-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Callers can now say: db.getRefDatabase().hasRefs() rather than the more verbose: !db.getRefDatabase().getAllRefs().isEmpty() The default implementation simply uses getAllRefs().isEmpty(), but a derived class could possibly override the method with a more efficient implementation. Change-Id: I5244520708a1a7d9adb351f10e43fc39d98e22a1 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | | Fix comparison order in AnyObjectIdDavid Turner2018-04-271-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous version suggested testing w2 first because w1 was used for hashing, but in fact, hashCode returns w2. The order (w3, w4, w5, w1, w2) might be better on 64-bit processors too, since it allows comparing 64 bits at a time, although perhaps on a modern SIMD processor, the entire 160 bytes would be compared at once anyway. Change-Id: Ieb69606d3c1456aeff36bffe99a71587ea76e977 Signed-off-by: David Turner <dturner@twosigma.com>
* | | | | | | | RefDatabase: Introduce getAllRefs methodDavid Pursehouse2018-04-2714-39/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently to get all refs, callers must use: getRefsByPrefix(ALL) Introduce getAllRefs, which does this, and migrate all existing callers of getRefsByPrefix(ALL). Change-Id: I7b1687c162c8ae836dc7db3ccc7ac847863f691d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | | RefDatabase: Update Javadoc for ALL constantDavid Pursehouse2018-04-271-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Javadoc refers to the deprecated getRefs method. Update it to refer to getRefsByPrefix which is the recommended replacement of getRefs. Change-Id: I61f2abcf1a3794f40a1746317dbc18aa0beb87a7 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | | LargePackedWholeObject#openStream: Suppress resource warningDavid Pursehouse2018-04-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Eclipse warns that DfsReader should be managed by try-with-resource. As described in 1484d6e (LargePackedWholeObject: Do not reuse released inflater, 2018-04-26), the DfsReader is owned and closed by the PackInputStream or explicitly closed in the try block's finally. Suppress the warning with a brief explanatory comment. Change-Id: I4187c935742072f3ee7f2d3551a6a98d40fc2702 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | | LargePackedWholeObject: Do not reuse released inflaterJonathan Nieder2018-04-262-13/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LargePackedWholeObject.openStream produces a stream that allows reading a large object. This stream holds a DfsReader that takes care of caching delta bases etc and in particular holds zlib Inflater for use while reading the each delta in the packfile. At DfsReader creation time, the Inflater is acquired from a global InflaterCache to avoid initialization overhead in case there is an existing Inflater available for reuse. When done with the Inflater, the DfsReader is responsible for returning it to the cache for reuse. The DfsReader is AutoClosable to remind the caller to close it and release the Inflater when finished with it. b0ac5f9c8907a4034612543a92eb465e88a9c6f2 (LargePackedWholeObject: Refactor to open DfsReader in try-with-resource, 2018-04-11) tried to clarify the lifetime of the DfsReader but was too aggressive: when this function returns, PackInputStream owns the DfsReader and is already going to release it. Worse, the returned InflaterInputStream holds a reference to the DfsReader's inflater, making releasing the DfsReader not only unnecessary but unsafe. The Inflater gets released into the InflaterCache's pool, to be acquired by another caller that uses it concurrently with the InflaterInputStream. This results in errors, such as java.util.zip.ZipException: incorrect header check at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164) at java.util.zip.InflaterInputStream.skip(InflaterInputStream.java:208) at java.io.BufferedInputStream.skip(BufferedInputStream.java:377) and java.util.zip.DataFormatException: incorrect header check at java.util.zip.Inflater.inflateBytes(Native Method) at java.util.zip.Inflater.inflate(Inflater.java:259) at org.eclipse.jgit.internal.storage.dfs.DfsReader.inflate(DfsReader.java:783) at org.eclipse.jgit.internal.storage.dfs.DfsPackFile.decompress(DfsPackFile.java:420) at org.eclipse.jgit.internal.storage.dfs.DfsPackFile.load(DfsPackFile.java:767) and Caused by: java.util.zip.ZipException: incorrect header check at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164) at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) at java.io.BufferedInputStream.read1(BufferedInputStream.java:286) at java.io.BufferedInputStream.read(BufferedInputStream.java:345) at org.eclipse.jgit.lib.ObjectStream$Filter.read(ObjectStream.java:219) at org.eclipse.jgit.util.IO.readFully(IO.java:233) at org.eclipse.jgit.transport.PackParser.checkObjectCollision(PackParser.java:1173) Verified in production. It should be possible to make a straightforward unit test for this using the InflaterCache state but that can wait for a followup commit. Change-Id: Iaf1d6fd368b64f76c520d215fd270a6098a1f236
* | | | | | | | Use eclipse compiler in Maven buildMatthias Sohn2018-04-251-57/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found instructions for configuring maven-compiler-plugin with ecj in [1]. Verified that ecj run in this way raises build errors when executed on commit d3ef5213. Define profiles "ecj" for using Eclipse compiler and "javac" for using javac including errorprone. By default ecj will be used. use ecj: $ mvn -Pecj clean install use javac: $ mvn -Pjavac clean install TODO: find out how to run ecj with errorprone from Maven. [1] https://stackoverflow.com/questions/33164976/using-eclipse-java-compiler-ecj-in-maven-builds Change-Id: I716b603b57612b953e603387c82fd01eb1b5ca97 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | | Remove trivial cases of using deprecated RefDatabase.getRefs()Matthias Sohn2018-04-2520-54/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | | | Fix non-externalized String warningsMatthias Sohn2018-04-255-46/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - suppress warning for non-translatable texts - externalize error messages Change-Id: Ieba42219b2c0b51a288f5a60438a6cc4f9dfe641 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | | Remove unused code and link to deprecated codeJonathan Tan2018-04-252-22/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Eclipse reports these as errors, so remove them. Change-Id: Ic53d8003f9faef38fe776af5a73794e7bb1dfc49 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* | | | | | | | File compile and API errors in JGitMichael Keppler2018-04-251-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Photon throws null analysis errors on the repeated invocation of those previously null checked methods. Extract them to a local variable to avoid this. (the null analysis is configured in project properties) * setUseProtocolV2() misses @since tag. Problem was introduced with 332bc611249d21f9b604f2c0207bf0bdfbfc3a78. Might be caused by the long delay of 2 months from creation to merging. Change-Id: Ibbb1a1580b604b8e7cd4bf7edc4643e292b6b4a8 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
* | | | | | | | Merge "Upgrade error_prone_core to 2.3.1"Matthias Sohn2018-04-231-2/+2
|\ \ \ \ \ \ \ \
| * | | | | | | | Upgrade error_prone_core to 2.3.1David Pursehouse2018-04-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and plexus-compiler-javac-errorprone to 2.8.4. Change-Id: I36487ce53e70b54d7a04292e666540224c107b43 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | | | Teach UploadPack "no-progress" in "fetch"Jonathan Tan2018-04-232-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-232-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-233-12/+349
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-232-3/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | | | | UploadPack: Don't buffer ls-refs outputJonathan Nieder2018-04-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Once we have read the user's entire command, there is no more need to buffer our response --- even the strictest servlet engine allows writing output once the input has been consumed. Noticed when the analogous code in the "fetch" command (introduced in a later patch) overflowed its buffer: java.lang.OutOfMemoryError at java.io.ByteArrayOutputStream.hugeCapacity(ByteArrayOutputStream.java:123) [...] at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1905) at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1741) at org.eclipse.jgit.transport.UploadPack.fetchV2(UploadPack.java:1001) at org.eclipse.jgit.transport.UploadPack.serviceV2(UploadPack.java:1030) at org.eclipse.jgit.transport.UploadPack.upload(UploadPack.java:726) at org.eclipse.jgit.http.server.UploadPackServlet.doPost(UploadPackServlet.java:195) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) Change-Id: I33df56f1cb1c6c2c25ee95426cb7ad665134ac6b
* | | | | | | | | Implement ls-refs in UploadPackJonathan Tan2018-04-234-1/+160
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-203-3/+197
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-204-11/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-202-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-182-15/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | | | PushProcess: Remove unused import of HashMapDavid Pursehouse2018-04-161-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 533621 Change-Id: Ie125818d5fc8fef5800108db2ca21151d8d3bfa3 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | | Configure WindowCache settings to use in JGit CLIMatthias Sohn2018-04-131-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set the same defaults as in EGit. Use mmap to map git packfiles into memory. Change-Id: I7997b9123448a762192d7eeb55e01432549fba98 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | | Merge "Push: Ensure ref updates are processed in input order"David Pursehouse2018-04-133-5/+64
|\ \ \ \ \ \ \ \
| * | | | | | | | Push: Ensure ref updates are processed in input orderDave Borowitz2018-04-133-5/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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