aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'stable-7.0' into stable-7.1Matthias Sohn7 days1-6/+6
|\ | | | | | | | | | | | | | | | | | | | | | | * stable-7.0: FileSnapshot: fix warnings Optionally.Hard: avoid Optional creation on every use, Pack: fix threading bug getting idx Fix potential NPE in TreeWalk#getFilterCommandDefinition Advertise "agent" capability when using protocol v2 FileSnapshot: silence "Stale file handle" exceptions Change-Id: I4fdea7450f27eebfa7ae08002fd51e67b58bf6bb
| * Advertise "agent" capability when using protocol v2Antonio Barone13 days1-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "agent" capability was not advertised by the server when executing git-upload-pack over protocol v2. This, in turn, prevented the clients from advertising its client agent too, as documented [1]: "The client may optionally send its own agent string by including the agent capability with a value Y (in the form agent=Y) in its request to the server (but it MUST NOT do so if the server did not advertise the agent capability)." When using jgit with Gerrit this had the effect of preventing the logging of the git client agent in the sshd_log. [1] https://git-scm.com/docs/protocol-v2#_agent Bug: jgit-118 Change-Id: Ifb6ea65fde020425920338f7dd9cc683fed6a4a4
| * Test advertised capabilities with protocol V0 and allow*Sha1InWantpszlazak2024-11-211-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | The advertised capabilities with protocol V0 were untested leading to potential regressions when advertising what SHA1 should or should not be on the list of capabilities. Verify that allow-tip-sha1-in-want and allow-reachable-sha1-in-want are properly advertised with the allow*Sha1InWant is set in jgit.config. Change-Id: Id48af2bc19280f2dcb26aa8e8765cde8f2ce7a06 (cherry picked from commit 5583f6a10eafc8c2627e0fb4833cb8ffe422f69a)
* | UploadPackTest: fix unclosed resource warningMatthias Sohn2024-11-191-4/+4
| | | | | | | | Change-Id: I4efccd72bd567d42e739ee330e26c6b04d5c5c01
* | Test advertised capabilities with protocol V0 and allow*Sha1InWantLuca Milanesio2024-10-121-0/+42
|/ | | | | | | | | | | | The advertised capabilities with protocol V0 were untested leading to potential regressions when advertising what SHA1 should or should not be on the list of capabilities. Verify that allow-tip-sha1-in-want and allow-reachable-sha1-in-want are properly advertised with the allow*Sha1InWant is set in jgit.config. Change-Id: I99d062a5a630b02ca3d1fe83bf6cdf3c284ae941
* [errorprone] Fix UnnecessaryParentheses errorsMatthias Sohn2024-04-281-20/+23
| | | | | | See https://errorprone.info/bugpattern/UnnecessaryParentheses Change-Id: I783fd24286ec1bd55efbf21d05758465f4af87ee
* Use try-with-resource to ensure UploadPack is closedMatthias Sohn2023-11-091-5/+6
| | | | Change-Id: I0d10aeac959a49b3bf2e83b0c104699d1d21f5e9
* Fix hiding field warningMatthias Sohn2023-11-091-4/+4
| | | | Change-Id: I9aced1b711901918667555a4cfff76992024e59c
* UploadPackTest: Cover using wanted-refs as advertised setIvan Frade2023-10-271-0/+62
| | | | | | | | | | | | | Parent change introduced using "wanted-refs" as advertised set during fetchV2, but it tested only a request without wantIds (only wanted-refs). Add a second where the request has wanted-refs AND wantId (which disables the optimization). Change the test to measure the amount of refs considered advertised, instead of relying in calls to the refdb. Change-Id: Id64ec933fd737bae1bfd429c7b8cc05b51a83870
* UploadPack: use want-refs as advertised set in fetch v2Patrick Hiesel2023-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Protocol v2 introduced refs-in-wants and ls-remote with prefixes. UploadPack already uses prefixes provided by the client during a v2 ref advertisement (ls-refs). However, when the client consequently sends another request to fetch a previously advertised ref (with want-ref lines), the server uses the whole set of advertised refs to compute reachability. In repos with many refs, this slows down the reachability checks setting up and walking through unnecessary refs. For gerrit it can also break valid requests because in gerrit "all" means "recent" and the wanted-ref could fall out of the "recent" range when reloading all refs at fetch time. Treat wanted-refs like a ref-prefix when calculating the advertised refs on v2 fetch command. Less refs means a faster setup and less walk for the reachability checks. Note that wanted-refs filters only over the refs visible to the user, so this doesn't give any extra visibility to the caller. If the request contains also "want <oid>" lines, we cannot use this optimization. Those objects could be reachable from any visible branch, not necessarily in the wanted-refs. Google-Bug: b/122888978 Change-Id: I2a4ae171d4fc5d4cb30b020cb073ad23dd5a66c4
* BasePackFetchConnection: Avoid full clone with useNegotiationTipRonald Bhuleskar2023-10-251-2/+65
| | | | | | | | With the useNegotiationTip flag (introduced in change 738dacb), the client sends to the server only the tips of the wanted refs for the negotiation. Some wanted refs may not exist in the client (yet) and our implementation ignores them. So when only non-existing refs are wanted, jgit doesn't send any tips and the server understands it is a full clone. In useNegotiationTip, send ALL_REFS if any of the wanted refs does not exists locally. Change-Id: Ide04c5df785b9212abcd9d3cba194515e0af166f
* Fix all Javadoc warnings and fail on themAntoine Musso2023-06-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes all the javadoc warnings, stops ignoring doclint 'missing' category and fails the build on javadoc warnings for public and protected classes and class members. Since javadoc doesn't allow access specifiers when specifying doclint configuration we cannot set `-Xdoclint:all,-missing/private` hence there is no simple way to skip private elements from doclint. Therefore we check javadoc using the Eclipse Java compiler (which is used by default) and javadoc configuration in `.settings/org.eclipse.jdt.core.prefs` files. This allows more fine grained configuration. We can reconsider this when javadoc starts supporting access specifiers in the doclint configuration. Below are detailled explanations for most modifications. @inheritDoc =========== doclint complains about explicits `{@inheritDoc}` when the parent does not have any documentation. As far as I can tell, javadoc defaults to inherit comments and should only be used when one wants to append extra documentation from the parent. Given the parent has no documentation, remove those usages which doclint complains about. In some case I have moved up the documentation from the concrete class up to the abstract class. Remove `{@inheritDoc}` on overriden methods which don't add additional documentation since javadoc defaults to inherit javadoc of overridden methods. @value to @link =============== In PackConfig, DEFAULT_SEARCH_FOR_REUSE_TIMEOUT and similar are forged from Integer.MAX_VALUE and are thus not considered constants (I guess cause the value would depends on the platform). Replace it with a link to `Integer.MAX_VALUE`. In `StringUtils.toBoolean`, @value was used to refer to the `stringValue` parameter. I have replaced it with `{@code stringValue}`. {@link <url>} to <a> ==================== @link does not support being given an external URL. Replaces them with HTML `<a>`. @since: being invalid ===================== org.eclipse.jgit/src/org/eclipse/jgit/util/Equality.java has an invalid tag `@since: ` due to the extra `:`. Javadoc does not complain about it with version 11.0.18+10 but does with 11.0.19.7. It is invalid regardless. invalid HTML syntax =================== - javadoc doesn't allow <br/>, <p/> and </p> anymore, use <br> and <p> instead - replace <tt>code</tt> by {@code code} - <table> tags don't allow summary attribute, specify caption as <caption>caption</caption> to fix this doclint visibility issue ======================== In the private abstract classes `BaseDirCacheEditor` and `BasePackConnection` links to other methods in the abstract class are inherited in the public subclasses but doclint gets confused and considers them unreachable. The HTML documentation for the sub classes shows the relative links in the sub classes, so it is all correct. It must be a bug somewhere in javadoc. Mute those warnings with: @SuppressWarnings("doclint:missing") Misc ==== Replace `<` and `>` with HTML encoded entities (`&lt; and `&gt;`). In `SshConstants` I went enclosing a serie of -> arrows in @literal. Additional tags =============== Configure maven-javad0c-plugin to allow the following additional tags defined in https://openjdk.org/jeps/8068562: - apiNote - implSpec - implNote Missing javadoc =============== Add missing @params and descriptions Change-Id: I840056389aa59135cfb360da0d5e40463ce35bd0 Also-By: Matthias Sohn <matthias.sohn@sap.com>
* Merge branch 'stable-6.5'Matthias Sohn2023-04-281-0/+69
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-6.5: [bazel] Move ToolTestCase to src folder (6.2) GcConcurrentTest: @Ignore flaky testInterruptGc Fix CommitTemplateConfigTest Fix after_open config and Snapshotting RefDir tests to work with bazel [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory Demote severity of some error prone bug patterns to warnings Parse pull.rebase=preserve as alias for pull.rebase=merges UploadPack: Fix NPE when traversing a tag chain Change-Id: I16e8553d187a8ef541f578291f47fc39c3da4ac0
| * Merge branch 'stable-6.4' into stable-6.5Matthias Sohn2023-04-271-0/+69
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-6.4: [bazel] Move ToolTestCase to src folder (6.2) GcConcurrentTest: @Ignore flaky testInterruptGc Fix CommitTemplateConfigTest Fix after_open config and Snapshotting RefDir tests to work with bazel [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory Demote severity of some error prone bug patterns to warnings UploadPack: Fix NPE when traversing a tag chain Change-Id: I6d20fea3a417e4361b61e81756253343668eb5de
| | * Merge branch 'stable-6.3' into stable-6.4Matthias Sohn2023-04-271-0/+69
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-6.3: [bazel] Move ToolTestCase to src folder (6.2) GcConcurrentTest: @Ignore flaky testInterruptGc Fix CommitTemplateConfigTest Fix after_open config and Snapshotting RefDir tests to work with bazel [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory Demote severity of some error prone bug patterns to warnings UploadPack: Fix NPE when traversing a tag chain Change-Id: I463f8528e623316add204848d551c44d44d04858
| | | * UploadPack: Fix NPE when traversing a tag chainKaushik Lingarkar2023-04-211-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Always parse RevTags including their body before getting their object to ensure that non-cached objects are handled correctly when traversing a tag chain. An NPE in UploadPack#addTagChain will occur on a depth=1 fetch of a branch containing a tag chain and the ref to one of the middle tags in the chain is deleted. Change-Id: Ifd8fe868869070b365df926fec5dcd8e64d4f521 Signed-off-by: Kaushik Lingarkar <quic_kaushikl@quicinc.com>
* | | | BasePackFetchConnection: support negotiationTip featureRonald Bhuleskar2023-03-281-0/+232
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, Git will report, to the server, commits reachable from all local refs to find common commits in an attempt to reduce the size of the to-be-received packfile. If specified with negotiation tip, Git will only report commits reachable from the given tips. This is useful to speed up fetches when the user knows which local ref is likely to have commits in common with the upstream ref being fetched. When negotation-tip is on, use the wanted refs instead of all refs as source of the "have" list to send. This is controlled by the `fetch.usenegotationtip` flag, false by default. This works only for programmatic fetches and there is no support for it yet in the CLI. Change-Id: I19f8fe48889bfe0ece7cdf78019b678ede5c6a32
* | | UploadPack: use allow-any-sha1-in-want configurationkylezhao2023-02-211-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C git 2.11 supports setting the equivalent of RequestPolicy.ANY with uploadpack.allowAnySHA1InWant[1]. Parse this into TransportConfig and use it from UploadPack. Add additional tests for [2] and this change. We can execute "git clone --filter=blob:none --no-checkout" successfully with config uploadPack.allowFilter is true. But when we checkout, the git will fetch other missing objects required by the checkout(this is why we need this config). When both uploadPack.allowFilter and uploadPack.allowAnySHA1InWant are true, jgit will support partial clone. If you are using an extremely large monorepo, this feature can help. It allows users to work on an incomplete repo which reduces disk usage. [1] https://github.com/git/git/commit/f8edeaa05d8623a9f6dad408237496c51101aad8 [2] change Id39771a6e42d8082099acde11249306828a053c0 Bug: 573390 Change-Id: I8fe75f03bf1fea7c11e0d67c8637bd05dd1f9b89 Signed-off-by: kylezhao <kylezhao@tencent.com>
* | | UploadPack: consume delimiter in object-info commandHan-Wen Nienhuys2023-02-021-1/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'size' packet line is an argument, so it must be preceeded by a 0001 delimiter. See also git's t5701-git-serve.sh test, https://github.com/git/git/blob/8b8d9a2/t/t5701-git-serve.sh#L329 Without this fix, the server will choke on the delimiter line, saying PackProtocolException: unexpected <empty string> To test, I ran Gerrit locally with this fix $ curl -X POST -H 'git-protocol: version=2' -H 'content-type: application/x-git-upload-pack-request' -H 'accept: application/x-git-upload-pack-result' --data $'0018command=object-info\n00010009size\n0031oid d38b1b92bdb2893eb4505667375563f2d6d4086b\n0000' http://localhost:8080/git.git/git-upload-pack => 0008size0032d38b1b92bdb2893eb4505667375563f2d6d4086b 268590000 The same command completes identically on Gitlab (which supports the object-info command) $ curl -X POST -H 'git-protocol: version=2' -H 'content-type: application/x-git-upload-pack-request' -H 'accept: application/x-git-upload-pack-result' --data $'0018command=object-info\n00010009size\n0031oid d38b1b92bdb2893eb4505667375563f2d6d4086b\n0000' https://gitlab.com/gitlab-org/git.git/git-upload-pack => 0008size0032d38b1b92bdb2893eb4505667375563f2d6d4086b 268590000 In this case, the blob is for the COPYING file in the Git source tree, which is 26859 bytes long. Change-Id: Ief4ce1eb9303a3b2479547d7950ef01c7c28f472
* | UploadPackTest: ensure UploadPack is closed to fix resource leakMatthias Sohn2022-11-211-37/+43
| | | | | | | | Change-Id: I4c8cf6041b4011934d338138d4531d190fdd6abb
* | UploadPack: Receive and parse client session-idJosh Brown2022-11-021-0/+42
|/ | | | | | | | | | | | | | | | | | | | Before this change JGit did not support the session-id capability implemented by native Git in UploadPack. This change implements advertising the capability from the server and parsing the session-id received from the client during an UploadPack operation. Enable the transfer.advertisesid config setting to advertise the capability from the server. The client may send a session-id capability in response. If received, the value from this is parsed and available via the getClientSID method on the UploadPack object. This change does not add the capability to send a session-id from the JGit client. https://git-scm.com/docs/gitprotocol-capabilities#_session_idsession_id Change-Id: Ib1b6929ff1b3a4528e767925b5e5c44b5d18182f Signed-off-by: Josh Brown <sjoshbrown@google.com>
* Merge branch 'stable-5.13' into stable-6.0Matthias Sohn2022-01-181-0/+55
|\ | | | | | | | | | | | | * stable-5.13: UploadPack v2 protocol: Stop negotiation for orphan refs Change-Id: I6a9ed8338ffbf5363e48d640a2c4209e4e503549
| * Merge branch 'stable-5.12' into stable-5.13Matthias Sohn2022-01-181-0/+55
| |\ | | | | | | | | | | | | | | | | | | * stable-5.12: UploadPack v2 protocol: Stop negotiation for orphan refs Change-Id: Ib43068c32d9cb8effe4b873396391dc3c9197a6e
| | * UploadPack v2 protocol: Stop negotiation for orphan refsMarcin Czech2022-01-181-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fetch of a single orphan ref (for example Gerrit meta ref: refs/changes/21/21/meta) did not stop the negotiation so client had to advertise all refs. This impacts the fetch performance on repositories with a large number of refs (for example on Gerrit repository it takes 20 seconds to fetch meta ref comparing to 1.2 second to fetch ref with parent). To avoid this issue UploadPack, used on the server side, now checks if all `want` refs have parents, if not this means that client doesn't need any extra objects, hence the server responds with `ready` and finishes the negotiation phase. Bug: 577937 Change-Id: Ia3001b400b415d5cf6aae45e72345ca08d3af058
* | | [6.0 API cleanup] Public interface for PackLockThomas Wolf2021-11-231-1/+0
|/ / | | | | | | | | | | | | | | | | | | | | | | Provide a public interface PackLock exposing only the unlock() method. Rename the internal PackLock class to PackLockImpl and have it implement the new interface. This way PackParser doesn't expose an internal class via its API anymore, and client can still unlock pack locks that were created. Bug: 576340 Change-Id: I976739f4ab28fe1f9ba7f35653a69a913aa68841 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | transport: add object-info capabilityBruno Albuquerque2021-08-311-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes it is useful to obtain metadata associated with an object without the need to first download it locally. This is specially useful when using partial clones. This change implements the object-info capability that allows clients to query the remote server for object metadata (currently only size). This is a backport of the same capability that was recently added to the Git project a2ba162cda (object-info: support for retrieving object info, 2021-04-20). Signed-off-by: Bruno Albuquerque <bga@google.com> Change-Id: I4dc9828e1c247f08b0976b8810be92d124366165
* | Teach independent negotiation (no pack file) using an option "wait-for-done"Ronald Bhuleskar2021-06-111-0/+102
|/ | | | | | | | | | | | | | | | | | | | | | | From Git commit 9c1e657a8f: Currently, the packfile negotiation step within a Git fetch cannot be done independent of sending the packfile, even though there is at least one application wherein this is useful - push negotiation. Therefore, make it possible for this negotiation step to be done independently. This feature is for protocol v2 only. In the protocol, the main hindrance towards independent negotiation is that the server can unilaterally decide to send the packfile. This is solved by a "wait-for-done" argument: the server will then wait for the client to say "done". In practice, the client will never say it; instead it will cease requests once it is satisfied. Advertising the server capability option "wait-for-done" is behind the transport config: uploadpack.advertisewaitfordone, which by default is false. Change-Id: I5ebd3e99ad76b8943597216e23ced2ed38eb5224
* Use new protocol version constantsMatthias Sohn2020-11-301-13/+25
| | | | Change-Id: Icd6b876e392c55a7322a990ac7f618250b732b4b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge branch 'stable-5.9'Matthias Sohn2020-11-301-2/+6
|\ | | | | | | | | | | | | * stable-5.9: Add constants for parsing git wire protocol version Change-Id: I1e4174ae8bbefcb71a191dcbf32027d4b35c2b37 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Add constants for parsing git wire protocol versionDavid Ostrovsky2020-11-291-2/+7
| | | | | | | | | | | | | | This would allow other JGit users to access and reuse the constants. Change-Id: I1608802f45586af5f8582afa592e26679e9cebe3 Signed-off-by: David Ostrovsky <david@ostrovsky.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | UploadPackTest#testUploadRedundantBytes: ensure test repo is closedMatthias Sohn2020-10-021-7/+10
| | | | | | | | | | | | This fixes a resource leak warning. Change-Id: I65166eeefc719ea577963c84ce2059e2d7e6c1d7 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Measure time taken for reachability checksAlexa Panfil2020-09-241-11/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | Reason why this change is needed: Getting this metric will help estimate how much time will be saved once the reachability checks get optimized What this patch does: Measure time spent by requestValidator.checkWants() in parseWants() and save it in an instance of PackStatistics.Accumulator. Signed-off-by: Alexa Panfil <alexapizza@google.com> Change-Id: Id7fe4016f96549d9511a2c24052dad93cfbb31a4
* | ReceivePackStats: Add size and count of unnecessary pushed objectsYunjie Li2020-09-111-0/+61
|/ | | | | | | | | | | | Since there is no negotiation for a push, the client is probably sending redundant objects and bytes which already exist in the server. Add more metrics in the stats to quantify it. Duplicated size and number to measure the size and the number of duplicated objects which should not be pushed. Change-Id: Iaacd4761ee9366a0a7ec4e26c508eff45c8744de Signed-off-by: Yunjie Li <yunjieli@google.com>
* Do not send empty blob in response to blob:none filterJonathan Nieder2020-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | If I create a repository containing an empty file and clone it with git clone --no-checkout --filter=blob:none \ https://url/of/repository then I would expect no blobs to be transferred over the wire. Alas, JGit rewrites filter=blob:none to filter=blob:limit=0, so if the repository contains an empty file then the empty blob gets transferred. Fix it by teaching JGit about filters based on object type to complement the existing filters based on object size. This prepares us for other future filters such as object:none. In particular, this means we do not need to look up the size of the filtered blobs, which should speed up clones. Noticed by Anna Pologova and Terry Parker. Change-Id: Id4b234921a190c108d8be2c87f54dcbfa811602a Signed-off-by: Jonathan Nieder <jrn@google.com>
* Add support for tree filters when fetchingJonathan Nieder2020-07-291-0/+32
| | | | | | | | | | | | | | Teach the FilterSpec serialization code about tree filters so they can be communicated over the wire and understood by the server. While we're here, harden the FilterSpec serialization code to throw IllegalStateException if we encounter a FilterSpec that cannot be expressed as a "filter" line. The only public API for creating a Filterspec is to pass in a "filter" line to be parsed, so these should not appear in practice. Change-Id: I9664844059ffbc9c36eb829e2d860f198b9403a0 Signed-off-by: Jonathan Nieder <jrn@google.com>
* UploadPack: Clear advertised ref map after negotiationMinh Thai2020-04-231-0/+78
| | | | | | | | | | | After negotiation phase of a fetch, the advertised ref map is no longer used and can be safely cleared. For >1GiB repos object selection and packfile writing may take 10s of minutes. For the chromium.googlesource.com/chromium/src repo, this advertised ref map is >400MiB. Returning this memory to the Java heap is a major scalability win. Change-Id: I00d453c5ef47630c21f199e333e1cfcf47b7e92a Signed-off-by: Minh Thai <mthai@google.com>
* Replace deprecated junit assertion methods with hamcrestMatthias Sohn2020-01-221-1/+1
| | | | Change-Id: Icebe8071eeefbc13d3bdbc231c568209cdc26195 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Update to Orbit I20200120214610 and JUnit to 4.13David Pursehouse2020-01-221-1/+1
| | | | | | | | | | Since version 4.13 JUnit has an assertThrows method. Remove the implementation in MoreAsserts and use the one from JUnit. CQ: 21439 Change-Id: I086baa94aa3069cebe87c4cbf91ed1534523c6cb Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* UploadPackTest: Fix unused parameter in checkUnadvertisedIfUnallowedDavid Pursehouse2019-11-251-7/+11
| | | | | Change-Id: I6042c401fff55325128d47e7e9098fc7e60d501d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* ProtocolV2Parser: Introduce advertise sideband-all optionIvan Frade2019-10-151-2/+5
| | | | | | | | | | | | | | | | The flag enabling sideband-all is used in two places: in UploadPack for advertisement and in the protocol parser to read it from the request. This leds to problems in distributed deployments where the two requests of a fetch can go to different servers with different configurations. Use the existing allowsidebandall to accept the sideband-all request (and respond to it) and introduce a new "advertisesidebandall" to toggle the advertising of the feature. Change-Id: I892d541bc3f321606c89bad1d333b079dce6b5fa Signed-off-by: Ivan Frade <ifrade@google.com>
* CachedPackUriProvider: Add size to the pack informationIvan Frade2019-10-111-1/+1
| | | | | | | | | | | | The object identifying packfiles to send them via packfile-uri contains only the uri and the hash. This is the information that goes through the wire. It would be useful to know also the size of those packfile, for example to track how many bytes have been offloaded to HTTP. Add size field the CachedPackUriProvider.PackInfo object. Change-Id: If6b921b48a4764d936141c777879b148cc80bbd3 Signed-off-by: Ivan Frade <ifrade@google.com>
* UploadPackTest: Stop using deprecated PacketLineIn constantsDavid Pursehouse2019-10-071-6/+6
| | | | | | | | The DELIM and END constants are deprecated and using them causes warnings. Replace them with the accessor methods. Change-Id: Iadb27000755e8fd8c61d9218591f9d110b8265c8 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* UploadPackTest: Move "reachability" tests to its own fileIvan Frade2019-09-181-97/+0
| | | | | | | | | | | | | | UploadPackTest is already too long and it is covering too many aspects of UploadPack. This makes difficult to see what is tests and if all cases are covered. Move the reachability-related tests to its own file. This moves also an auxiliary function, reducing the length of UploadPack. Complete also the coverage, adding combinations of bitmap availability/commits or blobs/reachable or not. Change-Id: Id5cfc9d0118d997da30e3886c91db996a86250fc Signed-off-by: Ivan Frade <ifrade@google.com>
* UploadPack: support custom packfile-to-URI mappingJonathan Tan2019-08-201-0/+54
| | | | | | | | | | | | | | | | Teach UploadPack to take a provider of URIs corresponding to cached packs. When fetching, if the client supports the packfile-uri feature, and if such a cached pack were to be streamed, instead send the corresponding URI. This packfile-uri feature is implemented in the jt/fetch-cdn-offload branch of Git. There is interest in this feature [1], but it is not yet merged. [1] https://public-inbox.org/git/cover.1552073690.git.jonathantanmy@google.com/ Change-Id: I9a32dae131c9c56ad2ff4a8a9638ae3b5e44dc15 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* UploadPack: move writing of "packfile" headerJonathan Tan2019-07-301-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a subsequent patch, in some cases, PackWriter#writePack will be responsible for both the "packfile-uris" and "packfile" sections, meaning that (in these cases) it must write the "packfile" section header itself. In preparation for that patch, move the writing of the "packfile" section header closer to the invocation of PackWriter#writePack when the entire fetch response is configured to use the sideband. This means that "packfile" is written *after* objects are counted (and progress messages sent to the client in sideband 2) when the "sideband-all" feature is used (whether "packfile-uris" is used or not), and written *before* objects are counted otherwise. Having code to write "packfile" in two places is unfortunate but necessary. When "sideband-all" is not used, object counting has to happen after "packfile" is written, because "packfile" activates the sideband that allows counting progress to be transmitted. When "packfile-uris" is used, object counting has to happen before "packfile" is written, because object counting determines whether to send "packfile-uris" or "packfile". When "sideband-all" is used but "packfile-uris" is not used, either way works; this commit uses "packfile-uris" behavior in this case. Also make the naming of the sideband-activating methods in PacketLineOut more consistent. Change-Id: Ifbfd26cc26af10c41b77758168833702d6983df1 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* UploadPackTest: use Consumer to set up UploadPackJonathan Tan2019-07-161-43/+70
| | | | | | | | | | Use a Consumer instead of several nullable variables to further configure UploadPack. This is in preparation for a test in a subsequent patch needing further customization of the UploadPack object before invoking it. Change-Id: I074dff92c711a5ba74558bb4b06c42c115fb9b7f Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* Support "sideband-all" in protocol v2 fetchJonathan Tan2019-07-161-0/+58
| | | | | | | | | | | | | | Allow the client to specify "sideband-all" in a fetch v2 request, indicating that the whole response is to be multiplexed (with a sideband indicator on every non-flush and non-delim pkt) instead of only the packfile being multiplexed. This allows, for example, progress messages to be sent at any point in the response. This implements the "sideband-all" feature documented in Documentation/technical/protocol-v2.txt in Git. Change-Id: I3e7f21c88ff0982b1b7ebb09c9ad6c742c4483c8 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* UploadPackTest: refactor capability config testJonathan Tan2019-07-161-48/+59
| | | | | | | | | | | | | | | | UploadPackTest.java contains tests that check behavior when "allowfilter" and "allowrefinwant" are not set, are set, and are not set but the client insists on using them anyway. Because another capability is to be included in a subsequent patch, refactor the common code in these tests. Remove setBoolean calls with "false", as they are no-ops. Also take the opportunity to eliminate the overspecification of the "fetch=" line returned by the capability advertisement. Change-Id: I289bbd11c902a513cd8d53bc34767e61ebbd5f17 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* Move exception handling code to the callerMasaya Suzuki2019-06-271-48/+42
| | | | | | | | By doing this, exceptions thrown by sendPack are also covered by the same code. Change-Id: I3509f2d832af1410f307e931577e4d07e32b014e Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
* Add assertThrowsMasaya Suzuki2019-06-271-154/+109
| | | | | | | | | | This is a new assertion that will be introduced in JUnit 4.13. Unlike ExpectedException rule, this makes it easy to test other aspects of the thrown exception, such like ServiceMayNotContinueException's status code. Introduce this as before making changes to UploadPackTest more. Change-Id: Ied7b3071ffcd0e93eece35b01e0abc5ff65645f2 Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>