diff options
author | kylezhao <kylezhao@tencent.com> | 2022-07-14 11:23:03 +0800 |
---|---|---|
committer | Thomas Wolf <twolf@apache.org> | 2022-10-21 08:11:33 +0200 |
commit | ad9c217f4954dc50f629b3eb6ae387b6940a5023 (patch) | |
tree | 5f4018d5d0dbe353f54da7aca888f34b8781e6b5 /org.eclipse.jgit.test/tst | |
parent | 71af0d6a5c4417a9c9c6523d4aa811579d8c867f (diff) | |
download | jgit-ad9c217f4954dc50f629b3eb6ae387b6940a5023.tar.gz jgit-ad9c217f4954dc50f629b3eb6ae387b6940a5023.zip |
PushCommand: allow users to disable use of bitmaps for push
Reachability bitmaps are designed to speed up the "counting objects"
phase of generating a pack during a clone or fetch. They are not
optimized for Git clients sending a small topic branch via "git push".
In some cases (see [1]), using reachability bitmaps during "git push"
can cause significant performance regressions.
Add PushCommand#setUseBitmaps(boolean) to allow users to tell "git push"
not to use bitmaps.
[1]: https://lore.kernel.org/git/87zhoz8b9o.fsf@evledraar.gmail.com/
Change-Id: I7fb7d26084ec63ddfa7249cf58abb85929b30e56
Signed-off-by: kylezhao <kylezhao@tencent.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java index 5ae440f1d2..2019c263fb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java @@ -242,6 +242,37 @@ public class TransportTest extends SampleDataRepositoryTestCase { } @Test + public void testOpenPushUseBitmaps() throws Exception { + URIish uri = new URIish("file://" + db.getWorkTree().getAbsolutePath()); + // default + try (Transport transport = Transport.open(uri)) { + try (PushConnection pushConnection = transport.openPush()) { + assertTrue(pushConnection instanceof BasePackPushConnection); + BasePackPushConnection basePackPushConnection = (BasePackPushConnection) pushConnection; + assertEquals(true, basePackPushConnection.isUseBitmaps()); + } + } + // true + try (Transport transport = Transport.open(uri)) { + transport.setPushUseBitmaps(true); + try (PushConnection pushConnection = transport.openPush()) { + assertTrue(pushConnection instanceof BasePackPushConnection); + BasePackPushConnection basePackPushConnection = (BasePackPushConnection) pushConnection; + assertEquals(true, basePackPushConnection.isUseBitmaps()); + } + } + // false + try (Transport transport = Transport.open(uri)) { + transport.setPushUseBitmaps(false); + try (PushConnection pushConnection = transport.openPush()) { + assertTrue(pushConnection instanceof BasePackPushConnection); + BasePackPushConnection basePackPushConnection = (BasePackPushConnection) pushConnection; + assertEquals(false, basePackPushConnection.isUseBitmaps()); + } + } + } + + @Test public void testSpi() { List<TransportProtocol> protocols = Transport.getTransportProtocols(); assertNotNull(protocols); |