1#ifndef LIST_OBJECTS_FILTER_OPTIONS_H 2#define LIST_OBJECTS_FILTER_OPTIONS_H 3 4#include"parse-options.h" 5#include"string-list.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_COMBINE, 17 LOFC__COUNT /* must be last */ 18}; 19 20struct list_objects_filter_options { 21/* 22 * 'filter_spec' is the raw argument value given on the command line 23 * or protocol request. (The part after the "--keyword=".) For 24 * commands that launch filtering sub-processes, or for communication 25 * over the network, don't use this value; use the result of 26 * expand_list_objects_filter_spec() instead. 27 * To get the raw filter spec given by the user, use the result of 28 * list_objects_filter_spec(). 29 */ 30struct string_list filter_spec; 31 32/* 33 * 'choice' is determined by parsing the filter-spec. This indicates 34 * the filtering algorithm to use. 35 */ 36enum list_objects_filter_choice choice; 37 38/* 39 * Choice is LOFC_DISABLED because "--no-filter" was requested. 40 */ 41unsigned int no_filter :1; 42 43/* 44 * BEGIN choice-specific parsed values from within the filter-spec. Only 45 * some values will be defined for any given choice. 46 */ 47 48struct object_id *sparse_oid_value; 49unsigned long blob_limit_value; 50unsigned long tree_exclude_depth; 51 52/* LOFC_COMBINE values */ 53 54/* This array contains all the subfilters which this filter combines. */ 55size_t sub_nr, sub_alloc; 56struct list_objects_filter_options *sub; 57 58/* 59 * END choice-specific parsed values. 60 */ 61}; 62 63/* Normalized command line arguments */ 64#define CL_ARG__FILTER"filter" 65 66intparse_list_objects_filter( 67struct list_objects_filter_options *filter_options, 68const char*arg); 69 70intopt_parse_list_objects_filter(const struct option *opt, 71const char*arg,int unset); 72 73#define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \ 74 { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \ 75 N_("object filtering"), 0, \ 76 opt_parse_list_objects_filter } 77 78/* 79 * Translates abbreviated numbers in the filter's filter_spec into their 80 * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024"). 81 * Returns a string owned by the list_objects_filter_options object. 82 * 83 * This form should be used instead of the raw list_objects_filter_spec() 84 * value when communicating with a remote process or subprocess. 85 */ 86const char*expand_list_objects_filter_spec( 87struct list_objects_filter_options *filter); 88 89/* 90 * Returns the filter spec string more or less in the form as the user 91 * entered it. This form of the filter_spec can be used in user-facing 92 * messages. Returns a string owned by the list_objects_filter_options 93 * object. 94 */ 95const char*list_objects_filter_spec( 96struct list_objects_filter_options *filter); 97 98voidlist_objects_filter_release( 99struct list_objects_filter_options *filter_options); 100 101staticinlinevoidlist_objects_filter_set_no_filter( 102struct list_objects_filter_options *filter_options) 103{ 104list_objects_filter_release(filter_options); 105 filter_options->no_filter =1; 106} 107 108voidpartial_clone_register( 109const char*remote, 110struct list_objects_filter_options *filter_options); 111voidpartial_clone_get_default_filter_spec( 112struct list_objects_filter_options *filter_options); 113 114#endif/* LIST_OBJECTS_FILTER_OPTIONS_H */