From 7b24a170d2c36c83c3669d194af46a09ccdeec43 Mon Sep 17 00:00:00 2001 From: Meet Soni Date: Tue, 4 Feb 2025 09:35:57 +0530 Subject: refspec: relocate matching related functions Move the functions `refspec_find_match()`, `refspec_find_all_matches()` and `refspec_find_negative_match()` from `remote.c` to `refspec.c`. These functions focus on matching refspecs, so centralizing them in `refspec.c` improves code organization by keeping refspec-related logic in one place. Signed-off-by: Meet Soni Signed-off-by: Junio C Hamano --- refspec.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'refspec.h') diff --git a/refspec.h b/refspec.h index 584d9c9eb5..be20ba53ab 100644 --- a/refspec.h +++ b/refspec.h @@ -30,6 +30,8 @@ struct refspec_item { char *raw; }; +struct string_list; + #define REFSPEC_FETCH 1 #define REFSPEC_PUSH 0 @@ -80,4 +82,18 @@ int refname_matches_negative_refspec_item(const char *refname, struct refspec *r int match_name_with_pattern(const char *key, const char *name, const char *value, char **result); +/* + * Queries a refspec for a match and updates the query item. + * Returns 0 on success, -1 if no match is found or negative refspec matches. + */ +int refspec_find_match(struct refspec *rs, struct refspec_item *query); + +/* + * Queries a refspec for all matches and appends results to the provided string + * list. + */ +void refspec_find_all_matches(struct refspec *rs, + struct refspec_item *query, + struct string_list *results); + #endif /* REFSPEC_H */ -- cgit v1.2.3