Skip to content

Commit 5f31841

Browse files
Copilotdscho
andcommitted
Address reviewer feedback on HTTP/1.1 URL settings
Co-authored-by: dscho <[email protected]>
1 parent 79ff309 commit 5f31841

File tree

2 files changed

+29
-103
lines changed

2 files changed

+29
-103
lines changed

scalar.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,27 +232,30 @@ static int set_recommended_config(int reconfigure)
232232

233233
/*
234234
* 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
235237
*/
236238
if (!git_config_get_string("remote.origin.url", &value)) {
237-
if (strstr(value, "dev.azure.com") ||
238-
strstr(value, "visualstudio.com")) {
239+
if (starts_with(value, "https://dev.azure.com") ||
240+
strstr(value, ".visualstudio.com/")) {
239241
struct strbuf key = STRBUF_INIT;
240242
strbuf_addf(&key, "http.%s.version", value);
243+
char *original_value = value;
241244

242245
if (reconfigure || git_config_get_string(key.buf, &value)) {
243246
trace2_data_string("scalar", the_repository, key.buf, "created");
244247
if (git_config_set_gently(key.buf, "HTTP/1.1") < 0) {
245-
free(value);
248+
free(original_value);
246249
strbuf_release(&key);
247250
return error(_("could not configure %s=%s"),
248251
key.buf, "HTTP/1.1");
249252
}
250-
} else {
251-
trace2_data_string("scalar", the_repository, key.buf, "exists");
252253
}
253254
strbuf_release(&key);
255+
FREE_AND_NULL(original_value);
256+
} else {
257+
free(value);
254258
}
255-
free(value);
256259
}
257260

258261
/*

t/t9210-scalar.sh

Lines changed: 20 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -248,39 +248,26 @@ test_expect_success 'scalar reconfigure --all with detached HEADs' '
248248
'
249249

250250
test_expect_success 'verify http.<url>.version=HTTP/1.1 for ADO URLs' '
251-
test_when_finished rm -rf ado-test &&
251+
test_when_finished rm -rf test-http-url-config &&
252252
253253
# Create a test repository
254-
git init ado-test &&
254+
git init test-http-url-config &&
255255
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
256+
# Test both URL types in a loop
257+
for url in "https://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 remote set-url origin "$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
270+
done
284271
'
285272

286273
test_expect_success '`reconfigure -a` removes stale config entries' '
@@ -422,40 +409,11 @@ test_expect_success '`scalar clone` with GVFS-enabled server' '
422409
git -C using-gvfs/src config gvfs.sharedCache >actual &&
423410
test_cmp expect actual &&
424411
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 &&
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 &&
439414
echo "HTTP/1.1" >expect &&
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 &&
415+
test_cmp expect actual &&
454416
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
459417
'
460418

461419
second=$(git rev-parse --verify second:second.t) &&
@@ -464,41 +422,6 @@ test_expect_success 'verify http.<url>.version=HTTP/1.1 for visualstudio.com URL
464422
test_path_is_missing 1/2 &&
465423
GIT_TRACE=$PWD/trace.txt git cat-file blob $second >actual &&
466424
: verify that the gvfs-helper was invoked to fetch it &&
467-
test_grep gvfs-helper trace.txt &&
468-
echo "second" >expect &&
469-
test_cmp expect actual
470-
)
471-
'
472-
473-
test_expect_success '`scalar clone --no-gvfs-protocol` skips gvfs/config' '
474-
# the fake cache server requires fake authentication &&
475-
git config --global core.askPass true &&
476-
477-
# We must set credential.interactive=true to bypass a setting
478-
# in "scalar clone" that disables interactive credentials during
479-
# an unattended command.
480-
GIT_TRACE2_EVENT="$(pwd)/clone-trace-no-gvfs" scalar \
481-
-c credential.interactive=true \
482-
clone --no-gvfs-protocol \
483-
--single-branch -- http://$HOST_PORT/ skipping-gvfs &&
484-
485-
! grep "GET/config(main)" <clone-trace-no-gvfs &&
486-
! git -C skipping-gvfs/src config core.gvfs &&
487-
488-
test_config -C skipping-gvfs/src remote.origin.partialclonefilter blob:none
489-
'
490-
491-
test_expect_success '`scalar register` parallel to worktree is unsupported' '
492-
git init test-repo/src &&
493-
mkdir -p test-repo/out &&
494-
495-
: parallel to worktree is unsupported &&
496-
test_must_fail env GIT_CEILING_DIRECTORIES="$(pwd)" \
497-
scalar register test-repo/out &&
498-
test_must_fail git config --get --global --fixed-value \
499-
maintenance.repo "$(pwd)/test-repo/src" &&
500-
scalar list >scalar.repos &&
501-
! grep -F "$(pwd)/test-repo/src" scalar.repos &&
502425

503426
: at enlistment root, i.e. parent of repository, is supported &&
504427
GIT_CEILING_DIRECTORIES="$(pwd)" scalar register test-repo &&

0 commit comments

Comments
 (0)