Git 2.21-rc0
[alt-git.git] / list-objects-filter-options.h
blobe3adc78ebf74717d3b4e544c5bbb5215d9402a92
1 #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2 #define LIST_OBJECTS_FILTER_OPTIONS_H
4 #include "parse-options.h"
5 #include "strbuf.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_SPARSE_PATH,
17 LOFC__COUNT /* must be last */
20 struct list_objects_filter_options {
22 * 'filter_spec' is the raw argument value given on the command line
23 * or protocol request. (The part after the "--keyword=".) For
24 * commands that launch filtering sub-processes, or for communication
25 * over the network, don't use this value; use the result of
26 * expand_list_objects_filter_spec() instead.
28 char *filter_spec;
31 * 'choice' is determined by parsing the filter-spec. This indicates
32 * the filtering algorithm to use.
34 enum list_objects_filter_choice choice;
37 * Choice is LOFC_DISABLED because "--no-filter" was requested.
39 unsigned int no_filter : 1;
42 * Parsed values (fields) from within the filter-spec. These are
43 * choice-specific; not all values will be defined for any given
44 * choice.
46 struct object_id *sparse_oid_value;
47 char *sparse_path_value;
48 unsigned long blob_limit_value;
49 unsigned long tree_exclude_depth;
52 /* Normalized command line arguments */
53 #define CL_ARG__FILTER "filter"
55 int parse_list_objects_filter(
56 struct list_objects_filter_options *filter_options,
57 const char *arg);
59 int opt_parse_list_objects_filter(const struct option *opt,
60 const char *arg, int unset);
62 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
63 { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
64 N_("object filtering"), 0, \
65 opt_parse_list_objects_filter }
68 * Translates abbreviated numbers in the filter's filter_spec into their
69 * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024").
71 * This form should be used instead of the raw filter_spec field when
72 * communicating with a remote process or subprocess.
74 void expand_list_objects_filter_spec(
75 const struct list_objects_filter_options *filter,
76 struct strbuf *expanded_spec);
78 void list_objects_filter_release(
79 struct list_objects_filter_options *filter_options);
81 static inline void list_objects_filter_set_no_filter(
82 struct list_objects_filter_options *filter_options)
84 list_objects_filter_release(filter_options);
85 filter_options->no_filter = 1;
88 void partial_clone_register(
89 const char *remote,
90 const struct list_objects_filter_options *filter_options);
91 void partial_clone_get_default_filter_spec(
92 struct list_objects_filter_options *filter_options);
94 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */