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 88217d81f7a6c3..67a56fc91d2fe8 100644 --- a/gvfs-helper-client.c +++ b/gvfs-helper-client.c @@ -12,6 +12,7 @@ #include "pkt-line.h" #include "quote.h" #include "packfile.h" +#include "config.h" static struct oidset gh_client__oidset_queued = OIDSET_INIT; static unsigned long gh_client__oidset_count; @@ -337,6 +338,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(); @@ -344,10 +346,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);