mirror of
https://github.com/git/git.git
synced 2025-02-06 09:44:30 +00:00
When the input rev_info has UNINTERESTING starting points, we want to be sure that the UNINTERESTING flag is passed appropriately through the objects. To match how this is done in places such as 'git pack-objects', we use the mark_edges_uninteresting() method. This method has an option for using the "sparse" walk, which is similar in spirit to the path-walk API's walk. To be sure to keep it independent, add a new 'prune_all_uninteresting' option to the path_walk_info struct. To check how the UNINTERSTING flag is spread through our objects, extend the 'test-tool path-walk' command to output whether or not an object has that flag. This changes our tests significantly, including the removal of some objects that were previously visited due to the incomplete implementation. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
70 lines
1.8 KiB
C
70 lines
1.8 KiB
C
/*
|
|
* path-walk.h : Methods and structures for walking the object graph in batches
|
|
* by the paths that can reach those objects.
|
|
*/
|
|
#include "object.h" /* Required for 'enum object_type'. */
|
|
|
|
struct rev_info;
|
|
struct oid_array;
|
|
|
|
/**
|
|
* The type of a function pointer for the method that is called on a list of
|
|
* objects reachable at a given path.
|
|
*/
|
|
typedef int (*path_fn)(const char *path,
|
|
struct oid_array *oids,
|
|
enum object_type type,
|
|
void *data);
|
|
|
|
struct path_walk_info {
|
|
/**
|
|
* revs provides the definitions for the commit walk, including
|
|
* which commits are UNINTERESTING or not. This structure is
|
|
* expected to be owned by the caller.
|
|
*/
|
|
struct rev_info *revs;
|
|
|
|
/**
|
|
* The caller wishes to execute custom logic on objects reachable at a
|
|
* given path. Every reachable object will be visited exactly once, and
|
|
* the first path to see an object wins. This may not be a stable choice.
|
|
*/
|
|
path_fn path_fn;
|
|
void *path_fn_data;
|
|
|
|
/**
|
|
* Initialize which object types the path_fn should be called on. This
|
|
* could also limit the walk to skip blobs if not set.
|
|
*/
|
|
int commits;
|
|
int trees;
|
|
int blobs;
|
|
int tags;
|
|
|
|
/**
|
|
* When 'prune_all_uninteresting' is set and a path has all objects
|
|
* marked as UNINTERESTING, then the path-walk will not visit those
|
|
* objects. It will not call path_fn on those objects and will not
|
|
* walk the children of such trees.
|
|
*/
|
|
int prune_all_uninteresting;
|
|
};
|
|
|
|
#define PATH_WALK_INFO_INIT { \
|
|
.blobs = 1, \
|
|
.trees = 1, \
|
|
.commits = 1, \
|
|
.tags = 1, \
|
|
}
|
|
|
|
void path_walk_info_init(struct path_walk_info *info);
|
|
void path_walk_info_clear(struct path_walk_info *info);
|
|
|
|
/**
|
|
* Given the configuration of 'info', walk the commits based on 'info->revs' and
|
|
* call 'info->path_fn' on each discovered path.
|
|
*
|
|
* Returns nonzero on an error.
|
|
*/
|
|
int walk_objects_by_path(struct path_walk_info *info);
|