diff --git a/Documentation/config/gvfs.txt b/Documentation/config/gvfs.txt index 6ab221ded36c91..7224939ac0b270 100644 --- a/Documentation/config/gvfs.txt +++ b/Documentation/config/gvfs.txt @@ -3,3 +3,8 @@ gvfs.cache-server:: gvfs.sharedcache:: TODO + +gvfs.fallback:: + If set to `false`, then never fallback to the origin server when the cache + server fails to connect. This will alert users to failures with the cache + server, but avoid causing throttling on the origin server. diff --git a/gvfs-helper-client.c b/gvfs-helper-client.c index 6f38fe1c4353d0..45d4d86783c73b 100644 --- a/gvfs-helper-client.c +++ b/gvfs-helper-client.c @@ -14,6 +14,7 @@ #include "quote.h" #include "packfile.h" #include "hex.h" +#include "config.h" static struct oidset gh_client__oidset_queued = OIDSET_INIT; static unsigned long gh_client__oidset_count; @@ -339,6 +340,7 @@ static struct gh_server__process *gh_client__find_long_running_process( struct gh_server__process *entry; struct strvec argv = STRVEC_INIT; struct strbuf quoted = STRBUF_INIT; + int fallback; gh_client__choose_odb(); @@ -346,10 +348,17 @@ static struct gh_server__process *gh_client__find_long_running_process( * TODO decide what defaults we want. */ strvec_push(&argv, "gvfs-helper"); - strvec_push(&argv, "--fallback"); strvec_push(&argv, "--cache-server=trust"); strvec_pushf(&argv, "--shared-cache=%s", gh_client__chosen_odb->path); + + /* If gvfs.fallback=false, then don't add --fallback. */ + if (!git_config_get_bool("gvfs.fallback", &fallback) && + !fallback) + strvec_push(&argv, "--no-fallback"); + else + strvec_push(&argv, "--fallback"); + strvec_push(&argv, "server"); sq_quote_argv_pretty("ed, argv.v);