Skip to content

Commit c4ea513

Browse files
derrickstoleegitster
authored andcommitted
rev-list: move --filter parsing into revision.c
Now that 'struct rev_info' has a 'filter' member and most consumers of object filtering are using that member instead of an external struct, move the parsing of the '--filter' option out of builtin/rev-list.c and into revision.c. This use within handle_revision_pseudo_opt() allows us to find the option within setup_revisions() if the arguments are passed directly. In the case of a command such as 'git blame', the arguments are first scanned and checked with parse_revision_opt(), which complains about the option, so 'git blame --filter=blob:none <file>' does not become valid with this change. Some commands, such as 'git diff' gain this option without having it make an effect. And 'git diff --objects' was already possible, but does not actually make sense in that builtin. The key addition that is coming is 'git bundle create --filter=<X>' so we can create bundles containing promisor packs. More work is required to make them fully functional, but that will follow. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 105c6f1 commit c4ea513

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

builtin/rev-list.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -591,17 +591,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
591591
show_progress = arg;
592592
continue;
593593
}
594-
595-
if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
596-
parse_list_objects_filter(&revs.filter, arg);
597-
if (revs.filter.choice && !revs.blob_objects)
598-
die(_("object filtering requires --objects"));
599-
continue;
600-
}
601-
if (!strcmp(arg, ("--no-" CL_ARG__FILTER))) {
602-
list_objects_filter_set_no_filter(&revs.filter);
603-
continue;
604-
}
605594
if (!strcmp(arg, "--filter-provided-objects")) {
606595
filter_provided_objects = 1;
607596
continue;

revision.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "utf8.h"
3333
#include "bloom.h"
3434
#include "json-writer.h"
35+
#include "list-objects-filter-options.h"
3536

3637
volatile show_early_output_fn_t show_early_output;
3738

@@ -2690,6 +2691,10 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
26902691
revs->no_walk = 0;
26912692
} else if (!strcmp(arg, "--single-worktree")) {
26922693
revs->single_worktree = 1;
2694+
} else if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
2695+
parse_list_objects_filter(&revs->filter, arg);
2696+
} else if (!strcmp(arg, ("--no-" CL_ARG__FILTER))) {
2697+
list_objects_filter_set_no_filter(&revs->filter);
26932698
} else {
26942699
return 0;
26952700
}
@@ -2894,6 +2899,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
28942899
die("cannot combine --walk-reflogs with history-limiting options");
28952900
if (revs->rewrite_parents && revs->children.name)
28962901
die(_("options '%s' and '%s' cannot be used together"), "--parents", "--children");
2902+
if (revs->filter.choice && !revs->blob_objects)
2903+
die(_("object filtering requires --objects"));
28972904

28982905
/*
28992906
* Limitations on the graph functionality

0 commit comments

Comments
 (0)