remote: rename query_refspecs functions

Rename functions related to handling refspecs in preparation for their move from `remote.c` to `refspec.c`. Update their names to better reflect their intent: - `query_refspecs()` -> `refspec_find_match()` for clarity, as it finds a single matching refspec. - `query_refspecs_multiple()` -> `refspec_find_all_matches()` to better reflect that it collects all matching refspecs instead of returning just the first match. - `query_matches_negative_refspec()` -> `refspec_find_negative_match()` for consistency with the updated naming convention, even though this static function didn't strictly require renaming. Signed-off-by: Meet Soni <meetsoni3017@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Meet Soni committed Feb 4, 2025 at 09:35 UTC be0905fed1cdc9a2269f19569c518f00d54d2dbe
3 files changed +12 -12
builtin/push.c
+1 -1
@@ -78,7 +78,7 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref,
78 .src = matched->name,
79 };
80
81 - if (!query_refspecs(&remote->push, &query) && query.dst) {
81 + if (!refspec_find_match(&remote->push, &query) && query.dst) {
82 refspec_appendf(refspec, "%s%s:%s",
83 query.force ? "+" : "",
84 query.src, query.dst);
remote.c
+10 -10
@@ -925,7 +925,7 @@ struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
925 return ref_map;
926 }
927
928 -static int query_matches_negative_refspec(struct refspec *rs, struct refspec_item *query)
928 +static int refspec_find_negative_match(struct refspec *rs, struct refspec_item *query)
929 {
930 int i, matched_negative = 0;
931 int find_src = !query->src;
@@ -982,7 +982,7 @@ static int query_matches_negative_refspec(struct refspec *rs, struct refspec_ite
982 return matched_negative;
983 }
984
985 -static void query_refspecs_multiple(struct refspec *rs,
985 +static void refspec_find_all_matches(struct refspec *rs,
986 struct refspec_item *query,
987 struct string_list *results)
988 {
@@ -990,9 +990,9 @@ static void query_refspecs_multiple(struct refspec *rs,
990 int find_src = !query->src;
991
992 if (find_src && !query->dst)
993 - BUG("query_refspecs_multiple: need either src or dst");
993 + BUG("refspec_find_all_matches: need either src or dst");
994
995 - if (query_matches_negative_refspec(rs, query))
995 + if (refspec_find_negative_match(rs, query))
996 return;
997
998 for (i = 0; i < rs->nr; i++) {
@@ -1013,7 +1013,7 @@ static void query_refspecs_multiple(struct refspec *rs,
1013 }
1014 }
1015
1016 -int query_refspecs(struct refspec *rs, struct refspec_item *query)
1016 +int refspec_find_match(struct refspec *rs, struct refspec_item *query)
1017 {
1018 int i;
1019 int find_src = !query->src;
@@ -1021,9 +1021,9 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query)
1021 char **result = find_src ? &query->src : &query->dst;
1022
1023 if (find_src && !query->dst)
1024 - BUG("query_refspecs: need either src or dst");
1024 + BUG("refspec_find_match: need either src or dst");
1025
1026 - if (query_matches_negative_refspec(rs, query))
1026 + if (refspec_find_negative_match(rs, query))
1027 return -1;
1028
1029 for (i = 0; i < rs->nr; i++) {
@@ -1054,7 +1054,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
1054 memset(&query, 0, sizeof(struct refspec_item));
1055 query.src = (char *)name;
1056
1057 - if (query_refspecs(rs, &query))
1057 + if (refspec_find_match(rs, &query))
1058 return NULL;
1059
1060 return query.dst;
@@ -1062,7 +1062,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
1062
1063 int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
1064 {
1065 - return query_refspecs(&remote->fetch, refspec);
1065 + return refspec_find_match(&remote->fetch, refspec);
1066 }
1067
1068 static struct ref *alloc_ref_with_prefix(const char *prefix, size_t prefixlen,
@@ -2487,7 +2487,7 @@ static int get_stale_heads_cb(const char *refname, const char *referent UNUSED,
2487 memset(&query, 0, sizeof(struct refspec_item));
2488 query.dst = (char *)refname;
2489
2490 - query_refspecs_multiple(info->rs, &query, &matches);
2490 + refspec_find_all_matches(info->rs, &query, &matches);
2491 if (matches.nr == 0)
2492 goto clean_exit; /* No matches */
2493
remote.h
+1 -1
@@ -269,7 +269,7 @@ int refname_matches_negative_refspec_item(const char *refname, struct refspec *r
269 */
270 struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs);
271
272 -int query_refspecs(struct refspec *rs, struct refspec_item *query);
272 +int refspec_find_match(struct refspec *rs, struct refspec_item *query);
273 char *apply_refspecs(struct refspec *rs, const char *name);
274
275 int check_push_refs(struct ref *src, struct refspec *rs);