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 */ 10enum 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 19struct 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 */ 27char*filter_spec; 28 29/* 30 * 'choice' is determined by parsing the filter-spec. This indicates 31 * the filtering algorithm to use. 32 */ 33enum list_objects_filter_choice choice; 34 35/* 36 * Choice is LOFC_DISABLED because "--no-filter" was requested. 37 */ 38unsigned 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 */ 45struct object_id *sparse_oid_value; 46unsigned long blob_limit_value; 47unsigned long tree_exclude_depth; 48}; 49 50/* Normalized command line arguments */ 51#define CL_ARG__FILTER"filter" 52 53intparse_list_objects_filter( 54struct list_objects_filter_options *filter_options, 55const char*arg); 56 57intopt_parse_list_objects_filter(const struct option *opt, 58const 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 */ 72voidexpand_list_objects_filter_spec( 73const struct list_objects_filter_options *filter, 74struct strbuf *expanded_spec); 75 76voidlist_objects_filter_release( 77struct list_objects_filter_options *filter_options); 78 79staticinlinevoidlist_objects_filter_set_no_filter( 80struct list_objects_filter_options *filter_options) 81{ 82list_objects_filter_release(filter_options); 83 filter_options->no_filter =1; 84} 85 86voidpartial_clone_register( 87const char*remote, 88const struct list_objects_filter_options *filter_options); 89voidpartial_clone_get_default_filter_spec( 90struct list_objects_filter_options *filter_options, 91const char*remote); 92 93#endif/* LIST_OBJECTS_FILTER_OPTIONS_H */