]> git.ipfire.org Git - thirdparty/git.git/blob - list-objects-filter-options.h
config.mak.uname: remove unused the NO_R_TO_GCC_LINKER flag
[thirdparty/git.git] / list-objects-filter-options.h
1 #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2 #define LIST_OBJECTS_FILTER_OPTIONS_H
3
4 #include "parse-options.h"
5 #include "string-list.h"
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,
14 LOFC_TREE_DEPTH,
15 LOFC_SPARSE_OID,
16 LOFC_COMBINE,
17 LOFC__COUNT /* must be last */
18 };
19
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
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
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.
33 * To get the raw filter spec given by the user, use the result of
34 * list_objects_filter_spec().
35 */
36 struct string_list filter_spec;
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
44 /*
45 * Choice is LOFC_DISABLED because "--no-filter" was requested.
46 */
47 unsigned int no_filter : 1;
48
49 /*
50 * BEGIN choice-specific parsed values from within the filter-spec. Only
51 * some values will be defined for any given choice.
52 */
53
54 char *sparse_oid_name;
55 unsigned long blob_limit_value;
56 unsigned long tree_exclude_depth;
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 */
67 };
68
69 /* Normalized command line arguments */
70 #define CL_ARG__FILTER "filter"
71
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 */
83 void parse_list_objects_filter(
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) \
91 OPT_CALLBACK(0, CL_ARG__FILTER, fo, N_("args"), \
92 N_("object filtering"), \
93 opt_parse_list_objects_filter)
94
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").
98 * Returns a string owned by the list_objects_filter_options object.
99 *
100 * This form should be used instead of the raw list_objects_filter_spec()
101 * value when communicating with a remote process or subprocess.
102 */
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);
114
115 void list_objects_filter_release(
116 struct list_objects_filter_options *filter_options);
117
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
125 void partial_clone_register(
126 const char *remote,
127 struct list_objects_filter_options *filter_options);
128 void partial_clone_get_default_filter_spec(
129 struct list_objects_filter_options *filter_options,
130 const char *remote);
131
132 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */