Skip to content

add --must-filter, give error on filter not supported instead of warn #1869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ int cmd_clone(int argc,
enum ref_storage_format ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;
const int do_not_override_repo_unix_permissions = -1;
int option_reject_shallow = -1; /* unspecified */
int must_filter = 0;
int deepen = 0;
char *option_template = NULL, *option_depth = NULL, *option_since = NULL;
char *option_origin = NULL;
Expand Down Expand Up @@ -915,6 +916,8 @@ int cmd_clone(int argc,
N_("force progress reporting")),
OPT_BOOL(0, "reject-shallow", &option_reject_shallow,
N_("don't clone shallow repository")),
OPT_BOOL(0, "must-filter", &must_filter,
N_("error on filter not supported by server")),
OPT_BOOL('n', "no-checkout", &option_no_checkout,
N_("don't create a checkout")),
OPT_BOOL(0, "bare", &option_bare, N_("create a bare repository")),
Expand Down Expand Up @@ -1333,6 +1336,9 @@ int cmd_clone(int argc,
transport_set_verbosity(transport, option_verbosity, option_progress);
transport->family = family;
transport->cloning = 1;
if (transport->smart_options) {
transport->smart_options->must_filter = must_filter;
}

if (is_bundle) {
struct bundle_header header = BUNDLE_HEADER_INIT;
Expand Down
7 changes: 6 additions & 1 deletion builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int prune_tags = -1; /* unspecified */

static int append, dry_run, force, keep, update_head_ok;
static int write_fetch_head = 1;
static int verbosity, deepen_relative, set_upstream, refetch;
static int verbosity, deepen_relative, set_upstream, refetch, must_filter;
static int progress = -1;
static int tags = TAGS_DEFAULT, update_shallow, deepen;
static int atomic_fetch;
Expand Down Expand Up @@ -1508,6 +1508,9 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
transport = transport_get(remote, NULL);
transport_set_verbosity(transport, verbosity, progress);
transport->family = family;
if (transport->smart_options) {
transport->smart_options->must_filter = must_filter;
}
if (upload_pack)
set_option(transport, TRANS_OPT_UPLOADPACK, upload_pack);
if (keep)
Expand Down Expand Up @@ -2322,6 +2325,8 @@ int cmd_fetch(int argc,
N_("append to .git/FETCH_HEAD instead of overwriting")),
OPT_BOOL(0, "atomic", &atomic_fetch,
N_("use atomic transaction to update references")),
OPT_BOOL(0, "must-filter", &must_filter,
N_("error on filter not supported by server")),
OPT_STRING(0, "upload-pack", &upload_pack, N_("path"),
N_("path to upload pack on remote end")),
OPT__FORCE(&force, N_("force overwrite of local reference"), 0),
Expand Down
8 changes: 6 additions & 2 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,13 @@ static void send_filter(struct fetch_pack_args *args,
trace2_data_string("fetch", the_repository,
"filter/effective", spec);
} else {
warning("filtering not recognized by server, ignoring");
trace2_data_string("fetch", the_repository,
if (args->must_filter) {
die("filtering not recognized by server");
} else {
warning("filtering not recognized by server, ignoring");
trace2_data_string("fetch", the_repository,
"filter/unsupported", spec);
}
}
} else {
trace2_data_string("fetch", the_repository,
Expand Down
1 change: 1 addition & 0 deletions fetch-pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct fetch_pack_args {
unsigned cloning:1;
unsigned update_shallow:1;
unsigned reject_shallow_remote:1;
unsigned must_filter:1;
unsigned deepen:1;
unsigned refetch:1;

Expand Down
17 changes: 17 additions & 0 deletions t/t0410-partial-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ test_expect_success 'convert shallow clone to partial clone' '
test_cmp_config -C client 1 core.repositoryformatversion
'

test_expect_failure 'must filter clone' '
rm -fr server client &&
test_create_repo server &&
test_commit -C server my_commit 1 &&
test_commit -C server my_commit2 1 &&
git clone --filter="blob:none" --must-filter "file://$(pwd)/server" client
'

test_expect_failure 'must filter fetch' '
rm -fr server client &&
test_create_repo server &&
test_commit -C server my_commit 1 &&
test_commit -C server my_commit2 1 &&
git clone --depth=1 "file://$(pwd)/server" client &&
git -C client fetch --unshallow --filter="blob:none" --must-filter
'

test_expect_success DEFAULT_REPO_FORMAT 'convert to partial clone with noop extension' '
rm -fr server client &&
test_create_repo server &&
Expand Down
1 change: 1 addition & 0 deletions transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.quiet = (transport->verbose < 0);
args.no_progress = !transport->progress;
args.depth = data->options.depth;
args.must_filter = data->options.must_filter;
args.deepen_since = data->options.deepen_since;
args.deepen_not = data->options.deepen_not;
args.deepen_relative = data->options.deepen_relative;
Expand Down
1 change: 1 addition & 0 deletions transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct git_transport_options {
unsigned reject_shallow : 1;
unsigned deepen_relative : 1;
unsigned refetch : 1;
unsigned must_filter : 1;

/* see documentation of corresponding flag in fetch-pack.h */
unsigned from_promisor : 1;
Expand Down
Loading