Git fork
at reftables-rust 87 lines 2.5 kB view raw
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'. */ 6 7struct rev_info; 8struct oid_array; 9struct pattern_list; 10 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. 14 */ 15typedef int (*path_fn)(const char *path, 16 struct oid_array *oids, 17 enum object_type type, 18 void *data); 19 20struct 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. 25 */ 26 struct rev_info *revs; 27 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. 32 */ 33 path_fn path_fn; 34 void *path_fn_data; 35 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. 39 */ 40 int commits; 41 int trees; 42 int blobs; 43 int tags; 44 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. 50 */ 51 int prune_all_uninteresting; 52 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. 57 */ 58 int edge_aggressive; 59 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. 67 */ 68 struct pattern_list *pl; 69}; 70 71#define PATH_WALK_INFO_INIT { \ 72 .blobs = 1, \ 73 .trees = 1, \ 74 .commits = 1, \ 75 .tags = 1, \ 76} 77 78void path_walk_info_init(struct path_walk_info *info); 79void path_walk_info_clear(struct path_walk_info *info); 80 81/** 82 * Given the configuration of 'info', walk the commits based on 'info->revs' and 83 * call 'info->path_fn' on each discovered path. 84 * 85 * Returns nonzero on an error. 86 */ 87int walk_objects_by_path(struct path_walk_info *info);