Skip to content

scalar: add test to verify http.version=HTTP/1.1 is set for Azure Repos URLs #754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be sufficient for answering my concerns for scalar clone commands against ADO. Thanks.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dscho: Somehow the comment I tried to leave yesterday didn't come through. I must have started a review that didn't get complete.

This line won't actually be sufficient because it's replacing a wider-focus config change for http.version=HTTP/1.1. The issue is that before this change there is a call to supports_gvfs_protocol() that will fail if this config isn't set.

Sorry, this PR doesn't actually resolve the issue due to this problem. Hard to recognize when the diff isn't there and the tests do not cover a real-world example.

res = error(_("could not turn on GVFS helper"));
goto cleanup;
}
Expand Down
28 changes: 28 additions & 0 deletions t/t9210-scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,29 @@ test_expect_success 'scalar reconfigure --all with detached HEADs' '
done
'

test_expect_success 'verify http.<url>.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 &&
Expand Down Expand Up @@ -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 &&
Expand Down
Loading