pickaxe -S: support content with NULs under --pickaxe-regex
[git/debian.git] / list-objects-filter-options.h
blob01767c3c968f33440aac3095a25d8cc08bec3659
1 #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2 #define LIST_OBJECTS_FILTER_OPTIONS_H
4 #include "parse-options.h"
5 #include "string-list.h"
7 /*
8 * The list of defined filters for list-objects.
9 */
10 enum list_objects_filter_choice {
11 LOFC_DISABLED = 0,
12 LOFC_BLOB_NONE,
13 LOFC_BLOB_LIMIT,
14 LOFC_TREE_DEPTH,
15 LOFC_SPARSE_OID,
16 LOFC_COMBINE,
17 LOFC__COUNT /* must be last */
21 * Returns a configuration key suitable for describing the given object filter,
22 * e.g.: "blob:none", "combine", etc.
24 const char *list_object_filter_config_name(enum list_objects_filter_choice c);
26 struct list_objects_filter_options {
28 * 'filter_spec' is the raw argument value given on the command line
29 * or protocol request. (The part after the "--keyword=".) For
30 * commands that launch filtering sub-processes, or for communication
31 * over the network, don't use this value; use the result of
32 * expand_list_objects_filter_spec() instead.
33 * To get the raw filter spec given by the user, use the result of
34 * list_objects_filter_spec().
36 struct string_list filter_spec;
39 * 'choice' is determined by parsing the filter-spec. This indicates
40 * the filtering algorithm to use.
42 enum list_objects_filter_choice choice;
45 * Choice is LOFC_DISABLED because "--no-filter" was requested.
47 unsigned int no_filter : 1;
50 * BEGIN choice-specific parsed values from within the filter-spec. Only
51 * some values will be defined for any given choice.
54 char *sparse_oid_name;
55 unsigned long blob_limit_value;
56 unsigned long tree_exclude_depth;
58 /* LOFC_COMBINE values */
60 /* This array contains all the subfilters which this filter combines. */
61 size_t sub_nr, sub_alloc;
62 struct list_objects_filter_options *sub;
65 * END choice-specific parsed values.
69 /* Normalized command line arguments */
70 #define CL_ARG__FILTER "filter"
72 void list_objects_filter_die_if_populated(
73 struct list_objects_filter_options *filter_options);
76 * Parses the filter spec string given by arg and either (1) simply places the
77 * result in filter_options if it is not yet populated or (2) combines it with
78 * the filter already in filter_options if it is already populated. In the case
79 * of (2), the filter specs are combined as if specified with 'combine:'.
81 * Dies and prints a user-facing message if an error occurs.
83 void parse_list_objects_filter(
84 struct list_objects_filter_options *filter_options,
85 const char *arg);
87 int opt_parse_list_objects_filter(const struct option *opt,
88 const char *arg, int unset);
90 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
91 OPT_CALLBACK(0, CL_ARG__FILTER, fo, N_("args"), \
92 N_("object filtering"), \
93 opt_parse_list_objects_filter)
96 * Translates abbreviated numbers in the filter's filter_spec into their
97 * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024").
98 * Returns a string owned by the list_objects_filter_options object.
100 * This form should be used instead of the raw list_objects_filter_spec()
101 * value when communicating with a remote process or subprocess.
103 const char *expand_list_objects_filter_spec(
104 struct list_objects_filter_options *filter);
107 * Returns the filter spec string more or less in the form as the user
108 * entered it. This form of the filter_spec can be used in user-facing
109 * messages. Returns a string owned by the list_objects_filter_options
110 * object.
112 const char *list_objects_filter_spec(
113 struct list_objects_filter_options *filter);
115 void list_objects_filter_release(
116 struct list_objects_filter_options *filter_options);
118 static inline void list_objects_filter_set_no_filter(
119 struct list_objects_filter_options *filter_options)
121 list_objects_filter_release(filter_options);
122 filter_options->no_filter = 1;
125 void partial_clone_register(
126 const char *remote,
127 struct list_objects_filter_options *filter_options);
128 void partial_clone_get_default_filter_spec(
129 struct list_objects_filter_options *filter_options,
130 const char *remote);
132 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */