Skip to content

Commit

Permalink
Rename "refilter" to "repair"
Browse files Browse the repository at this point in the history
  • Loading branch information
olsen232 committed Feb 14, 2022
1 parent f5b5cf9 commit 93318cb
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 39 deletions.
13 changes: 7 additions & 6 deletions Documentation/fetch-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,13 @@ endif::git-pull[]
setting. See linkgit:git-config[1].

ifndef::git-pull[]
--refilter::
Reapply a partial clone filter from configuration or `--filter=`, such
as when the filter definition has changed. Instead of negotiating with
the server to avoid transferring commits and associated objects that are
already present locally, this option fetches all objects that match the
filter.
--repair::
Fetch all objects that match the filter, regardless of current state.
Can be used to reapply a partial clone filter from configuration or
`--filter=`, such as when the filter definition has changed. Instead of
negotiating with the server to avoid transferring commits and associated
objects that are already present locally, this option fetches all objects
that match the filter.
endif::git-pull[]

--refmap=<refspec>::
Expand Down
2 changes: 1 addition & 1 deletion Documentation/technical/partial-clone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Fetching Missing Objects
currently fetches all objects referred to by the requested objects, even
though they are not necessary.

- Fetching with `--refilter` will request a complete new filtered packfile from
- Fetching with `--repair` will request a complete new filtered packfile from
the remote, which can be used to change a filter without needing to
dynamically fetch missing objects.

