]> git.ipfire.org Git - thirdparty/git.git/blame - list-objects-filter-options.h
bundle: output hash information in 'verify'
[thirdparty/git.git] / list-objects-filter-options.h
CommitLineData
25ec7bca
JH
1#ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2#define LIST_OBJECTS_FILTER_OPTIONS_H
3
b0c42a53 4#include "cache.h"
25ec7bca 5#include "parse-options.h"
cf9ceb5a 6#include "string-list.h"
25ec7bca
JH
7
8/*
9 * The list of defined filters for list-objects.
10 */
11enum list_objects_filter_choice {
12 LOFC_DISABLED = 0,
13 LOFC_BLOB_NONE,
14 LOFC_BLOB_LIMIT,
c813a7c3 15 LOFC_TREE_DEPTH,
25ec7bca 16 LOFC_SPARSE_OID,
b0c42a53 17 LOFC_OBJECT_TYPE,
e987df5f 18 LOFC_COMBINE,
25ec7bca
JH
19 LOFC__COUNT /* must be last */
20};
21
b9ea2147
TB
22/*
23 * Returns a configuration key suitable for describing the given object filter,
24 * e.g.: "blob:none", "combine", etc.
25 */
26const char *list_object_filter_config_name(enum list_objects_filter_choice c);
27
25ec7bca
JH
28struct list_objects_filter_options {
29 /*
30 * 'filter_spec' is the raw argument value given on the command line
31 * or protocol request. (The part after the "--keyword=".) For
87c2d9d3
JS
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.
cf9ceb5a
MD
35 * To get the raw filter spec given by the user, use the result of
36 * list_objects_filter_spec().
25ec7bca 37 */
cf9ceb5a 38 struct string_list filter_spec;
25ec7bca
JH
39
40 /*
41 * 'choice' is determined by parsing the filter-spec. This indicates
42 * the filtering algorithm to use.
43 */
44 enum list_objects_filter_choice choice;
45
aa57b871
JH
46 /*
47 * Choice is LOFC_DISABLED because "--no-filter" was requested.
48 */
49 unsigned int no_filter : 1;
50
25ec7bca 51 /*
e987df5f
MD
52 * BEGIN choice-specific parsed values from within the filter-spec. Only
53 * some values will be defined for any given choice.
25ec7bca 54 */
e987df5f 55
4c96a775 56 char *sparse_oid_name;
25ec7bca 57 unsigned long blob_limit_value;
c813a7c3 58 unsigned long tree_exclude_depth;
b0c42a53 59 enum object_type object_type;
e987df5f
MD
60
61 /* LOFC_COMBINE values */
62
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;
66
67 /*
68 * END choice-specific parsed values.
69 */
25ec7bca
JH
70};
71
105c6f14
DS
72/*
73 * Parse value of the argument to the "filter" keyword.
74 * On the command line this looks like:
75 * --filter=<arg>
76 * and in the pack protocol as:
77 * "filter" SP <arg>
78 *
79 * The filter keyword will be used by many commands.
80 * See Documentation/rev-list-options.txt for allowed values for <arg>.
81 *
82 * Capture the given arg as the "filter_spec". This can be forwarded to
83 * subordinate commands when necessary (although it's better to pass it through
84 * expand_list_objects_filter_spec() first). We also "intern" the arg for the
85 * convenience of the current command.
86 */
87int gently_parse_list_objects_filter(
88 struct list_objects_filter_options *filter_options,
89 const char *arg,
90 struct strbuf *errbuf);
91
489fc9ee
MD
92void list_objects_filter_die_if_populated(
93 struct list_objects_filter_options *filter_options);
94
95/*
96 * Parses the filter spec string given by arg and either (1) simply places the
97 * result in filter_options if it is not yet populated or (2) combines it with
98 * the filter already in filter_options if it is already populated. In the case
99 * of (2), the filter specs are combined as if specified with 'combine:'.
100 *
101 * Dies and prints a user-facing message if an error occurs.
102 */
90d21f9e 103void parse_list_objects_filter(
25ec7bca
JH
104 struct list_objects_filter_options *filter_options,
105 const char *arg);
106
107int opt_parse_list_objects_filter(const struct option *opt,
108 const char *arg, int unset);
109
110#define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
cc910442 111 OPT_CALLBACK(0, "filter", fo, N_("args"), \
203c8533
DL
112 N_("object filtering"), \
113 opt_parse_list_objects_filter)
25ec7bca 114
87c2d9d3
JS
115/*
116 * Translates abbreviated numbers in the filter's filter_spec into their
117 * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024").
cf9ceb5a 118 * Returns a string owned by the list_objects_filter_options object.
87c2d9d3 119 *
cf9ceb5a
MD
120 * This form should be used instead of the raw list_objects_filter_spec()
121 * value when communicating with a remote process or subprocess.
87c2d9d3 122 */
cf9ceb5a
MD
123const char *expand_list_objects_filter_spec(
124 struct list_objects_filter_options *filter);
125
126/*
127 * Returns the filter spec string more or less in the form as the user
128 * entered it. This form of the filter_spec can be used in user-facing
129 * messages. Returns a string owned by the list_objects_filter_options
130 * object.
131 */
132const char *list_objects_filter_spec(
133 struct list_objects_filter_options *filter);
87c2d9d3 134
4875c979
JH
135void list_objects_filter_release(
136 struct list_objects_filter_options *filter_options);
137
aa57b871
JH
138static inline void list_objects_filter_set_no_filter(
139 struct list_objects_filter_options *filter_options)
140{
141 list_objects_filter_release(filter_options);
142 filter_options->no_filter = 1;
143}
144
1e1e39b3
JH
145void partial_clone_register(
146 const char *remote,
cf9ceb5a 147 struct list_objects_filter_options *filter_options);
1e1e39b3 148void partial_clone_get_default_filter_spec(
fa3d1b63
CC
149 struct list_objects_filter_options *filter_options,
150 const char *remote);
1e1e39b3 151
4a4c3f9b
DS
152void list_objects_filter_copy(
153 struct list_objects_filter_options *dest,
154 const struct list_objects_filter_options *src);
155
25ec7bca 156#endif /* LIST_OBJECTS_FILTER_OPTIONS_H */