THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.7KB

  1. #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
  2. #define LIST_OBJECTS_FILTER_OPTIONS_H
  3. #include "parse-options.h"
  4. #include "string-list.h"
  5. /*
  6. * The list of defined filters for list-objects.
  7. */
  8. enum list_objects_filter_choice {
  9. LOFC_DISABLED = 0,
  10. LOFC_BLOB_NONE,
  11. LOFC_BLOB_LIMIT,
  12. LOFC_TREE_DEPTH,
  13. LOFC_SPARSE_OID,
  14. LOFC_COMBINE,
  15. LOFC__COUNT /* must be last */
  16. };
  17. struct list_objects_filter_options {
  18. /*
  19. * 'filter_spec' is the raw argument value given on the command line
  20. * or protocol request. (The part after the "--keyword=".) For
  21. * commands that launch filtering sub-processes, or for communication
  22. * over the network, don't use this value; use the result of
  23. * expand_list_objects_filter_spec() instead.
  24. * To get the raw filter spec given by the user, use the result of
  25. * list_objects_filter_spec().
  26. */
  27. struct string_list filter_spec;
  28. /*
  29. * 'choice' is determined by parsing the filter-spec. This indicates
  30. * the filtering algorithm to use.
  31. */
  32. enum list_objects_filter_choice choice;
  33. /*
  34. * Choice is LOFC_DISABLED because "--no-filter" was requested.
  35. */
  36. unsigned int no_filter : 1;
  37. /*
  38. * BEGIN choice-specific parsed values from within the filter-spec. Only
  39. * some values will be defined for any given choice.
  40. */
  41. char *sparse_oid_name;
  42. unsigned long blob_limit_value;
  43. unsigned long tree_exclude_depth;
  44. /* LOFC_COMBINE values */
  45. /* This array contains all the subfilters which this filter combines. */
  46. size_t sub_nr, sub_alloc;
  47. struct list_objects_filter_options *sub;
  48. /*
  49. * END choice-specific parsed values.
  50. */
  51. };
  52. /* Normalized command line arguments */
  53. #define CL_ARG__FILTER "filter"
  54. void list_objects_filter_die_if_populated(
  55. struct list_objects_filter_options *filter_options);
  56. /*
  57. * Parses the filter spec string given by arg and either (1) simply places the
  58. * result in filter_options if it is not yet populated or (2) combines it with
  59. * the filter already in filter_options if it is already populated. In the case
  60. * of (2), the filter specs are combined as if specified with 'combine:'.
  61. *
  62. * Dies and prints a user-facing message if an error occurs.
  63. */
  64. void parse_list_objects_filter(
  65. struct list_objects_filter_options *filter_options,
  66. const char *arg);
  67. int opt_parse_list_objects_filter(const struct option *opt,
  68. const char *arg, int unset);
  69. #define OPT_PARSE_LIST_OBJECTS_FILTER(fo) \
  70. { OPTION_CALLBACK, 0, CL_ARG__FILTER, fo, N_("args"), \
  71. N_("object filtering"), 0, \
  72. opt_parse_list_objects_filter }
  73. /*
  74. * Translates abbreviated numbers in the filter's filter_spec into their
  75. * fully-expanded forms (e.g., "limit:blob=1k" becomes "limit:blob=1024").
  76. * Returns a string owned by the list_objects_filter_options object.
  77. *
  78. * This form should be used instead of the raw list_objects_filter_spec()
  79. * value when communicating with a remote process or subprocess.
  80. */
  81. const char *expand_list_objects_filter_spec(
  82. struct list_objects_filter_options *filter);
  83. /*
  84. * Returns the filter spec string more or less in the form as the user
  85. * entered it. This form of the filter_spec can be used in user-facing
  86. * messages. Returns a string owned by the list_objects_filter_options
  87. * object.
  88. */
  89. const char *list_objects_filter_spec(
  90. struct list_objects_filter_options *filter);
  91. void list_objects_filter_release(
  92. struct list_objects_filter_options *filter_options);
  93. static inline void list_objects_filter_set_no_filter(
  94. struct list_objects_filter_options *filter_options)
  95. {
  96. list_objects_filter_release(filter_options);
  97. filter_options->no_filter = 1;
  98. }
  99. void partial_clone_register(
  100. const char *remote,
  101. struct list_objects_filter_options *filter_options);
  102. void partial_clone_get_default_filter_spec(
  103. struct list_objects_filter_options *filter_options,
  104. const char *remote);
  105. #endif /* LIST_OBJECTS_FILTER_OPTIONS_H */