]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote: rename query_refspecs functions
authorMeet Soni <meetsoni3017@gmail.com>
Tue, 4 Feb 2025 04:05:56 +0000 (09:35 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Feb 2025 17:51:41 +0000 (09:51 -0800)
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>
builtin/push.c
remote.c
remote.h

index 90de3746b5229f87655c4111112980945cd49832..92d530e5c4dff07e7fecd439f7aaef9721fd780f 100644 (file)
@@ -78,7 +78,7 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref,
                        .src = matched->name,
                };
 
-               if (!query_refspecs(&remote->push, &query) && query.dst) {
+               if (!refspec_find_match(&remote->push, &query) && query.dst) {
                        refspec_appendf(refspec, "%s%s:%s",
                                        query.force ? "+" : "",
                                        query.src, query.dst);
index 1da8ec703768b2baac02a25177a0f2544c5f73be..b510809a56be6a3f455a2c3abd91fc2f18244f40 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -925,7 +925,7 @@ struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
        return ref_map;
 }
 
-static int query_matches_negative_refspec(struct refspec *rs, struct refspec_item *query)
+static int refspec_find_negative_match(struct refspec *rs, struct refspec_item *query)
 {
        int i, matched_negative = 0;
        int find_src = !query->src;
@@ -982,7 +982,7 @@ static int query_matches_negative_refspec(struct refspec *rs, struct refspec_ite
        return matched_negative;
 }
 
-static void query_refspecs_multiple(struct refspec *rs,
+static void refspec_find_all_matches(struct refspec *rs,
                                    struct refspec_item *query,
                                    struct string_list *results)
 {
@@ -990,9 +990,9 @@ static void query_refspecs_multiple(struct refspec *rs,
        int find_src = !query->src;
 
        if (find_src && !query->dst)
-               BUG("query_refspecs_multiple: need either src or dst");
+               BUG("refspec_find_all_matches: need either src or dst");
 
-       if (query_matches_negative_refspec(rs, query))
+       if (refspec_find_negative_match(rs, query))
                return;
 
        for (i = 0; i < rs->nr; i++) {
@@ -1013,7 +1013,7 @@ static void query_refspecs_multiple(struct refspec *rs,
        }
 }
 
-int query_refspecs(struct refspec *rs, struct refspec_item *query)
+int refspec_find_match(struct refspec *rs, struct refspec_item *query)
 {
        int i;
        int find_src = !query->src;
@@ -1021,9 +1021,9 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query)
        char **result = find_src ? &query->src : &query->dst;
 
        if (find_src && !query->dst)
-               BUG("query_refspecs: need either src or dst");
+               BUG("refspec_find_match: need either src or dst");
 
-       if (query_matches_negative_refspec(rs, query))
+       if (refspec_find_negative_match(rs, query))
                return -1;
 
        for (i = 0; i < rs->nr; i++) {
@@ -1054,7 +1054,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
        memset(&query, 0, sizeof(struct refspec_item));
        query.src = (char *)name;
 
-       if (query_refspecs(rs, &query))
+       if (refspec_find_match(rs, &query))
                return NULL;
 
        return query.dst;
@@ -1062,7 +1062,7 @@ char *apply_refspecs(struct refspec *rs, const char *name)
 
 int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
 {
-       return query_refspecs(&remote->fetch, refspec);
+       return refspec_find_match(&remote->fetch, refspec);
 }
 
 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,
        memset(&query, 0, sizeof(struct refspec_item));
        query.dst = (char *)refname;
 
-       query_refspecs_multiple(info->rs, &query, &matches);
+       refspec_find_all_matches(info->rs, &query, &matches);
        if (matches.nr == 0)
                goto clean_exit; /* No matches */
 
index 66ee53411d76691122b642dfe162d5aa455ab5c8..516ba7f39890b9c291b73a11c28fa96f3ab4712e 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -269,7 +269,7 @@ int refname_matches_negative_refspec_item(const char *refname, struct refspec *r
  */
 struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs);
 
-int query_refspecs(struct refspec *rs, struct refspec_item *query);
+int refspec_find_match(struct refspec *rs, struct refspec_item *query);
 char *apply_refspecs(struct refspec *rs, const char *name);
 
 int check_push_refs(struct ref *src, struct refspec *rs);