run-command: use prepare_git_cmd() in prepare_cmd()
[git/raj.git] / list-objects-filter-options.h
blobc54f0000fbade5608e81345a9c5dbd54137d352d
1 #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2 #define LIST_OBJECTS_FILTER_OPTIONS_H
4 #include "parse-options.h"
5 #include "strbuf.h"
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 */
19 struct list_objects_filter_options {
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.
27 char *filter_spec;
30 * 'choice' is determined by parsing the filter-spec. This indicates
31 * the filtering algorithm to use.
33 enum list_objects_filter_choice choice;
36 * Choice is LOFC_DISABLED because "--no-filter" was requested.
38 unsigned int no_filter : 1;
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.
45 struct object_id *sparse_oid_value;
46 unsigned long blob_limit_value;
47 unsigned long tree_exclude_depth;
50 /* Normalized command line arguments */
51 #define CL_ARG__FILTER "filter"
53 int parse_list_objects_filter(
54 struct list_objects_filter_options *filter_options,
55 const char *arg);
57 int opt_parse_list_objects_filter(const struct option *opt,
58 const char *arg, int unset);
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 }
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").
69 * This form should be used instead of the raw filter_spec field when
70 * communicating with a remote process or subprocess.
72 void expand_list_objects_filter_spec(
73 const struct list_objects_filter_options *filter,
74 struct strbuf *expanded_spec);
76 void list_objects_filter_release(
77 struct list_objects_filter_options *filter_options);
79 static inline void list_objects_filter_set_no_filter(
80 struct list_objects_filter_options *filter_options)
82 list_objects_filter_release(filter_options);
83 filter_options->no_filter = 1;
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);
92 #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */