Merge branch 'nd/list-merge-strategy'
[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
6 /*
7  * The list of defined filters for list-objects.
8  */
9 enum list_objects_filter_choice {
10         LOFC_DISABLED = 0,
11         LOFC_BLOB_NONE,
12         LOFC_BLOB_LIMIT,
13         LOFC_SPARSE_OID,
14         LOFC_SPARSE_PATH,
15         LOFC__COUNT /* must be last */
16 };
17
18 struct list_objects_filter_options {
19         /*
20          * 'filter_spec' is the raw argument value given on the command line
21          * or protocol request.  (The part after the "--keyword=".)  For
22          * commands that launch filtering sub-processes, this value should be
23          * passed to them as received by the current process.
24          */
25         char *filter_spec;
26
27         /*
28          * 'choice' is determined by parsing the filter-spec.  This indicates
29          * the filtering algorithm to use.
30          */
31         enum list_objects_filter_choice choice;
32
33         /*
34          * Choice is LOFC_DISABLED because "--no-filter" was requested.
35          */
36         unsigned int no_filter : 1;
37
38         /*
39          * Parsed values (fields) from within the filter-spec.  These are
40          * choice-specific; not all values will be defined for any given
41          * choice.
42          */
43         struct object_id *sparse_oid_value;
44         char *sparse_path_value;
45         unsigned long blob_limit_value;
46 };
47
48 /* Normalized command line arguments */
49 #define CL_ARG__FILTER "filter"
50
51 int parse_list_objects_filter(
52         struct list_objects_filter_options *filter_options,
53         const char *arg);
54
55 int opt_parse_list_objects_filter(const struct option *opt,
56                                   const char *arg, int unset);
57
58 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
59         { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
60           N_("object filtering"), 0, \
61           opt_parse_list_objects_filter }
62
63 void list_objects_filter_release(
64         struct list_objects_filter_options *filter_options);
65
66 static inline void list_objects_filter_set_no_filter(
67         struct list_objects_filter_options *filter_options)
68 {
69         list_objects_filter_release(filter_options);
70         filter_options->no_filter = 1;
71 }
72
73 void partial_clone_register(
74         const char *remote,
75         const struct list_objects_filter_options *filter_options);
76 void partial_clone_get_default_filter_spec(
77         struct list_objects_filter_options *filter_options);
78
79 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */