l10n: Update Catalan translation
[alt-git.git] / list-objects-filter-options.h
blob7eeadab2dd0551c5eea8f7f14cd741841317230e
1 #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2 #define LIST_OBJECTS_FILTER_OPTIONS_H
4 #include "cache.h"
5 #include "parse-options.h"
6 #include "string-list.h"
8 /*
9 * The list of defined filters for list-objects.
11 enum list_objects_filter_choice {
12 LOFC_DISABLED = 0,
13 LOFC_BLOB_NONE,
14 LOFC_BLOB_LIMIT,
15 LOFC_TREE_DEPTH,
16 LOFC_SPARSE_OID,
17 LOFC_OBJECT_TYPE,
18 LOFC_COMBINE,
19 LOFC__COUNT /* must be last */
23 * Returns a configuration key suitable for describing the given object filter,
24 * e.g.: "blob:none", "combine", etc.
26 const char *list_object_filter_config_name(enum list_objects_filter_choice c);
28 struct list_objects_filter_options {
30 * 'filter_spec' is the raw argument value given on the command line
31 * or protocol request. (The part after the "--keyword=".) For
32 * commands that launch filtering sub-processes, or for communication
33 * over the network, don't use this value; use the result of
34 * expand_list_objects_filter_spec() instead.
35 * To get the raw filter spec given by the user, use the result of
36 * list_objects_filter_spec().
38 struct strbuf filter_spec;
41 * 'choice' is determined by parsing the filter-spec. This indicates
42 * the filtering algorithm to use.
44 enum list_objects_filter_choice choice;
47 * Choice is LOFC_DISABLED because "--no-filter" was requested.
49 unsigned int no_filter : 1;
52 * BEGIN choice-specific parsed values from within the filter-spec. Only
53 * some values will be defined for any given choice.
56 char *sparse_oid_name;
57 unsigned long blob_limit_value;
58 unsigned long tree_exclude_depth;
59 enum object_type object_type;
61 /* LOFC_COMBINE values */
63 /* This array contains all the subfilters which this filter combines. */
64 size_t sub_nr, sub_alloc;
65 struct list_objects_filter_options *sub;
68 * END choice-specific parsed values.
72 #define LIST_OBJECTS_FILTER_INIT { .filter_spec = STRBUF_INIT }
73 void list_objects_filter_init(struct list_objects_filter_options *filter_options);
76 * Parse value of the argument to the "filter" keyword.
77 * On the command line this looks like:
78 * --filter=<arg>
79 * and in the pack protocol as:
80 * "filter" SP <arg>
82 * The filter keyword will be used by many commands.
83 * See Documentation/rev-list-options.txt for allowed values for <arg>.
85 * Capture the given arg as the "filter_spec". This can be forwarded to
86 * subordinate commands when necessary (although it's better to pass it through
87 * expand_list_objects_filter_spec() first). We also "intern" the arg for the
88 * convenience of the current command.
90 int gently_parse_list_objects_filter(
91 struct list_objects_filter_options *filter_options,
92 const char *arg,
93 struct strbuf *errbuf);
95 void list_objects_filter_die_if_populated(
96 struct list_objects_filter_options *filter_options);
99 * Parses the filter spec string given by arg and either (1) simply places the
100 * result in filter_options if it is not yet populated or (2) combines it with
101 * the filter already in filter_options if it is already populated. In the case
102 * of (2), the filter specs are combined as if specified with 'combine:'.
104 * Dies and prints a user-facing message if an error occurs.
106 void parse_list_objects_filter(
107 struct list_objects_filter_options *filter_options,
108 const char *arg);
111 * The opt->value to opt_parse_list_objects_filter() is either a
112 * "struct list_objects_filter_option *" when using
113 * OPT_PARSE_LIST_OBJECTS_FILTER().
115 * Or, if using no "struct option" field is used by the callback,
116 * except the "defval" which is expected to be an "opt_lof_init"
117 * function, which is called with the "opt->value" and must return a
118 * pointer to the ""struct list_objects_filter_option *" to be used.
120 * The OPT_PARSE_LIST_OBJECTS_FILTER_INIT() can be used e.g. the
121 * "struct list_objects_filter_option" is embedded in a "struct
122 * rev_info", which the "defval" could be tasked with lazily
123 * initializing. See cmd_pack_objects() for an example.
125 int opt_parse_list_objects_filter(const struct option *opt,
126 const char *arg, int unset);
127 typedef struct list_objects_filter_options *(*opt_lof_init)(void *);
128 #define OPT_PARSE_LIST_OBJECTS_FILTER_INIT(fo, init) \
129 { OPTION_CALLBACK, 0, "filter", (fo), N_("args"), \
130 N_("object filtering"), 0, opt_parse_list_objects_filter, \
131 (intptr_t)(init) }
133 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
134 OPT_PARSE_LIST_OBJECTS_FILTER_INIT((fo), NULL)
137 * Translates abbreviated numbers in the filter's filter_spec into their
138 * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024").
139 * Returns a string owned by the list_objects_filter_options object.
141 * This form should be used instead of the raw list_objects_filter_spec()
142 * value when communicating with a remote process or subprocess.
144 const char *expand_list_objects_filter_spec(
145 struct list_objects_filter_options *filter);
148 * Returns the filter spec string more or less in the form as the user
149 * entered it. This form of the filter_spec can be used in user-facing
150 * messages. Returns a string owned by the list_objects_filter_options
151 * object.
153 const char *list_objects_filter_spec(
154 struct list_objects_filter_options *filter);
156 void list_objects_filter_release(
157 struct list_objects_filter_options *filter_options);
159 static inline void list_objects_filter_set_no_filter(
160 struct list_objects_filter_options *filter_options)
162 list_objects_filter_release(filter_options);
163 filter_options->no_filter = 1;
166 void partial_clone_register(
167 const char *remote,
168 struct list_objects_filter_options *filter_options);
169 void partial_clone_get_default_filter_spec(
170 struct list_objects_filter_options *filter_options,
171 const char *remote);
173 void list_objects_filter_copy(
174 struct list_objects_filter_options *dest,
175 const struct list_objects_filter_options *src);
177 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */