From 8f46e6a0a3133b054edea4360af4c03bbb1ffefb Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 5 Jan 2026 15:36:42 -0500 Subject: [PATCH 1/4] fixup! gvfs-helper: create tool to fetch objects using the GVFS Protocol Before modifying the config documentation more, fill in these blanks. Signed-off-by: Derrick Stolee --- Documentation/config/gvfs.adoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/config/gvfs.adoc b/Documentation/config/gvfs.adoc index 7224939ac0b270..da771a0535943a 100644 --- a/Documentation/config/gvfs.adoc +++ b/Documentation/config/gvfs.adoc @@ -1,8 +1,10 @@ gvfs.cache-server:: - TODO + When set, redirect all GVFS Protocol requests to this base URL instead + of the origin server. gvfs.sharedcache:: - TODO + When set, place all object data downloaded via the GVFS Protocol into + this Git alternate. gvfs.fallback:: If set to `false`, then never fallback to the origin server when the cache From fa89d0699f5ba98aa6bbacc68a14bc920f3ea24c Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 5 Jan 2026 15:56:50 -0500 Subject: [PATCH 2/4] gvfs-helper: override cache server for prefetch This extension of the gvfs.cache-server config now allows a new key, gvfs.prefetch.cache-server, to override the cache-server URL for only the prefetch endpoint. The purpose of this config is to allow for incremental testing and deployment of new cache-server infrastructure. Hypothetically, we could have special-purpose cache-servers that are glorified bundle servers and other servers that focus on the object and size endpoints. More realistically, this will allow us to test cache servers that have only the prefetch endpoint ready to go. This allows some incremental rollout that is more controlled than a flag day replacing the entire infrastructure. Signed-off-by: Derrick Stolee --- Documentation/config/gvfs.adoc | 12 ++++++- gvfs-helper.c | 63 +++++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/Documentation/config/gvfs.adoc b/Documentation/config/gvfs.adoc index da771a0535943a..ed6e94f31aa990 100644 --- a/Documentation/config/gvfs.adoc +++ b/Documentation/config/gvfs.adoc @@ -1,6 +1,16 @@ gvfs.cache-server:: When set, redirect all GVFS Protocol requests to this base URL instead - of the origin server. + of the origin server. Individual verbs can be overridden with the + `gvfs..cache-server` config keys. + +gvfs..cache-server:: + Override the base value of `gvfs.cache-server` when using this specific + ``. The verbs available are: ++ +-- + prefetch:: + Use this cache server when prefetching commits and tree packfiles. +-- gvfs.sharedcache:: When set, place all object data downloaded via the GVFS Protocol into diff --git a/gvfs-helper.c b/gvfs-helper.c index d030c76e32cacb..a39857d3ccc307 100644 --- a/gvfs-helper.c +++ b/gvfs-helper.c @@ -373,7 +373,8 @@ static struct gh__global { struct credential cache_creds; const char *main_url; - const char *cache_server_url; + char *cache_server_url; + char *cache_server_url_backup; struct strbuf buf_odb_path; @@ -391,6 +392,54 @@ enum gh__server_type { GH__SERVER_TYPE__NR, }; +enum gh__verb { + PREFETCH, +}; + +static void update_cache_server_for_verb(enum gh__verb verb) +{ + const char *verbstr = NULL; + char *value = NULL; + struct strbuf key = STRBUF_INIT; + + switch (verb) { + case PREFETCH: + verbstr = "prefetch"; + break; + + default: + gh__global.cache_server_url_backup = NULL; + return; + } + + gh__global.cache_server_url_backup = gh__global.cache_server_url; + + strbuf_addf(&key, "gvfs.%s.cache-server", verbstr); + + if (!repo_config_get_string(the_repository, key.buf, &value) && + value) { + trace2_data_string("gvfs-helper", the_repository, key.buf, value); + gh__global.cache_server_url = value; + } else { + gh__global.cache_server_url_backup = NULL; + } + + strbuf_release(&key); +} + +static void reset_cache_server(void) +{ + /* + * The backup exists only if the base was replaced with a + * freeable value. + */ + if (gh__global.cache_server_url_backup) { + free(gh__global.cache_server_url); + gh__global.cache_server_url = gh__global.cache_server_url_backup; + gh__global.cache_server_url_backup = NULL; + } +} + static const char *gh__server_type_label[GH__SERVER_TYPE__NR] = { "(main)", "(cs)" @@ -3119,6 +3168,7 @@ static void do_req__with_fallback(const char *url_component, struct gh__request_params *params, struct gh__response_status *status) { +retry_backup: if (gh__global.cache_server_url && params->b_permit_cache_server_if_defined) { do_req__to_cache_server(url_component, params, status); @@ -3129,6 +3179,15 @@ static void do_req__with_fallback(const char *url_component, if (!gh__cmd_opts.try_fallback) return; + /* + * If we overrode the cache-server using a custom key, + * then fall back to the regular cache server on failure. + */ + if (gh__global.cache_server_url_backup) { + reset_cache_server(); + goto retry_backup; + } + /* * The cache-server shares creds with the main Git server, * so if our creds failed against the cache-server, they @@ -3444,7 +3503,9 @@ static void do__http_get__gvfs_prefetch(struct gh__response_status *status, show_date(seconds_since_epoch, 0, DATE_MODE(ISO8601))); + update_cache_server_for_verb(PREFETCH); do_req__with_fallback(component_url.buf, ¶ms, status); + reset_cache_server(); gh__request_params__release(¶ms); strbuf_release(&component_url); From dde8b394e142c43240079937fc14ac855f6cf696 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 5 Jan 2026 16:00:40 -0500 Subject: [PATCH 3/4] gvfs-helper: override cache server for get This extension of the gvfs.cache-server config now allows a new key, gvfs.get.cache-server, to override the cache-server URL for only the prefetch endpoint. The purpose of this config is to allow for incremental testing and deployment of new cache-server infrastructure. Signed-off-by: Derrick Stolee --- Documentation/config/gvfs.adoc | 3 +++ gvfs-helper.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Documentation/config/gvfs.adoc b/Documentation/config/gvfs.adoc index ed6e94f31aa990..0a9b6bd524ffc3 100644 --- a/Documentation/config/gvfs.adoc +++ b/Documentation/config/gvfs.adoc @@ -10,6 +10,9 @@ gvfs..cache-server:: -- prefetch:: Use this cache server when prefetching commits and tree packfiles. + get:: + Use this cache server when downloading objects immediately via the + GET endpoint. -- gvfs.sharedcache:: diff --git a/gvfs-helper.c b/gvfs-helper.c index a39857d3ccc307..81953d66ccf246 100644 --- a/gvfs-helper.c +++ b/gvfs-helper.c @@ -394,6 +394,7 @@ enum gh__server_type { enum gh__verb { PREFETCH, + GET, }; static void update_cache_server_for_verb(enum gh__verb verb) @@ -407,6 +408,10 @@ static void update_cache_server_for_verb(enum gh__verb verb) verbstr = "prefetch"; break; + case GET: + verbstr = "get"; + break; + default: gh__global.cache_server_url_backup = NULL; return; @@ -3311,7 +3316,9 @@ static void do__http_get__gvfs_object(struct gh__response_status *status, setup_gvfs_objects_progress(¶ms, l_num, l_den); + update_cache_server_for_verb(GET); do_req__with_fallback(component_url.buf, ¶ms, status); + reset_cache_server(); gh__request_params__release(¶ms); strbuf_release(&component_url); From a88dd1be8a3b1e9b347cddbfa6fda50b3383ed63 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 5 Jan 2026 16:02:42 -0500 Subject: [PATCH 4/4] gvfs-helper: override cache server for post This extension of the gvfs.cache-server config now allows a new key, gvfs.post.cache-server, to overrid the cache-server URL for only the batched objects endpoint. The purpose of this config is to allow for incremental testing and deployment of new cache-server infrastructure. Signed-off-by: Derrick Stolee --- Documentation/config/gvfs.adoc | 3 +++ gvfs-helper.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Documentation/config/gvfs.adoc b/Documentation/config/gvfs.adoc index 0a9b6bd524ffc3..4d988598425cec 100644 --- a/Documentation/config/gvfs.adoc +++ b/Documentation/config/gvfs.adoc @@ -13,6 +13,9 @@ gvfs..cache-server:: get:: Use this cache server when downloading objects immediately via the GET endpoint. + post:: + Use this cache server when downloading objects in batches using the + POST endpoint. -- gvfs.sharedcache:: diff --git a/gvfs-helper.c b/gvfs-helper.c index 81953d66ccf246..022985dfc1990d 100644 --- a/gvfs-helper.c +++ b/gvfs-helper.c @@ -395,6 +395,7 @@ enum gh__server_type { enum gh__verb { PREFETCH, GET, + POST, }; static void update_cache_server_for_verb(enum gh__verb verb) @@ -412,6 +413,10 @@ static void update_cache_server_for_verb(enum gh__verb verb) verbstr = "get"; break; + case POST: + verbstr = "post"; + break; + default: gh__global.cache_server_url_backup = NULL; return; @@ -3390,7 +3395,9 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status, setup_gvfs_objects_progress(¶ms, j_pack_num, j_pack_den); + update_cache_server_for_verb(POST); do_req__with_fallback("gvfs/objects", ¶ms, status); + reset_cache_server(); gh__request_params__release(¶ms); jw_release(&jw_req);