Skip to content

Commit 89833fc

Browse files
committed
Merge branch 'ds/fetch-bundle-uri-with-all'
"git fetch --all" does not have to download and handle the same bundleURI over and over, which has been corrected. * ds/fetch-bundle-uri-with-all: fetch: download bundles once, even with --all
2 parents c5305bb + 25bccb4 commit 89833fc

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

builtin/fetch.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,12 @@ static int fetch_multiple(struct string_list *list, int max_children)
19671967
return errcode;
19681968
}
19691969

1970-
strvec_pushl(&argv, "fetch", "--append", "--no-auto-gc",
1970+
/*
1971+
* Cancel out the fetch.bundleURI config when running subprocesses,
1972+
* to avoid fetching from the same bundle list multiple times.
1973+
*/
1974+
strvec_pushl(&argv, "-c", "fetch.bundleURI=",
1975+
"fetch", "--append", "--no-auto-gc",
19711976
"--no-write-commit-graph", NULL);
19721977
add_options_to_argv(&argv);
19731978

bundle-uri.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,15 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
794794

795795
init_bundle_list(&list);
796796

797+
/*
798+
* Do not fetch a NULL or empty bundle URI. An empty bundle URI
799+
* could signal that a configured bundle URI has been disabled.
800+
*/
801+
if (!uri || !*uri) {
802+
result = 0;
803+
goto cleanup;
804+
}
805+
797806
/* If a bundle is added to this global list, then it is required. */
798807
list.mode = BUNDLE_MODE_ALL;
799808

t/t5558-clone-bundle-uri.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,40 @@ test_expect_success 'creationToken heuristic with failed downloads (fetch)' '
10181018
test_cmp expect refs
10191019
'
10201020

1021+
test_expect_success 'bundles are downloaded once during fetch --all' '
1022+
test_when_finished rm -rf download-* trace*.txt fetch-mult &&
1023+
1024+
cat >"$HTTPD_DOCUMENT_ROOT_PATH/bundle-list" <<-EOF &&
1025+
[bundle]
1026+
version = 1
1027+
mode = all
1028+
heuristic = creationToken
1029+
1030+
[bundle "bundle-1"]
1031+
uri = bundle-1.bundle
1032+
creationToken = 1
1033+
1034+
[bundle "bundle-2"]
1035+
uri = bundle-2.bundle
1036+
creationToken = 2
1037+
1038+
[bundle "bundle-3"]
1039+
uri = bundle-3.bundle
1040+
creationToken = 3
1041+
EOF
1042+
1043+
git clone --single-branch --branch=left \
1044+
--bundle-uri="$HTTPD_URL/bundle-list" \
1045+
"$HTTPD_URL/smart/fetch.git" fetch-mult &&
1046+
git -C fetch-mult remote add dup1 "$HTTPD_URL/smart/fetch.git" &&
1047+
git -C fetch-mult remote add dup2 "$HTTPD_URL/smart/fetch.git" &&
1048+
1049+
GIT_TRACE2_EVENT="$(pwd)/trace-mult.txt" \
1050+
git -C fetch-mult fetch --all &&
1051+
grep "\"child_start\".*\"git-remote-https\",\"$HTTPD_URL/bundle-list\"" \
1052+
trace-mult.txt >bundle-fetches &&
1053+
test_line_count = 1 bundle-fetches
1054+
'
10211055
# Do not add tests here unless they use the HTTP server, as they will
10221056
# not run unless the HTTP dependencies exist.
10231057

0 commit comments

Comments
 (0)