]> source.dussan.org Git - jgit.git/commit
UploadPack: use want-refs as advertised set in fetch v2 30/193330/12
authorPatrick Hiesel <hiesel@google.com>
Fri, 13 May 2022 11:49:02 +0000 (13:49 +0200)
committerIvan Frade <ifrade@google.com>
Fri, 27 Oct 2023 14:39:45 +0000 (07:39 -0700)
commit5f563e386ec9f696d9681720d8649b1e9b4adb7c
tree10e5db3518637c8c7031312940707671cf47d690
parent093bde518118175e1542fa2561f8d2f20649879b
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
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java