diff options
author | Patrick Hiesel <hiesel@google.com> | 2022-05-13 13:49:02 +0200 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2023-10-27 07:39:45 -0700 |
commit | 5f563e386ec9f696d9681720d8649b1e9b4adb7c (patch) | |
tree | 10e5db3518637c8c7031312940707671cf47d690 /org.eclipse.jgit.test/tst/org/eclipse/jgit/transport | |
parent | 093bde518118175e1542fa2561f8d2f20649879b (diff) | |
download | jgit-5f563e386ec9f696d9681720d8649b1e9b4adb7c.tar.gz jgit-5f563e386ec9f696d9681720d8649b1e9b4adb7c.zip |
UploadPack: use want-refs as advertised set in fetch v2
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
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/transport')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index 278c9f8616..d61403f97e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java @@ -3000,7 +3000,7 @@ public class UploadPackTest { assertThat(pckIn.readString(), is("packfile")); parsePack(recvStream); assertTrue(client.getObjectDatabase().has(one.toObjectId())); - assertEquals(1, ((RefCallsCountingRepository)server).numRefCalls()); + assertEquals(0, ((RefCallsCountingRepository)server).numRefCalls()); } @Test |