path-walk: allow consumer to specify object types

We add the ability to filter the object types in the path-walk API so
the callback function is called fewer times.

This adds the ability to ask for the commits in a list, as well. We
re-use the empty string for this set of objects because these are passed
directly to the callback function instead of being part of the
'path_stack'.

Future changes will add the ability to visit annotated tags.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Derrick Stolee
2024-12-20 16:21:12 +00:00
committed by Junio C Hamano
parent d190124f27
commit c8dba310d7
5 changed files with 170 additions and 50 deletions

View File

@ -31,9 +31,21 @@ struct path_walk_info {
*/
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;
};
#define PATH_WALK_INFO_INIT { 0 }
#define PATH_WALK_INFO_INIT { \
.blobs = 1, \
.trees = 1, \
.commits = 1, \
}
void path_walk_info_init(struct path_walk_info *info);
void path_walk_info_clear(struct path_walk_info *info);