[RFC PATCH v2 22/36] bundle: make it easy to call 'git bundle fetch'
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Apr 18, 2022, 17:23 UTC
- Message-ID
- <RFC-patch-v2-22.36-1350c19c3a1-20220418T165545Z-avarab@gmail.com>
- In-Reply-To
- <RFC-cover-v2-00.36-00000000000-20220418T165545Z-avarab@gmail.com>
From: Derrick Stolee <derrickstolee@github.com>
Future changes will integrate 'git bundle fetch' into the 'git clone' and 'git fetch' operations. Make it easy to fetch bundles via a helper method.
Signed-off-by: Derrick Stolee <derrickstolee@github.com> --- bundle.c | 21 +++++++++++++++++++++ bundle.h | 9 +++++++++ 2 files changed, 30 insertions(+)
diff --git a/bundle.c b/bundle.c index 5fa41a52f11..7e88f5bc942 100644 --- a/bundle.c +++ b/bundle.c @@ -639,3 +639,24 @@ int unbundle(struct repository *r, struct bundle_header *header, return error(_("index-pack died")); return 0; } + +int fetch_bundle_uri(const char *bundle_uri, + const char *filter) +{ + int res = 0; + struct strvec args = STRVEC_INIT; + + strvec_pushl(&args, "bundle", "fetch", NULL); + + if (filter) + strvec_pushf(&args, "--filter=%s", filter); + strvec_push(&args, bundle_uri); + + if (run_command_v_opt(args.v, RUN_GIT_CMD)) { + warning(_("failed to download bundle from uri '%s'"), bundle_uri); + res = 1; + } + + strvec_clear(&args); + return res; +} diff --git a/bundle.h b/bundle.h index 0c052f54964..c647dec7c93 100644 --- a/bundle.h +++ b/bundle.h @@ -46,4 +46,13 @@ int unbundle(struct repository *r, struct bundle_header *header, int list_bundle_refs(struct bundle_header *header, int argc, const char **argv); +struct list_objects_filter_options; +/** + * Fetch bundles from the given URI with the given filter. + * + * Uses 'git bundle fetch' as a subprocess. + */ +int fetch_bundle_uri(const char *bundle_uri, + const char *filter); + #endif
-- 2.36.0.rc2.902.g60576bbc845