]>
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" | |
87c2d9d3 | 5 | #include "strbuf.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 | ||
20 | struct list_objects_filter_options { | |
21 | /* | |
22 | * 'filter_spec' is the raw argument value given on the command line | |
23 | * or protocol request. (The part after the "--keyword=".) For | |
87c2d9d3 JS |
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. | |
25ec7bca JH |
27 | */ |
28 | char *filter_spec; | |
29 | ||
30 | /* | |
31 | * 'choice' is determined by parsing the filter-spec. This indicates | |
32 | * the filtering algorithm to use. | |
33 | */ | |
34 | enum list_objects_filter_choice choice; | |
35 | ||
aa57b871 JH |
36 | /* |
37 | * Choice is LOFC_DISABLED because "--no-filter" was requested. | |
38 | */ | |
39 | unsigned int no_filter : 1; | |
40 | ||
25ec7bca | 41 | /* |
e987df5f MD |
42 | * BEGIN choice-specific parsed values from within the filter-spec. Only |
43 | * some values will be defined for any given choice. | |
25ec7bca | 44 | */ |
e987df5f | 45 | |
25ec7bca | 46 | struct object_id *sparse_oid_value; |
25ec7bca | 47 | unsigned long blob_limit_value; |
c813a7c3 | 48 | unsigned long tree_exclude_depth; |
e987df5f MD |
49 | |
50 | /* LOFC_COMBINE values */ | |
51 | ||
52 | /* This array contains all the subfilters which this filter combines. */ | |
53 | size_t sub_nr, sub_alloc; | |
54 | struct list_objects_filter_options *sub; | |
55 | ||
56 | /* | |
57 | * END choice-specific parsed values. | |
58 | */ | |
25ec7bca JH |
59 | }; |
60 | ||
61 | /* Normalized command line arguments */ | |
62 | #define CL_ARG__FILTER "filter" | |
63 | ||
64 | int parse_list_objects_filter( | |
65 | struct list_objects_filter_options *filter_options, | |
66 | const char *arg); | |
67 | ||
68 | int opt_parse_list_objects_filter(const struct option *opt, | |
69 | const char *arg, int unset); | |
70 | ||
71 | #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \ | |
72 | { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \ | |
4875c979 | 73 | N_("object filtering"), 0, \ |
25ec7bca JH |
74 | opt_parse_list_objects_filter } |
75 | ||
87c2d9d3 JS |
76 | /* |
77 | * Translates abbreviated numbers in the filter's filter_spec into their | |
78 | * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024"). | |
79 | * | |
80 | * This form should be used instead of the raw filter_spec field when | |
81 | * communicating with a remote process or subprocess. | |
82 | */ | |
83 | void expand_list_objects_filter_spec( | |
84 | const struct list_objects_filter_options *filter, | |
85 | struct strbuf *expanded_spec); | |
86 | ||
4875c979 JH |
87 | void list_objects_filter_release( |
88 | struct list_objects_filter_options *filter_options); | |
89 | ||
aa57b871 JH |
90 | static inline void list_objects_filter_set_no_filter( |
91 | struct list_objects_filter_options *filter_options) | |
92 | { | |
93 | list_objects_filter_release(filter_options); | |
94 | filter_options->no_filter = 1; | |
95 | } | |
96 | ||
1e1e39b3 JH |
97 | void partial_clone_register( |
98 | const char *remote, | |
99 | const struct list_objects_filter_options *filter_options); | |
100 | void partial_clone_get_default_filter_spec( | |
101 | struct list_objects_filter_options *filter_options); | |
102 | ||
25ec7bca | 103 | #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */ |