Skip to content

Commit 12b0a14

Browse files
derrickstoleegitster
authored andcommitted
bundle-uri: download bundles from an advertised list
The logic in fetch_bundle_uri() is useful for the --bundle-uri option of 'git clone', but is not helpful when the clone operation discovers a list of URIs from the bundle-uri protocol v2 command. To actually download and unbundle the advertised bundles, we need a different mechanism. Create the new fetch_bundle_list() method which is very similar to fetch_bundle_uri() except that it relies on download_bundle_list() instead of fetch_bundle_uri_internal(). The download_bundle_list() method will recursively call fetch_bundle_uri_internal() if any of the advertised URIs serve a bundle list instead of a bundle. This will also follow the bundle.list.mode setting from the input list: "any" will download only one such URI while "all" will download data from all of the URIs. In an identical way to fetch_bundle_uri(), the bundles are unbundled after all of the bundle lists have been expanded and all necessary URIs. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebc3947 commit 12b0a14

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

bundle-uri.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,27 @@ int fetch_bundle_uri(struct repository *r, const char *uri)
577577
return result;
578578
}
579579

580+
int fetch_bundle_list(struct repository *r, struct bundle_list *list)
581+
{
582+
int result;
583+
struct bundle_list global_list;
584+
585+
init_bundle_list(&global_list);
586+
587+
/* If a bundle is added to this global list, then it is required. */
588+
global_list.mode = BUNDLE_MODE_ALL;
589+
590+
if ((result = download_bundle_list(r, list, &global_list, 0)))
591+
goto cleanup;
592+
593+
result = unbundle_all_bundles(r, &global_list);
594+
595+
cleanup:
596+
for_all_bundles_in_list(&global_list, unlink_bundle, NULL);
597+
clear_bundle_list(&global_list);
598+
return result;
599+
}
600+
580601
/**
581602
* API for serve.c.
582603
*/

bundle-uri.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ int bundle_uri_parse_config_format(const char *uri,
107107
*/
108108
int fetch_bundle_uri(struct repository *r, const char *uri);
109109

110+
/**
111+
* Given a bundle list that was already advertised (likely by the
112+
* bundle-uri protocol v2 verb) at the given uri, fetch and unbundle the
113+
* bundles according to the bundle strategy of that list.
114+
*
115+
* It is expected that the given 'list' is initialized, including its
116+
* 'baseURI' value.
117+
*
118+
* Returns non-zero if there was an error trying to download the list
119+
* or any of its advertised bundles.
120+
*/
121+
int fetch_bundle_list(struct repository *r,
122+
struct bundle_list *list);
123+
110124
/**
111125
* API for serve.c.
112126
*/

0 commit comments

Comments
 (0)