static struct transport *gtransport;
static struct transport *gsecondary;
static struct refspec refmap = REFSPEC_INIT_FETCH;
-static struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT;
static struct string_list server_options = STRING_LIST_INIT_DUP;
static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
smart_options->negotiation_tips = oids;
}
-static struct transport *prepare_transport(struct remote *remote, int deepen)
+static struct transport *prepare_transport(struct remote *remote, int deepen,
+ struct list_objects_filter_options *filter_options)
{
struct transport *transport;
set_option(transport, TRANS_OPT_UPDATE_SHALLOW, "yes");
if (refetch)
set_option(transport, TRANS_OPT_REFETCH, "yes");
- if (filter_options.choice) {
+ if (filter_options->choice) {
const char *spec =
- expand_list_objects_filter_spec(&filter_options);
+ expand_list_objects_filter_spec(filter_options);
set_option(transport, TRANS_OPT_LIST_OBJECTS_FILTER, spec);
set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
}
struct ref_transaction *transaction,
struct ref *ref_map,
struct fetch_head *fetch_head,
- const struct fetch_config *config)
+ const struct fetch_config *config,
+ struct list_objects_filter_options *filter_options)
{
int retcode, cannot_reuse;
cannot_reuse = transport->cannot_reuse ||
deepen_since || deepen_not.nr;
if (cannot_reuse) {
- gsecondary = prepare_transport(transport->remote, 0);
+ gsecondary = prepare_transport(transport->remote, 0, filter_options);
transport = gsecondary;
}
static int do_fetch(struct transport *transport,
struct refspec *rs,
- const struct fetch_config *config)
+ const struct fetch_config *config,
+ struct list_objects_filter_options *filter_options)
{
struct ref_transaction *transaction = NULL;
struct ref *ref_map = NULL;
* the transaction and don't commit anything.
*/
if (backfill_tags(&display_state, transport, transaction, tags_ref_map,
- &fetch_head, config))
+ &fetch_head, config, filter_options))
retcode = 1;
}
* Fetching from the promisor remote should use the given filter-spec
* or inherit the default filter-spec from the config.
*/
-static inline void fetch_one_setup_partial(struct remote *remote)
+static inline void fetch_one_setup_partial(struct remote *remote,
+ struct list_objects_filter_options *filter_options)
{
/*
* Explicit --no-filter argument overrides everything, regardless
* of any prior partial clones and fetches.
*/
- if (filter_options.no_filter)
+ if (filter_options->no_filter)
return;
/*
* If no prior partial clone/fetch and the current fetch DID NOT
* request a partial-fetch, do a normal fetch.
*/
- if (!repo_has_promisor_remote(the_repository) && !filter_options.choice)
+ if (!repo_has_promisor_remote(the_repository) && !filter_options->choice)
return;
/*
* filter-spec as the default for subsequent fetches to this
* remote if there is currently no default filter-spec.
*/
- if (filter_options.choice) {
- partial_clone_register(remote->name, &filter_options);
+ if (filter_options->choice) {
+ partial_clone_register(remote->name, filter_options);
return;
}
* explicitly given filter-spec or inherit the filter-spec from
* the config.
*/
- if (!filter_options.choice)
- partial_clone_get_default_filter_spec(&filter_options, remote->name);
+ if (!filter_options->choice)
+ partial_clone_get_default_filter_spec(filter_options, remote->name);
return;
}
static int fetch_one(struct remote *remote, int argc, const char **argv,
int prune_tags_ok, int use_stdin_refspecs,
- const struct fetch_config *config)
+ const struct fetch_config *config,
+ struct list_objects_filter_options *filter_options)
{
struct refspec rs = REFSPEC_INIT_FETCH;
int i;
die(_("no remote repository specified; please specify either a URL or a\n"
"remote name from which new revisions should be fetched"));
- gtransport = prepare_transport(remote, 1);
+ gtransport = prepare_transport(remote, 1, filter_options);
if (prune < 0) {
/* no command line request */
sigchain_push_common(unlock_pack_on_signal);
atexit(unlock_pack_atexit);
sigchain_push(SIGPIPE, SIG_IGN);
- exit_code = do_fetch(gtransport, &rs, config);
+ exit_code = do_fetch(gtransport, &rs, config, filter_options);
sigchain_pop(SIGPIPE);
refspec_clear(&rs);
transport_disconnect(gtransport);
const char *submodule_prefix = "";
const char *bundle_uri;
struct string_list list = STRING_LIST_INIT_DUP;
+ struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT;
struct remote *remote = NULL;
int all = -1, multiple = 0;
int result = 0;
trace2_region_enter("fetch", "negotiate-only", the_repository);
if (!remote)
die(_("must supply remote when using --negotiate-only"));
- gtransport = prepare_transport(remote, 1);
+ gtransport = prepare_transport(remote, 1, &filter_options);
if (gtransport->smart_options) {
gtransport->smart_options->acked_commits = &acked_commits;
} else {
} else if (remote) {
if (filter_options.choice || repo_has_promisor_remote(the_repository)) {
trace2_region_enter("fetch", "setup-partial", the_repository);
- fetch_one_setup_partial(remote);
+ fetch_one_setup_partial(remote, &filter_options);
trace2_region_leave("fetch", "setup-partial", the_repository);
}
trace2_region_enter("fetch", "fetch-one", the_repository);
result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs,
- &config);
+ &config, &filter_options);
trace2_region_leave("fetch", "fetch-one", the_repository);
} else {
int max_children = max_jobs;
cleanup:
string_list_clear(&list, 0);
+ list_objects_filter_release(&filter_options);
return result;
}