Skip to content

Commit 1030eb5

Browse files
authored
scalar: add test to verify http.version=HTTP/1.1 is set for Azure Repos URLs (#754)
This PR addresses an issue where macOS users of `scalar clone` need to set `http.version=HTTP/1.1` in their global config before they can connect to Azure DevOps and the `gvfs/config` endpoint. Upon investigation, I found that the setting `http.version=HTTP/1.1` was already implemented in the codebase when the GVFS protocol is enabled (which is automatically enabled for dev.azure.com and visualstudio.com URLs). Fixes #752.
2 parents 0b0e37b + 99091f5 commit 1030eb5

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
@@ -230,6 +230,33 @@ static int set_recommended_config(int reconfigure)
230230
fsmonitor.key, fsmonitor.value);
231231
}
232232

233+
/*
234+
* Set HTTP/1.1 for Azure DevOps URLs
235+
* We check for dev.azure.com/ and .visualstudio.com/ patterns
236+
* which are sufficient to identify ADO URLs (including formats like
237+
* https://orgname@dev.azure.com/...)
238+
*/
239+
if (!git_config_get_string("remote.origin.url", &value)) {
240+
if (starts_with(value, "https://dev.azure.com/") ||
241+
strstr(value, "@dev.azure.com/") ||
242+
strstr(value, ".visualstudio.com/")) {
243+
struct strbuf key = STRBUF_INIT;
244+
strbuf_addf(&key, "http.%s.version", value);
245+
FREE_AND_NULL(value);
246+
247+
if (reconfigure || git_config_get_string(key.buf, &value)) {
248+
trace2_data_string("scalar", the_repository, key.buf, "created");
249+
if (git_config_set_gently(key.buf, "HTTP/1.1") < 0) {
250+
strbuf_release(&key);
251+
return error(_("could not configure %s=%s"),
252+
key.buf, "HTTP/1.1");
253+
}
254+
}
255+
strbuf_release(&key);
256+
}
257+
FREE_AND_NULL(value);
258+
}
259+
233260
/*
234261
* The `log.excludeDecoration` setting is special because it allows
235262
* for multiple values.
@@ -869,7 +896,7 @@ static int cmd_clone(int argc, const char **argv)
869896
/* Is --[no-]gvfs-protocol unspecified? Infer from url. */
870897
if (gvfs_protocol < 0) {
871898
if (cache_server_url ||
872-
strstr(url, "dev.azure.com") ||
899+
strstr(url, "dev.azure.com/") ||
873900
strstr(url, "visualstudio.com"))
874901
gvfs_protocol = 1;
875902
else
@@ -886,7 +913,7 @@ static int cmd_clone(int argc, const char **argv)
886913
cache_server_url = default_cache_server_url;
887914
if (set_config("core.useGVFSHelper=true") ||
888915
set_config("core.gvfs=150") ||
889-
set_config("http.version=HTTP/1.1")) {
916+
set_config("http.%s.version=HTTP/1.1", url)) {
890917
res = error(_("could not turn on GVFS helper"));
891918
goto cleanup;
892919
}

t/t9210-scalar.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,29 @@ test_expect_success 'scalar reconfigure --all with detached HEADs' '
247247
done
248248
'
249249

250+
test_expect_success 'verify http.<url>.version=HTTP/1.1 for ADO URLs' '
251+
test_when_finished rm -rf test-http-url-config &&
252+
253+
# Create a test repository
254+
git init test-http-url-config &&
255+
256+
# Test both URL types
257+
for url in "https://test@dev.azure.com/test/project/_git/repo" \
258+
"https://contoso.visualstudio.com/project/_git/repo"
259+
do
260+
# Set URL as remote
261+
git -C test-http-url-config config set remote.origin.url "$url" &&
262+
263+
# Run scalar reconfigure
264+
scalar reconfigure test-http-url-config &&
265+
266+
# Verify URL-specific HTTP version setting
267+
git -C test-http-url-config config "http.$url.version" >actual &&
268+
echo "HTTP/1.1" >expect &&
269+
test_cmp expect actual || return 1
270+
done
271+
'
272+
250273
test_expect_success '`reconfigure -a` removes stale config entries' '
251274
git init stale/src &&
252275
scalar register stale &&
@@ -386,6 +409,11 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
386409
git -C using-gvfs/src config gvfs.sharedCache >actual &&
387410
test_cmp expect actual &&
388411
412+
: verify that URL-specific HTTP version setting is configured for GVFS URLs in clone &&
413+
git -C using-gvfs/src config "http.http://$HOST_PORT/.version" >actual &&
414+
echo "HTTP/1.1" >expect &&
415+
test_cmp expect actual &&
416+
389417
second=$(git rev-parse --verify second:second.t) &&
390418
(
391419
cd using-gvfs/src &&

0 commit comments

Comments
 (0)