[PATCH 11/25] bundle: allow relative URLs in table of contents
From: Derrick Stolee via GitGitGadget <hidden>
Date: 2022-02-23 18:31:44
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Derrick Stolee <redacted> When hosting bundle data, it can be helpful to distribute that data across multiple CDNs. This might require a change in the base URI, all the way to the domain name. If all bundles require an absolute URI in their 'uri' value, then every push to a CDN would require altering the table of contents to match the expected domain and exact location within it. Allow the table of contents to specify a relative URI for the bundles. This allows easier distribution of bundle data. RFC-TODO: An earlier change referenced relative URLs, but it was not implemented until this change. Signed-off-by: Derrick Stolee <redacted> --- builtin/bundle.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 27da5e3737f..ec969a62ae1 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c@@ -10,6 +10,7 @@ #include "config.h" #include "packfile.h" #include "list-objects-filter-options.h" +#include "remote.h" /* * Basic handler for bundle files to connect repositories via sneakernet.
@@ -453,6 +454,8 @@ static int cmd_bundle_fetch(int argc, const char **argv, const char *prefix) /* initialize stack using timestamp heuristic. */ hashmap_for_each_entry(&toc, &iter, info, ent) { + char *old_uri; + /* Skip if filter does not match. */ if (!filter && info->filter_str) continue;
@@ -460,6 +463,10 @@ static int cmd_bundle_fetch(int argc, const char **argv, const char *prefix) (!info->filter_str || strcasecmp(filter, info->filter_str))) continue; + old_uri = info->uri; + info->uri = relative_url(bundle_uri, info->uri, NULL); + free(old_uri); + /* * Now that the filter matches, start with the * bundle with largest timestamp.
--
gitgitgadget