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.

96 lines
3.2KB

  1. #ifndef LIST_OBJECTS_FILTER_H
  2. #define LIST_OBJECTS_FILTER_H
  3. struct list_objects_filter_options;
  4. struct object;
  5. struct oidset;
  6. struct repository;
  7. /*
  8. * During list-object traversal we allow certain objects to be
  9. * filtered (omitted) from the result. The active filter uses
  10. * these result values to guide list-objects.
  11. *
  12. * _ZERO : Do nothing with the object at this time. It may
  13. * be revisited if it appears in another place in
  14. * the tree or in another commit during the overall
  15. * traversal.
  16. *
  17. * _MARK_SEEN : Mark this object as "SEEN" in the object flags.
  18. * This will prevent it from being revisited during
  19. * the remainder of the traversal. This DOES NOT
  20. * imply that it will be included in the results.
  21. *
  22. * _DO_SHOW : Show this object in the results (call show() on it).
  23. * In general, objects should only be shown once, but
  24. * this result DOES NOT imply that we mark it SEEN.
  25. *
  26. * _SKIP_TREE : Used in LOFS_BEGIN_TREE situation - indicates that
  27. * the tree's children should not be iterated over. This
  28. * is used as an optimization when all children will
  29. * definitely be ignored.
  30. *
  31. * Most of the time, you want the combination (_MARK_SEEN | _DO_SHOW)
  32. * but they can be used independently, such as when sparse-checkout
  33. * pattern matching is being applied.
  34. *
  35. * A _MARK_SEEN without _DO_SHOW can be called a hard-omit -- the
  36. * object is not shown and will never be reconsidered (unless a
  37. * previous iteration has already shown it).
  38. *
  39. * A _DO_SHOW without _MARK_SEEN can be used, for example, to
  40. * include a directory, but then revisit it to selectively include
  41. * or omit objects within it.
  42. *
  43. * A _ZERO can be called a provisional-omit -- the object is NOT shown,
  44. * but *may* be revisited (if the object appears again in the traversal).
  45. * Therefore, it will be omitted from the results *unless* a later
  46. * iteration causes it to be shown.
  47. */
  48. enum list_objects_filter_result {
  49. LOFR_ZERO = 0,
  50. LOFR_MARK_SEEN = 1<<0,
  51. LOFR_DO_SHOW = 1<<1,
  52. LOFR_SKIP_TREE = 1<<2,
  53. };
  54. enum list_objects_filter_situation {
  55. LOFS_BEGIN_TREE,
  56. LOFS_END_TREE,
  57. LOFS_BLOB
  58. };
  59. struct filter;
  60. /*
  61. * Constructor for the set of defined list-objects filters.
  62. * The `omitted` set is optional. It is populated with objects that the
  63. * filter excludes. This set should not be considered finalized until
  64. * after list_objects_filter__free is called on the returned `struct
  65. * filter *`.
  66. */
  67. struct filter *list_objects_filter__init(
  68. struct oidset *omitted,
  69. struct list_objects_filter_options *filter_options);
  70. /*
  71. * Lets `filter` decide how to handle the `obj`. If `filter` is NULL, this
  72. * function behaves as expected if no filter is configured: all objects are
  73. * included.
  74. */
  75. enum list_objects_filter_result list_objects_filter__filter_object(
  76. struct repository *r,
  77. enum list_objects_filter_situation filter_situation,
  78. struct object *obj,
  79. const char *pathname,
  80. const char *filename,
  81. struct filter *filter);
  82. /*
  83. * Destroys `filter` and finalizes the `omitted` set, if present. Does
  84. * nothing if `filter` is null.
  85. */
  86. void list_objects_filter__free(struct filter *filter);
  87. #endif /* LIST_OBJECTS_FILTER_H */