Skip to content

Commit 79ff309

Browse files
Copilotdscho
andcommitted
Fix http.<url>.version setting for ADO URLs
Co-authored-by: dscho <[email protected]>
1 parent d3b2c16 commit 79ff309

File tree

2 files changed

+96
-4
lines changed

2 files changed

+96
-4
lines changed

scalar.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,31 @@ 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+
*/
236+
if (!git_config_get_string("remote.origin.url", &value)) {
237+
if (strstr(value, "dev.azure.com") ||
238+
strstr(value, "visualstudio.com")) {
239+
struct strbuf key = STRBUF_INIT;
240+
strbuf_addf(&key, "http.%s.version", value);
241+
242+
if (reconfigure || git_config_get_string(key.buf, &value)) {
243+
trace2_data_string("scalar", the_repository, key.buf, "created");
244+
if (git_config_set_gently(key.buf, "HTTP/1.1") < 0) {
245+
free(value);
246+
strbuf_release(&key);
247+
return error(_("could not configure %s=%s"),
248+
key.buf, "HTTP/1.1");
249+
}
250+
} else {
251+
trace2_data_string("scalar", the_repository, key.buf, "exists");
252+
}
253+
strbuf_release(&key);
254+
}
255+
free(value);
256+
}
257+
233258
/*
234259
* The `log.excludeDecoration` setting is special because it allows
235260
* for multiple values.
@@ -886,7 +911,7 @@ static int cmd_clone(int argc, const char **argv)
886911
cache_server_url = default_cache_server_url;
887912
if (set_config("core.useGVFSHelper=true") ||
888913
set_config("core.gvfs=150") ||
889-
set_config("http.version=HTTP/1.1")) {
914+
set_config("http.%s.version=HTTP/1.1", url)) {
890915
res = error(_("could not turn on GVFS helper"));
891916
goto cleanup;
892917
}

t/t9210-scalar.sh

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,42 @@ 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 ado-test &&
252+
253+
# Create a test repository
254+
git init ado-test &&
255+
256+
# Set ADO URL as remote
257+
git -C ado-test remote add origin https://dev.azure.com/test/project/_git/repo &&
258+
259+
# Run scalar reconfigure
260+
scalar reconfigure ado-test &&
261+
262+
# Verify URL-specific HTTP version setting
263+
git -C ado-test config "http.https://dev.azure.com/test/project/_git/repo.version" >actual &&
264+
echo "HTTP/1.1" >expect &&
265+
test_cmp expect actual
266+
'
267+
268+
test_expect_success 'verify http.<url>.version=HTTP/1.1 for visualstudio.com URLs' '
269+
test_when_finished rm -rf vso-test &&
270+
271+
# Create a test repository
272+
git init vso-test &&
273+
274+
# Set VSO URL as remote
275+
git -C vso-test remote add origin https://contoso.visualstudio.com/project/_git/repo &&
276+
277+
# Run scalar reconfigure
278+
scalar reconfigure vso-test &&
279+
280+
# Verify URL-specific HTTP version setting
281+
git -C vso-test config "http.https://contoso.visualstudio.com/project/_git/repo.version" >actual &&
282+
echo "HTTP/1.1" >expect &&
283+
test_cmp expect actual
284+
'
285+
250286
test_expect_success '`reconfigure -a` removes stale config entries' '
251287
git init stale/src &&
252288
scalar register stale &&
@@ -386,10 +422,41 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
386422
git -C using-gvfs/src config gvfs.sharedCache >actual &&
387423
test_cmp expect actual &&
388424
389-
: verify that HTTP/1.1 is configured for ADO URLs &&
390-
git -C using-gvfs/src config http.version >actual &&
425+
test_expect_success 'verify http.<url>.version=HTTP/1.1 for ADO URLs' '
426+
test_when_finished rm -rf ado-test &&
427+
428+
# Create a test repository
429+
git init ado-test &&
430+
431+
# Set ADO URL as remote
432+
git -C ado-test remote add origin https://dev.azure.com/test/project/_git/repo &&
433+
434+
# Run scalar reconfigure
435+
scalar reconfigure ado-test &&
436+
437+
# Verify URL-specific HTTP version setting
438+
git -C ado-test config "http.https://dev.azure.com/test/project/_git/repo.version" >actual &&
391439
echo "HTTP/1.1" >expect &&
392-
test_cmp expect actual &&
440+
test_cmp expect actual
441+
'
442+
443+
test_expect_success 'verify http.<url>.version=HTTP/1.1 for visualstudio.com URLs' '
444+
test_when_finished rm -rf vso-test &&
445+
446+
# Create a test repository
447+
git init vso-test &&
448+
449+
# Set VSO URL as remote
450+
git -C vso-test remote add origin https://contoso.visualstudio.com/project/_git/repo &&
451+
452+
# Run scalar reconfigure
453+
scalar reconfigure vso-test &&
454+
455+
# Verify URL-specific HTTP version setting
456+
git -C vso-test config "http.https://contoso.visualstudio.com/project/_git/repo.version" >actual &&
457+
echo "HTTP/1.1" >expect &&
458+
test_cmp expect actual
459+
'
393460
394461
second=$(git rev-parse --verify second:second.t) &&
395462
(

0 commit comments

Comments
 (0)