t3431: add rebase --fork-point tests
[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 "strbuf.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__COUNT /* must be last */
17 };
18
19 struct list_objects_filter_options {
20         /*
21          * 'filter_spec' is the raw argument value given on the command line
22          * or protocol request.  (The part after the "--keyword=".)  For
23          * commands that launch filtering sub-processes, or for communication
24          * over the network, don't use this value; use the result of
25          * expand_list_objects_filter_spec() instead.
26          */
27         char *filter_spec;
28
29         /*
30          * 'choice' is determined by parsing the filter-spec.  This indicates
31          * the filtering algorithm to use.
32          */
33         enum list_objects_filter_choice choice;
34
35         /*
36          * Choice is LOFC_DISABLED because "--no-filter" was requested.
37          */
38         unsigned int no_filter : 1;
39
40         /*
41          * Parsed values (fields) from within the filter-spec.  These are
42          * choice-specific; not all values will be defined for any given
43          * choice.
44          */
45         struct object_id *sparse_oid_value;
46         unsigned long blob_limit_value;
47         unsigned long tree_exclude_depth;
48 };
49
50 /* Normalized command line arguments */
51 #define CL_ARG__FILTER "filter"
52
53 int parse_list_objects_filter(
54         struct list_objects_filter_options *filter_options,
55         const char *arg);
56
57 int opt_parse_list_objects_filter(const struct option *opt,
58                                   const char *arg, int unset);
59
60 #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
61         { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
62           N_("object filtering"), 0, \
63           opt_parse_list_objects_filter }
64
65 /*
66  * Translates abbreviated numbers in the filter's filter_spec into their
67  * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024").
68  *
69  * This form should be used instead of the raw filter_spec field when
70  * communicating with a remote process or subprocess.
71  */
72 void expand_list_objects_filter_spec(
73         const struct list_objects_filter_options *filter,
74         struct strbuf *expanded_spec);
75
76 void list_objects_filter_release(
77         struct list_objects_filter_options *filter_options);
78
79 static inline void list_objects_filter_set_no_filter(
80         struct list_objects_filter_options *filter_options)
81 {
82         list_objects_filter_release(filter_options);
83         filter_options->no_filter = 1;
84 }
85
86 void partial_clone_register(
87         const char *remote,
88         const struct list_objects_filter_options *filter_options);
89 void partial_clone_get_default_filter_spec(
90         struct list_objects_filter_options *filter_options);
91
92 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */