Skip to content

Commit 3332e4c

Browse files
Copilotdschoderrickstolee
committed
scalar: work around GVFS Protocol HTTP/2 failures
Work around failures when using the GVFS Protocol with Azure DevOps URLs (dev.azure.com and *.visualstudio.com) due to incomplete HTTP/2 support on the server side. Configure http.<url>.version=HTTP/1.1 for these remotes when setting up or reconfiguring a Scalar enlistment. This ensures that Scalar and GVFS continue to function correctly with Azure-hosted repositories, without affecting other remotes. This fixes #752 Co-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de> Co-authored-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 4604ac5 commit 3332e4c

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

scalar.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,33 @@ static int set_recommended_config(int reconfigure)
215215
fsmonitor.key, fsmonitor.value);
216216
}
217217

218+
/*
219+
* Set HTTP/1.1 for Azure DevOps URLs
220+
* We check for dev.azure.com/ and .visualstudio.com/ patterns
221+
* which are sufficient to identify ADO URLs (including formats like
222+
* https://orgname@dev.azure.com/...)
223+
*/
224+
if (!repo_config_get_string(the_repository, "remote.origin.url", &value)) {
225+
if (starts_with(value, "https://dev.azure.com/") ||
226+
strstr(value, "@dev.azure.com/") ||
227+
strstr(value, ".visualstudio.com/")) {
228+
struct strbuf key = STRBUF_INIT;
229+
strbuf_addf(&key, "http.%s.version", value);
230+
FREE_AND_NULL(value);
231+
232+
if (reconfigure || repo_config_get_string(the_repository, key.buf, &value)) {
233+
trace2_data_string("scalar", the_repository, key.buf, "created");
234+
if (repo_config_set_gently(the_repository, key.buf, "HTTP/1.1") < 0) {
235+
strbuf_release(&key);
236+
return error(_("could not configure %s=%s"),
237+
key.buf, "HTTP/1.1");
238+
}
239+
}
240+
strbuf_release(&key);
241+
}
242+
FREE_AND_NULL(value);
243+
}
244+
218245
/*
219246
* The `log.excludeDecoration` setting is special because it allows
220247
* for multiple values.
@@ -872,7 +899,7 @@ static int cmd_clone(int argc, const char **argv)
872899
/* Is --[no-]gvfs-protocol unspecified? Infer from url. */
873900
if (gvfs_protocol < 0) {
874901
if (cache_server_url ||
875-
strstr(url, "dev.azure.com") ||
902+
strstr(url, "dev.azure.com/") ||
876903
strstr(url, "visualstudio.com"))
877904
gvfs_protocol = 1;
878905
else
@@ -889,7 +916,7 @@ static int cmd_clone(int argc, const char **argv)
889916
cache_server_url = default_cache_server_url;
890917
if (set_config("core.useGVFSHelper=true") ||
891918
set_config("core.gvfs=150") ||
892-
set_config("http.version=HTTP/1.1")) {
919+
set_config("http.%s.version=HTTP/1.1", url)) {
893920
res = error(_("could not turn on GVFS helper"));
894921
goto cleanup;
895922
}

t/t9210-scalar.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,29 @@ test_expect_success 'scalar reconfigure --all with detached HEADs' '
269269
done
270270
'
271271

272+
test_expect_success 'verify http.<url>.version=HTTP/1.1 for ADO URLs' '
273+
test_when_finished rm -rf test-http-url-config &&
274+
275+
# Create a test repository
276+
git init test-http-url-config &&
277+
278+
# Test both URL types
279+
for url in "https://test@dev.azure.com/test/project/_git/repo" \
280+
"https://contoso.visualstudio.com/project/_git/repo"
281+
do
282+
# Set URL as remote
283+
git -C test-http-url-config config set remote.origin.url "$url" &&
284+
285+
# Run scalar reconfigure
286+
scalar reconfigure test-http-url-config &&
287+
288+
# Verify URL-specific HTTP version setting
289+
git -C test-http-url-config config "http.$url.version" >actual &&
290+
echo "HTTP/1.1" >expect &&
291+
test_cmp expect actual || return 1
292+
done
293+
'
294+
272295
test_expect_success '`reconfigure -a` removes stale config entries' '
273296
git init stale/src &&
274297
scalar register stale &&
@@ -408,6 +431,11 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
408431
git -C using-gvfs/src config gvfs.sharedCache >actual &&
409432
test_cmp expect actual &&
410433
434+
: verify that URL-specific HTTP version setting is configured for GVFS URLs in clone &&
435+
git -C using-gvfs/src config "http.http://$HOST_PORT/.version" >actual &&
436+
echo "HTTP/1.1" >expect &&
437+
test_cmp expect actual &&
438+
411439
second=$(git rev-parse --verify second:second.t) &&
412440
(
413441
cd using-gvfs/src &&

0 commit comments

Comments
 (0)