Skip to content

Commit be0905f

Browse files
inosmeetgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 230d022 commit be0905f

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

builtin/push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref,
7878
.src = matched->name,
7979
};
8080

81-
if (!query_refspecs(&remote->push, &query) && query.dst) {
81+
if (!refspec_find_match(&remote->push, &query) && query.dst) {
8282
refspec_appendf(refspec, "%s%s:%s",
8383
query.force ? "+" : "",
8484
query.src, query.dst);

remote.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
925925
return ref_map;
926926
}
927927

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)
929929
{
930930
int i, matched_negative = 0;
931931
int find_src = !query->src;
@@ -982,17 +982,17 @@ static int query_matches_negative_refspec(struct refspec *rs, struct refspec_ite
982982
return matched_negative;
983983
}
984984

985-
static void query_refspecs_multiple(struct refspec *rs,
985+
static void refspec_find_all_matches(struct refspec *rs,
986986
struct refspec_item *query,
987987
struct string_list *results)
988988
{
989989
int i;
990990
int find_src = !query->src;
991991

992992
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");
994994

995-
if (query_matches_negative_refspec(rs, query))
995+
if (refspec_find_negative_match(rs, query))
996996
return;
997997

998998
for (i = 0; i < rs->nr; i++) {
@@ -1013,17 +1013,17 @@ static void query_refspecs_multiple(struct refspec *rs,
10131013
}
10141014
}
10151015

1016-
int query_refspecs(struct refspec *rs, struct refspec_item *query)
1016+
int refspec_find_match(struct refspec *rs, struct refspec_item *query)
10171017
{
10181018
int i;
10191019
int find_src = !query->src;
10201020
const char *needle = find_src ? query->dst : query->src;
10211021
char **result = find_src ? &query->src : &query->dst;
10221022

10231023
if (find_src && !query->dst)
1024-
BUG("query_refspecs: need either src or dst");
1024+
BUG("refspec_find_match: need either src or dst");
10251025

1026-
if (query_matches_negative_refspec(rs, query))
1026+
if (refspec_find_negative_match(rs, query))
10271027
return -1;
10281028

10291029
for (i = 0; i < rs->nr; i++) {
@@ -1054,15 +1054,15 @@ char *apply_refspecs(struct refspec *rs, const char *name)
10541054
memset(&query, 0, sizeof(struct refspec_item));
10551055
query.src = (char *)name;
10561056

1057-
if (query_refspecs(rs, &query))
1057+
if (refspec_find_match(rs, &query))
10581058
return NULL;
10591059

10601060
return query.dst;
10611061
}
10621062

10631063
int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
10641064
{
1065-
return query_refspecs(&remote->fetch, refspec);
1065+
return refspec_find_match(&remote->fetch, refspec);
10661066
}
10671067

10681068
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,
24872487
memset(&query, 0, sizeof(struct refspec_item));
24882488
query.dst = (char *)refname;
24892489

2490-
query_refspecs_multiple(info->rs, &query, &matches);
2490+
refspec_find_all_matches(info->rs, &query, &matches);
24912491
if (matches.nr == 0)
24922492
goto clean_exit; /* No matches */
24932493

remote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ int refname_matches_negative_refspec_item(const char *refname, struct refspec *r
269269
*/
270270
struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs);
271271

272-
int query_refspecs(struct refspec *rs, struct refspec_item *query);
272+
int refspec_find_match(struct refspec *rs, struct refspec_item *query);
273273
char *apply_refspecs(struct refspec *rs, const char *name);
274274

275275
int check_push_refs(struct ref *src, struct refspec *rs);

0 commit comments

Comments
 (0)