diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-06-22 17:51:44 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-06-22 23:40:24 +0400 |
commit | 527ed55448fb8fceb93837426c60bb401b8e32ab (patch) | |
tree | 22577f75f91a53044542cfebcbb2613057eeeeb5 /src/refs.c | |
parent | d046945cefc34c8caafde53e20e1a064576e587e (diff) |
references: introduce git_reference_foreach_glob()
Diffstat (limited to 'src/refs.c')
-rw-r--r-- | src/refs.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c index 104685793..ee076b3b8 100644 --- a/src/refs.c +++ b/src/refs.c @@ -1764,3 +1764,40 @@ int git_reference__update(git_repository *repo, const git_oid *oid, const char * git_reference_free(ref); return res; } + +struct glob_cb_data { + const char *glob; + int (*callback)(const char *, void *); + void *payload; +}; + +static int fromglob_cb(const char *reference_name, void *payload) +{ + struct glob_cb_data *data = (struct glob_cb_data *)payload; + + if (!p_fnmatch(data->glob, reference_name, 0)) + return data->callback(reference_name, data->payload); + + return 0; +} + +int git_reference_foreach_glob( + git_repository *repo, + const char *glob, + unsigned int list_flags, + int (*callback)( + const char *reference_name, + void *payload), + void *payload) +{ + struct glob_cb_data data; + + assert(repo && glob && callback); + + data.glob = glob; + data.callback = callback; + data.payload = payload; + + return git_reference_foreach( + repo, list_flags, fromglob_cb, &data); +} |