Expand Down
4 changes: 2 additions & 2 deletions builtin/fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
args.from_promisor = 1;
continue;
}
if (!strcmp("--refilter", arg)) {
args.refilter = 1;
if (!strcmp("--repair", arg)) {
args.repair = 1;
continue;
}
if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
Expand Down
12 changes: 6 additions & 6 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static int prune_tags = -1; /* unspecified */

static int all, append, dry_run, force, keep, multiple, update_head_ok;
static int write_fetch_head = 1;
static int verbosity, deepen_relative, set_upstream, refilter;
static int verbosity, deepen_relative, set_upstream, repair;
static int progress = -1;
static int enable_auto_gc = 1;
static int tags = TAGS_DEFAULT, unshallow, update_shallow, deepen;
Expand Down Expand Up @@ -188,7 +188,7 @@ static struct option builtin_fetch_options[] = {
OPT_SET_INT_F(0, "unshallow", &unshallow,
N_("convert to a complete repository"),
1, PARSE_OPT_NONEG),
OPT_SET_INT_F(0, "refilter", &refilter,
OPT_SET_INT_F(0, "repair", &repair,
N_("re-fetch with a modified filter"),
1, PARSE_OPT_NONEG),
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"),
Expand Down Expand Up @@ -1288,13 +1288,13 @@ static int check_exist_and_connected(struct ref *ref_map)
return -1;

/*
* Similarly, if we need to refilter a partial clone we already have
* Similarly, if we need to repair a partial clone we already have
* these commits reachable. Running rev-list here will return with
* a good (0) exit status and we'll bypass the fetch that we
* really need to perform. Claiming failure now will ensure
* we perform the network exchange to reapply the filter.
*/
if (refilter)
if (repair)
return -1;


Expand Down Expand Up @@ -1493,8 +1493,8 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, "yes");
if (update_shallow)
set_option(transport, TRANS_OPT_UPDATE_SHALLOW, "yes");
if (refilter)
set_option(transport, TRANS_OPT_REFILTER, "yes");
if (repair)
set_option(transport, TRANS_OPT_REPAIR, "yes");
if (filter_options.choice) {
const char *spec =
expand_list_objects_filter_spec(&filter_options);
Expand Down
20 changes: 10 additions & 10 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ static int find_common(struct fetch_negotiator *negotiator,
const char *remote_hex;
struct object *o;

if (!args->refilter) {
if (!args->repair) {
/*
* If that object is complete (i.e. it is an ancestor of a
* local ref), we tell them we have it but do not have to
Expand Down Expand Up @@ -695,7 +695,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,

save_commit_buffer = 0;

if (args->refilter)
if (args->repair)
return;

trace2_region_enter("fetch-pack", "parse_remote_refs_and_find_cutoff", NULL);
Expand Down Expand Up @@ -1024,7 +1024,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
int agent_len;
struct fetch_negotiator negotiator_alloc;
struct fetch_negotiator *negotiator;
unsigned is_refiltering = 0;
unsigned is_repairing = 0;

sort_ref_list(&ref, ref_compare_name);
QSORT(sought, nr_sought, cmp_ref_by_name);
Expand Down Expand Up @@ -1094,12 +1094,12 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
if (server_supports("filter")) {
server_supports_filtering = 1;
print_verbose(args, _("Server supports %s"), "filter");
} else if (args->filter_options.choice || args->refilter) {
} else if (args->filter_options.choice || args->repair) {
warning("filtering not recognized by server, ignoring");
}

if (server_supports_filtering && args->refilter) {
is_refiltering = 1;
if (server_supports_filtering && args->repair) {
is_repairing = 1;
}

if (server_supports("deepen-since")) {
Expand All @@ -1120,15 +1120,15 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
die(_("Server does not support this repository's object format"));

negotiator = &negotiator_alloc;
if (is_refiltering) {
if (is_repairing) {
fetch_negotiator_init_noop(negotiator);
} else {
fetch_negotiator_init(r, negotiator);
}

mark_complete_and_common_ref(negotiator, args, &ref);
filter_refs(args, &ref, sought, nr_sought);
if (!is_refiltering && everything_local(args, &ref)) {
if (!is_repairing && everything_local(args, &ref)) {
packet_flush(fd[1]);
goto all_done;
}
Expand Down Expand Up @@ -1586,7 +1586,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
struct strvec index_pack_args = STRVEC_INIT;

negotiator = &negotiator_alloc;
if (args->refilter)
if (args->repair)
fetch_negotiator_init_noop(negotiator);
else
fetch_negotiator_init(r, negotiator);
Expand Down Expand Up @@ -1615,7 +1615,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
/* Filter 'ref' by 'sought' and those that aren't local */
mark_complete_and_common_ref(negotiator, args, &ref);
filter_refs(args, &ref, sought, nr_sought);
if (!args->refilter && everything_local(args, &ref))
if (!args->repair && everything_local(args, &ref))
state = FETCH_DONE;
else
state = FETCH_SEND_REQUEST;
Expand Down
2 changes: 1 addition & 1 deletion fetch-pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct fetch_pack_args {
unsigned update_shallow:1;
unsigned reject_shallow_remote:1;
unsigned deepen:1;
unsigned refilter:1;
unsigned repair:1;

/*
* Indicate that the remote of this request is a promisor remote. The
Expand Down
10 changes: 5 additions & 5 deletions t/t5616-partial-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,23 @@ test_expect_success 'push new commits to server for file.4.txt' '
git -C src push -u srv main
'

# Do partial fetch to fetch smaller files; then verify that without --refilter
# Do partial fetch to fetch smaller files; then verify that without --repair
# applying a new filter does not refetch missing large objects. Then use
# --refilter to apply the new filter on existing commits. Test it under both
# --repair to apply the new filter on existing commits. Test it under both
# protocol v2 & v0.
test_expect_success 'apply a different filter using --refilter' '
test_expect_success 'apply a different filter using --repair' '
git -C pc1 fetch --filter=blob:limit=999 origin &&
git -C pc1 rev-list --quiet --objects --missing=print \
main..origin/main >observed &&
test_line_count = 4 observed &&
git -C pc1 fetch --filter=blob:limit=19999 --refilter origin &&
git -C pc1 fetch --filter=blob:limit=19999 --repair origin &&
git -C pc1 rev-list --quiet --objects --missing=print \
main..origin/main >observed &&
test_line_count = 2 observed &&
git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 \
--refilter origin &&
--repair origin &&
git -C pc1 rev-list --quiet --objects --missing=print \
main..origin/main >observed &&
test_line_count = 0 observed
Expand Down
4 changes: 2 additions & 2 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ static int fetch_refs(struct transport *transport,
if (data->transport_options.update_shallow)
set_helper_option(transport, "update-shallow", "true");

if (data->transport_options.refilter)
set_helper_option(transport, "refilter", "true");
if (data->transport_options.repair)
set_helper_option(transport, "repair", "true");

if (data->transport_options.filter_options.choice) {
const char *spec = expand_list_objects_filter_spec(
Expand Down
6 changes: 3 additions & 3 deletions transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ static int set_git_option(struct git_transport_options *opts,
list_objects_filter_die_if_populated(&opts->filter_options);
parse_list_objects_filter(&opts->filter_options, value);
return 0;
} else if (!strcmp(name, TRANS_OPT_REFILTER)) {
opts->refilter = !!value;
} else if (!strcmp(name, TRANS_OPT_REPAIR)) {
opts->repair = !!value;
return 0;
} else if (!strcmp(name, TRANS_OPT_REJECT_SHALLOW)) {
opts->reject_shallow = !!value;
Expand Down Expand Up @@ -380,7 +380,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.update_shallow = data->options.update_shallow;
args.from_promisor = data->options.from_promisor;
args.filter_options = data->options.filter_options;
args.refilter = data->options.refilter;
args.repair = data->options.repair;
args.stateless_rpc = transport->stateless_rpc;
args.server_options = transport->server_options;
args.negotiation_tips = data->options.negotiation_tips;
Expand Down
6 changes: 3 additions & 3 deletions transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct git_transport_options {
unsigned update_shallow : 1;
unsigned reject_shallow : 1;
unsigned deepen_relative : 1;
unsigned refilter : 1;
unsigned repair : 1;

/* see documentation of corresponding flag in fetch-pack.h */
unsigned from_promisor : 1;
Expand Down Expand Up @@ -217,8 +217,8 @@ void transport_check_allowed(const char *type);
/* Filter objects for partial clone and fetch */
#define TRANS_OPT_LIST_OBJECTS_FILTER "filter"

/* Refilter a previous partial clone */
#define TRANS_OPT_REFILTER "refilter"
/* Fetch everything that matches filter, regardless of current state */
#define TRANS_OPT_REPAIR "repair"

/* Request atomic (all-or-nothing) updates when pushing */
#define TRANS_OPT_ATOMIC "atomic"
Expand Down

0 comments on commit 93318cb

Please sign in to comment.