The sixteenth batch
[git/gitster.git] / path-walk.h
blob5ef5a8440e6b5e6eff24b4ec27f8741c4c708080
1 /*
2 * path-walk.h : Methods and structures for walking the object graph in batches
3 * by the paths that can reach those objects.
4 */
5 #include "object.h" /* Required for 'enum object_type'. */
7 struct rev_info;
8 struct oid_array;
9 struct pattern_list;
11 /**
12 * The type of a function pointer for the method that is called on a list of
13 * objects reachable at a given path.
15 typedef int (*path_fn)(const char *path,
16 struct oid_array *oids,
17 enum object_type type,
18 void *data);
20 struct path_walk_info {
21 /**
22 * revs provides the definitions for the commit walk, including
23 * which commits are UNINTERESTING or not. This structure is
24 * expected to be owned by the caller.
26 struct rev_info *revs;
28 /**
29 * The caller wishes to execute custom logic on objects reachable at a
30 * given path. Every reachable object will be visited exactly once, and
31 * the first path to see an object wins. This may not be a stable choice.
33 path_fn path_fn;
34 void *path_fn_data;
36 /**
37 * Initialize which object types the path_fn should be called on. This
38 * could also limit the walk to skip blobs if not set.
40 int commits;
41 int trees;
42 int blobs;
43 int tags;
45 /**
46 * When 'prune_all_uninteresting' is set and a path has all objects
47 * marked as UNINTERESTING, then the path-walk will not visit those
48 * objects. It will not call path_fn on those objects and will not
49 * walk the children of such trees.
51 int prune_all_uninteresting;
53 /**
54 * When 'edge_aggressive' is set, then the revision walk will use
55 * the '--object-edge-aggressive' option to mark even more objects
56 * as uninteresting.
58 int edge_aggressive;
60 /**
61 * Specify a sparse-checkout definition to match our paths to. Do not
62 * walk outside of this sparse definition. If the patterns are in
63 * cone mode, then the search may prune directories that are outside
64 * of the cone. If not in cone mode, then all tree paths will be
65 * explored but the path_fn will only be called when the path matches
66 * the sparse-checkout patterns.
68 struct pattern_list *pl;
71 #define PATH_WALK_INFO_INIT { \
72 .blobs = 1, \
73 .trees = 1, \
74 .commits = 1, \
75 .tags = 1, \
78 void path_walk_info_init(struct path_walk_info *info);
79 void path_walk_info_clear(struct path_walk_info *info);
81 /**
82 * Given the configuration of 'info', walk the commits based on 'info->revs' and
83 * call 'info->path_fn' on each discovered path.
85 * Returns nonzero on an error.
87 int walk_objects_by_path(struct path_walk_info *info);