Merge branch 'ds/commit-graph-assert-missing-parents'
[git.git] / list-objects-filter.h
blob1d45a4ad5786c915f1fd597ce782cd96b7301532
1 #ifndef LIST_OBJECTS_FILTER_H
2 #define LIST_OBJECTS_FILTER_H
4 struct list_objects_filter_options;
5 struct object;
6 struct oidset;
7 struct repository;
9 /*
10 * During list-object traversal we allow certain objects to be
11 * filtered (omitted) from the result. The active filter uses
12 * these result values to guide list-objects.
14 * _ZERO : Do nothing with the object at this time. It may
15 * be revisited if it appears in another place in
16 * the tree or in another commit during the overall
17 * traversal.
19 * _MARK_SEEN : Mark this object as "SEEN" in the object flags.
20 * This will prevent it from being revisited during
21 * the remainder of the traversal. This DOES NOT
22 * imply that it will be included in the results.
24 * _DO_SHOW : Show this object in the results (call show() on it).
25 * In general, objects should only be shown once, but
26 * this result DOES NOT imply that we mark it SEEN.
28 * _SKIP_TREE : Used in LOFS_BEGIN_TREE situation - indicates that
29 * the tree's children should not be iterated over. This
30 * is used as an optimization when all children will
31 * definitely be ignored.
33 * Most of the time, you want the combination (_MARK_SEEN | _DO_SHOW)
34 * but they can be used independently, such as when sparse-checkout
35 * pattern matching is being applied.
37 * A _MARK_SEEN without _DO_SHOW can be called a hard-omit -- the
38 * object is not shown and will never be reconsidered (unless a
39 * previous iteration has already shown it).
41 * A _DO_SHOW without _MARK_SEEN can be used, for example, to
42 * include a directory, but then revisit it to selectively include
43 * or omit objects within it.
45 * A _ZERO can be called a provisional-omit -- the object is NOT shown,
46 * but *may* be revisited (if the object appears again in the traversal).
47 * Therefore, it will be omitted from the results *unless* a later
48 * iteration causes it to be shown.
50 enum list_objects_filter_result {
51 LOFR_ZERO = 0,
52 LOFR_MARK_SEEN = 1<<0,
53 LOFR_DO_SHOW = 1<<1,
54 LOFR_SKIP_TREE = 1<<2,
57 enum list_objects_filter_situation {
58 LOFS_BEGIN_TREE,
59 LOFS_END_TREE,
60 LOFS_BLOB
63 typedef enum list_objects_filter_result (*filter_object_fn)(
64 struct repository *r,
65 enum list_objects_filter_situation filter_situation,
66 struct object *obj,
67 const char *pathname,
68 const char *filename,
69 void *filter_data);
71 typedef void (*filter_free_fn)(void *filter_data);
74 * Constructor for the set of defined list-objects filters.
75 * Returns a generic "void *filter_data".
77 * The returned "filter_fn" will be used by traverse_commit_list()
78 * to filter the results.
80 * The returned "filter_free_fn" is a destructor for the
81 * filter_data.
83 void *list_objects_filter__init(
84 struct oidset *omitted,
85 struct list_objects_filter_options *filter_options,
86 filter_object_fn *filter_fn,
87 filter_free_fn *filter_free_fn);
89 #endif /* LIST_OBJECTS_FILTER_H */