remote: rename function omit_name_by_refspec

Rename the function `omit_name_by_refspec()` to `refname_matches_negative_refspec_item()` to provide clearer intent. The previous function name was vague and did not accurately describe its purpose. By using `refname_matches_negative_refspec_item`, make the function's purpose more intuitive, clarifying that it checks if a reference name matches any negative refspec. Rename function parameters for consistency with existing naming conventions. Use `refname` instead of `name` to align with terminology in `refs.h`. Remove the redundant doc comment since the function name is now self-explanatory. 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 e4f6ab008522c5ad386485720770b8d03b4fb880
3 files changed +6 -10
builtin/remote.c
+1 -1
@@ -383,7 +383,7 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
383 states->remote->fetch.items[i].raw);
384
385 for (ref = fetch_map; ref; ref = ref->next) {
386 - if (omit_name_by_refspec(ref->name, &states->remote->fetch))
386 + if (refname_matches_negative_refspec_item(ref->name, &states->remote->fetch))
387 string_list_append(&states->skipped, abbrev_branch(ref->name));
388 else if (!ref->peer_ref || !refs_ref_exists(get_main_ref_store(the_repository), ref->peer_ref->name))
389 string_list_append(&states->new_refs, abbrev_branch(ref->name));
remote.c
+4 -4
@@ -944,12 +944,12 @@ static int refspec_match(const struct refspec_item *refspec,
944 return !strcmp(refspec->src, name);
945 }
946
947 -int omit_name_by_refspec(const char *name, struct refspec *rs)
947 +int refname_matches_negative_refspec_item(const char *refname, struct refspec *rs)
948 {
949 int i;
950
951 for (i = 0; i < rs->nr; i++) {
952 - if (rs->items[i].negative && refspec_match(&rs->items[i], name))
952 + if (rs->items[i].negative && refspec_match(&rs->items[i], refname))
953 return 1;
954 }
955 return 0;
@@ -962,7 +962,7 @@ struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
962 for (tail = &ref_map; *tail; ) {
963 struct ref *ref = *tail;
964
965 - if (omit_name_by_refspec(ref->name, rs)) {
965 + if (refname_matches_negative_refspec_item(ref->name, rs)) {
966 *tail = ref->next;
967 free(ref->peer_ref);
968 free(ref);
@@ -1021,7 +1021,7 @@ static int query_matches_negative_refspec(struct refspec *rs, struct refspec_ite
1021 }
1022
1023 for (i = 0; !matched_negative && i < reversed.nr; i++) {
1024 - if (omit_name_by_refspec(reversed.items[i].string, rs))
1024 + if (refname_matches_negative_refspec_item(reversed.items[i].string, rs))
1025 matched_negative = 1;
1026 }
1027
remote.h
+1 -5
@@ -261,11 +261,7 @@ int resolve_remote_symref(struct ref *ref, struct ref *list);
261 */
262 struct ref *ref_remove_duplicates(struct ref *ref_map);
263
264 -/*
265 - * Check whether a name matches any negative refspec in rs. Returns 1 if the
266 - * name matches at least one negative refspec, and 0 otherwise.
267 - */
268 -int omit_name_by_refspec(const char *name, struct refspec *rs);
264 +int refname_matches_negative_refspec_item(const char *refname, struct refspec *rs);
265
266 /*
267 * Remove all entries in the input list which match any negative refspec in