treewide: remove unnecessary inclusions of parse-options.h from headers
[git/debian.git] / list-objects-filter-options.h
blobaad295f2327996b82f4b568d42cb88a3aa278cba
1 #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2 #define LIST_OBJECTS_FILTER_OPTIONS_H
4 #include "cache.h"
5 #include "string-list.h"
7 struct option;
9 /*
10 * The list of defined filters for list-objects.
12 enum list_objects_filter_choice {
13 LOFC_DISABLED = 0,
14 LOFC_BLOB_NONE,
15 LOFC_BLOB_LIMIT,
16 LOFC_TREE_DEPTH,
17 LOFC_SPARSE_OID,
18 LOFC_OBJECT_TYPE,
19 LOFC_COMBINE,
20 LOFC__COUNT /* must be last */
24 * Returns a configuration key suitable for describing the given object filter,
25 * e.g.: "blob:none", "combine", etc.
27 const char *list_object_filter_config_name(enum list_objects_filter_choice c);
29 struct list_objects_filter_options {
31 * 'filter_spec' is the raw argument value given on the command line
32 * or protocol request. (The part after the "--keyword=".) For
33 * commands that launch filtering sub-processes, or for communication
34 * over the network, don't use this value; use the result of
35 * expand_list_objects_filter_spec() instead.
36 * To get the raw filter spec given by the user, use the result of
37 * list_objects_filter_spec().
39 struct strbuf filter_spec;
42 * 'choice' is determined by parsing the filter-spec. This indicates
43 * the filtering algorithm to use.
45 enum list_objects_filter_choice choice;
48 * Choice is LOFC_DISABLED because "--no-filter" was requested.
50 unsigned int no_filter : 1;
53 * BEGIN choice-specific parsed values from within the filter-spec. Only
54 * some values will be defined for any given choice.
57 char *sparse_oid_name;
58 unsigned long blob_limit_value;
59 unsigned long tree_exclude_depth;
60 enum object_type object_type;
62 /* LOFC_COMBINE values */
64 /* This array contains all the subfilters which this filter combines. */
65 size_t sub_nr, sub_alloc;
66 struct list_objects_filter_options *sub;
69 * END choice-specific parsed values.
73 #define LIST_OBJECTS_FILTER_INIT { .filter_spec = STRBUF_INIT }
74 void list_objects_filter_init(struct list_objects_filter_options *filter_options);
77 * Parse value of the argument to the "filter" keyword.
78 * On the command line this looks like:
79 * --filter=<arg>
80 * and in the pack protocol as:
81 * "filter" SP <arg>
83 * The filter keyword will be used by many commands.
84 * See Documentation/rev-list-options.txt for allowed values for <arg>.
86 * Capture the given arg as the "filter_spec". This can be forwarded to
87 * subordinate commands when necessary (although it's better to pass it through
88 * expand_list_objects_filter_spec() first). We also "intern" the arg for the
89 * convenience of the current command.
91 int gently_parse_list_objects_filter(
92 struct list_objects_filter_options *filter_options,
93 const char *arg,
94 struct strbuf *errbuf);
96 void list_objects_filter_die_if_populated(
97 struct list_objects_filter_options *filter_options);
100 * Parses the filter spec string given by arg and either (1) simply places the
101 * result in filter_options if it is not yet populated or (2) combines it with
102 * the filter already in filter_options if it is already populated. In the case
103 * of (2), the filter specs are combined as if specified with 'combine:'.
105 * Dies and prints a user-facing message if an error occurs.
107 void parse_list_objects_filter(
108 struct list_objects_filter_options *filter_options,
109 const char *arg);
112 * The opt->value to opt_parse_list_objects_filter() is either a
113 * "struct list_objects_filter_option *" when using
114 * OPT_PARSE_LIST_OBJECTS_FILTER().
116 int opt_parse_list_objects_filter(const struct option *opt,
117 const char *arg, int unset);
119 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
120 OPT_CALLBACK(0, "filter", (fo), N_("args"), \
121 N_("object filtering"), opt_parse_list_objects_filter)
124 * Translates abbreviated numbers in the filter's filter_spec into their
125 * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024").
126 * Returns a string owned by the list_objects_filter_options object.
128 * This form should be used instead of the raw list_objects_filter_spec()
129 * value when communicating with a remote process or subprocess.
131 const char *expand_list_objects_filter_spec(
132 struct list_objects_filter_options *filter);
135 * Returns the filter spec string more or less in the form as the user
136 * entered it. This form of the filter_spec can be used in user-facing
137 * messages. Returns a string owned by the list_objects_filter_options
138 * object.
140 const char *list_objects_filter_spec(
141 struct list_objects_filter_options *filter);
143 void list_objects_filter_release(
144 struct list_objects_filter_options *filter_options);
146 static inline void list_objects_filter_set_no_filter(
147 struct list_objects_filter_options *filter_options)
149 list_objects_filter_release(filter_options);
150 filter_options->no_filter = 1;
153 void partial_clone_register(
154 const char *remote,
155 struct list_objects_filter_options *filter_options);
156 void partial_clone_get_default_filter_spec(
157 struct list_objects_filter_options *filter_options,
158 const char *remote);
160 void list_objects_filter_copy(
161 struct list_objects_filter_options *dest,
162 const struct list_objects_filter_options *src);
164 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */