diff --git a/scalar.c b/scalar.c index bb3edceddb5ba5..14a0b08e84c3ae 100644 --- a/scalar.c +++ b/scalar.c @@ -230,6 +230,33 @@ static int set_recommended_config(int reconfigure) fsmonitor.key, fsmonitor.value); } + /* + * Set HTTP/1.1 for Azure DevOps URLs + * We check for dev.azure.com/ and .visualstudio.com/ patterns + * which are sufficient to identify ADO URLs (including formats like + * https://orgname@dev.azure.com/...) + */ + if (!git_config_get_string("remote.origin.url", &value)) { + if (starts_with(value, "https://dev.azure.com/") || + strstr(value, "@dev.azure.com/") || + strstr(value, ".visualstudio.com/")) { + struct strbuf key = STRBUF_INIT; + strbuf_addf(&key, "http.%s.version", value); + FREE_AND_NULL(value); + + if (reconfigure || git_config_get_string(key.buf, &value)) { + trace2_data_string("scalar", the_repository, key.buf, "created"); + if (git_config_set_gently(key.buf, "HTTP/1.1") < 0) { + strbuf_release(&key); + return error(_("could not configure %s=%s"), + key.buf, "HTTP/1.1"); + } + } + strbuf_release(&key); + } + FREE_AND_NULL(value); + } + /* * The `log.excludeDecoration` setting is special because it allows * for multiple values. @@ -869,7 +896,7 @@ static int cmd_clone(int argc, const char **argv) /* Is --[no-]gvfs-protocol unspecified? Infer from url. */ if (gvfs_protocol < 0) { if (cache_server_url || - strstr(url, "dev.azure.com") || + strstr(url, "dev.azure.com/") || strstr(url, "visualstudio.com")) gvfs_protocol = 1; else @@ -886,7 +913,7 @@ static int cmd_clone(int argc, const char **argv) cache_server_url = default_cache_server_url; if (set_config("core.useGVFSHelper=true") || set_config("core.gvfs=150") || - set_config("http.version=HTTP/1.1")) { + set_config("http.%s.version=HTTP/1.1", url)) { res = error(_("could not turn on GVFS helper")); goto cleanup; } diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh index b932082e663914..9bfd3390d4bef3 100755 --- a/t/t9210-scalar.sh +++ b/t/t9210-scalar.sh @@ -247,6 +247,29 @@ test_expect_success 'scalar reconfigure --all with detached HEADs' ' done ' +test_expect_success 'verify http..version=HTTP/1.1 for ADO URLs' ' + test_when_finished rm -rf test-http-url-config && + + # Create a test repository + git init test-http-url-config && + + # Test both URL types + for url in "https://test@dev.azure.com/test/project/_git/repo" \ + "https://contoso.visualstudio.com/project/_git/repo" + do + # Set URL as remote + git -C test-http-url-config config set remote.origin.url "$url" && + + # Run scalar reconfigure + scalar reconfigure test-http-url-config && + + # Verify URL-specific HTTP version setting + git -C test-http-url-config config "http.$url.version" >actual && + echo "HTTP/1.1" >expect && + test_cmp expect actual || return 1 + done +' + test_expect_success '`reconfigure -a` removes stale config entries' ' git init stale/src && scalar register stale && @@ -386,6 +409,11 @@ test_expect_success '`scalar clone` with GVFS-enabled server' ' git -C using-gvfs/src config gvfs.sharedCache >actual && test_cmp expect actual && + : verify that URL-specific HTTP version setting is configured for GVFS URLs in clone && + git -C using-gvfs/src config "http.http://$HOST_PORT/.version" >actual && + echo "HTTP/1.1" >expect && + test_cmp expect actual && + second=$(git rev-parse --verify second:second.t) && ( cd using-gvfs/src &&