]>
Commit | Line | Data |
---|---|---|
25ec7bca JH |
1 | #ifndef LIST_OBJECTS_FILTER_OPTIONS_H |
2 | #define LIST_OBJECTS_FILTER_OPTIONS_H | |
3 | ||
4 | #include "parse-options.h" | |
cf9ceb5a | 5 | #include "string-list.h" |
25ec7bca JH |
6 | |
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, | |
c813a7c3 | 14 | LOFC_TREE_DEPTH, |
25ec7bca | 15 | LOFC_SPARSE_OID, |
e987df5f | 16 | LOFC_COMBINE, |
25ec7bca JH |
17 | LOFC__COUNT /* must be last */ |
18 | }; | |
19 | ||
b9ea2147 TB |
20 | /* |
21 | * Returns a configuration key suitable for describing the given object filter, | |
22 | * e.g.: "blob:none", "combine", etc. | |
23 | */ | |
24 | const char *list_object_filter_config_name(enum list_objects_filter_choice c); | |
25 | ||
25ec7bca JH |
26 | struct list_objects_filter_options { |
27 | /* | |
28 | * 'filter_spec' is the raw argument value given on the command line | |
29 | * or protocol request. (The part after the "--keyword=".) For | |
87c2d9d3 JS |
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. | |
cf9ceb5a MD |
33 | * To get the raw filter spec given by the user, use the result of |
34 | * list_objects_filter_spec(). | |
25ec7bca | 35 | */ |
cf9ceb5a | 36 | struct string_list filter_spec; |
25ec7bca JH |
37 | |
38 | /* | |
39 | * 'choice' is determined by parsing the filter-spec. This indicates | |
40 | * the filtering algorithm to use. | |
41 | */ | |
42 | enum list_objects_filter_choice choice; | |
43 | ||
aa57b871 JH |
44 | /* |
45 | * Choice is LOFC_DISABLED because "--no-filter" was requested. | |
46 | */ | |
47 | unsigned int no_filter : 1; | |
48 | ||
25ec7bca | 49 | /* |
e987df5f MD |
50 | * BEGIN choice-specific parsed values from within the filter-spec. Only |
51 | * some values will be defined for any given choice. | |
25ec7bca | 52 | */ |
e987df5f | 53 | |
4c96a775 | 54 | char *sparse_oid_name; |
25ec7bca | 55 | unsigned long blob_limit_value; |
c813a7c3 | 56 | unsigned long tree_exclude_depth; |
e987df5f MD |
57 | |
58 | /* LOFC_COMBINE values */ | |
59 | ||
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; | |
63 | ||
64 | /* | |
65 | * END choice-specific parsed values. | |
66 | */ | |
25ec7bca JH |
67 | }; |
68 | ||
69 | /* Normalized command line arguments */ | |
70 | #define CL_ARG__FILTER "filter" | |
71 | ||
489fc9ee MD |
72 | void list_objects_filter_die_if_populated( |
73 | struct list_objects_filter_options *filter_options); | |
74 | ||
75 | /* | |
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:'. | |
80 | * | |
81 | * Dies and prints a user-facing message if an error occurs. | |
82 | */ | |
90d21f9e | 83 | void parse_list_objects_filter( |
25ec7bca JH |
84 | struct list_objects_filter_options *filter_options, |
85 | const char *arg); | |
86 | ||
87 | int opt_parse_list_objects_filter(const struct option *opt, | |
88 | const char *arg, int unset); | |
89 | ||
90 | #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \ | |
203c8533 DL |
91 | OPT_CALLBACK(0, CL_ARG__FILTER, fo, N_("args"), \ |
92 | N_("object filtering"), \ | |
93 | opt_parse_list_objects_filter) | |
25ec7bca | 94 | |
87c2d9d3 JS |
95 | /* |
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"). | |
cf9ceb5a | 98 | * Returns a string owned by the list_objects_filter_options object. |
87c2d9d3 | 99 | * |
cf9ceb5a MD |
100 | * This form should be used instead of the raw list_objects_filter_spec() |
101 | * value when communicating with a remote process or subprocess. | |
87c2d9d3 | 102 | */ |
cf9ceb5a MD |
103 | const char *expand_list_objects_filter_spec( |
104 | struct list_objects_filter_options *filter); | |
105 | ||
106 | /* | |
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. | |
111 | */ | |
112 | const char *list_objects_filter_spec( | |
113 | struct list_objects_filter_options *filter); | |
87c2d9d3 | 114 | |
4875c979 JH |
115 | void list_objects_filter_release( |
116 | struct list_objects_filter_options *filter_options); | |
117 | ||
aa57b871 JH |
118 | static inline void list_objects_filter_set_no_filter( |
119 | struct list_objects_filter_options *filter_options) | |
120 | { | |
121 | list_objects_filter_release(filter_options); | |
122 | filter_options->no_filter = 1; | |
123 | } | |
124 | ||
1e1e39b3 JH |
125 | void partial_clone_register( |
126 | const char *remote, | |
cf9ceb5a | 127 | struct list_objects_filter_options *filter_options); |
1e1e39b3 | 128 | void partial_clone_get_default_filter_spec( |
fa3d1b63 CC |
129 | struct list_objects_filter_options *filter_options, |
130 | const char *remote); | |
1e1e39b3 | 131 | |
25ec7bca | 132 | #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */ |