From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Subject: [PATCH 2/5] refs: add `exclude_patterns` parameter to `for_each_fullref_in()`
Date: Fri, 3 May 2024 08:28:04 +0200 [thread overview]
Message-ID: <4f34bb2e03479b4987ef30330f096650de354b06.1714717057.git.ps@pks.im> (raw)
In-Reply-To: <cover.1714717057.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 4927 bytes --]
The `for_each_fullref_in()` function is supposedly the ref-store-less
equivalent of `refs_for_each_fullref_in()`, but the latter has gained a
new parameter `exclude_patterns` over time. Bring these two functions
back in sync again by adding the parameter to the former function, as
well.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
builtin/rev-parse.c | 4 ++--
builtin/show-ref.c | 4 ++--
ref-filter.c | 10 +++++-----
refs.c | 8 +++++---
refs.h | 3 ++-
5 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 624182e507..2b28d43939 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -908,8 +908,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--bisect")) {
- for_each_fullref_in("refs/bisect/bad", show_reference, NULL);
- for_each_fullref_in("refs/bisect/good", anti_reference, NULL);
+ for_each_fullref_in("refs/bisect/bad", NULL, show_reference, NULL);
+ for_each_fullref_in("refs/bisect/good", NULL, anti_reference, NULL);
continue;
}
if (opt_with_value(arg, "--branches", &arg)) {
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 1c15421e60..3c521dbfd4 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -208,9 +208,9 @@ static int cmd_show_ref__patterns(const struct patterns_options *opts,
head_ref(show_ref, &show_ref_data);
if (opts->heads_only || opts->tags_only) {
if (opts->heads_only)
- for_each_fullref_in("refs/heads/", show_ref, &show_ref_data);
+ for_each_fullref_in("refs/heads/", NULL, show_ref, &show_ref_data);
if (opts->tags_only)
- for_each_fullref_in("refs/tags/", show_ref, &show_ref_data);
+ for_each_fullref_in("refs/tags/", NULL, show_ref, &show_ref_data);
} else {
for_each_ref(show_ref, &show_ref_data);
}
diff --git a/ref-filter.c b/ref-filter.c
index 59ad6f54dd..eab4beba16 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2640,7 +2640,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
* prefixes like "refs/heads/" etc. are stripped off,
* so we have to look at everything:
*/
- return for_each_fullref_in("", cb, cb_data);
+ return for_each_fullref_in("", NULL, cb, cb_data);
}
if (filter->ignore_case) {
@@ -2649,7 +2649,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
* so just return everything and let the caller
* sort it out.
*/
- return for_each_fullref_in("", cb, cb_data);
+ return for_each_fullref_in("", NULL, cb, cb_data);
}
if (!filter->name_patterns[0]) {
@@ -3060,11 +3060,11 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref
* of filter_ref_kind().
*/
if (filter->kind == FILTER_REFS_BRANCHES)
- ret = for_each_fullref_in("refs/heads/", fn, cb_data);
+ ret = for_each_fullref_in("refs/heads/", NULL, fn, cb_data);
else if (filter->kind == FILTER_REFS_REMOTES)
- ret = for_each_fullref_in("refs/remotes/", fn, cb_data);
+ ret = for_each_fullref_in("refs/remotes/", NULL, fn, cb_data);
else if (filter->kind == FILTER_REFS_TAGS)
- ret = for_each_fullref_in("refs/tags/", fn, cb_data);
+ ret = for_each_fullref_in("refs/tags/", NULL, fn, cb_data);
else if (filter->kind & FILTER_REFS_REGULAR)
ret = for_each_fullref_in_pattern(filter, fn, cb_data);
diff --git a/refs.c b/refs.c
index 7cafda1c25..00bcc72719 100644
--- a/refs.c
+++ b/refs.c
@@ -1742,10 +1742,12 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
}
-int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data)
+int for_each_fullref_in(const char *prefix,
+ const char **exclude_patterns,
+ each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref(get_main_ref_store(the_repository),
- prefix, NULL, fn, 0, 0, cb_data);
+ return refs_for_each_fullref_in(get_main_ref_store(the_repository),
+ prefix, exclude_patterns, fn, cb_data);
}
int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
diff --git a/refs.h b/refs.h
index 10982dcf03..a28de62fb5 100644
--- a/refs.h
+++ b/refs.h
@@ -353,7 +353,8 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data);
int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
const char **exclude_patterns,
each_ref_fn fn, void *cb_data);
-int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data);
+int for_each_fullref_in(const char *prefix, const char **exclude_patterns,
+ each_ref_fn fn, void *cb_data);
/**
* iterate all refs in "patterns" by partitioning patterns into disjoint sets
--
2.45.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-05-03 6:28 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 6:27 [PATCH 0/5] refs: remove functions without ref store Patrick Steinhardt
2024-05-03 6:27 ` [PATCH 1/5] refs: introduce missing functions that accept a `struct ref_store` Patrick Steinhardt
2024-05-03 17:11 ` Junio C Hamano
2024-05-03 6:28 ` Patrick Steinhardt [this message]
2024-05-03 18:44 ` [PATCH 2/5] refs: add `exclude_patterns` parameter to `for_each_fullref_in()` Taylor Blau
2024-05-03 6:28 ` [PATCH 3/5] cocci: introduce rules to transform "refs" to pass ref store Patrick Steinhardt
2024-05-03 6:28 ` [PATCH 4/5] cocci: apply rules to rewrite callers of "refs" interfaces Patrick Steinhardt
2024-05-03 18:48 ` Taylor Blau
2024-05-03 19:20 ` Junio C Hamano
2024-05-06 6:35 ` Patrick Steinhardt
2024-05-03 6:28 ` [PATCH 5/5] refs: remove functions without ref store Patrick Steinhardt
2024-05-06 1:15 ` James Liu
2024-05-03 17:24 ` [PATCH 0/5] " Junio C Hamano
2024-05-03 17:35 ` Jeff King
2024-05-03 18:24 ` Junio C Hamano
2024-05-06 6:44 ` Patrick Steinhardt
2024-05-06 16:14 ` Junio C Hamano
2024-05-07 5:56 ` Patrick Steinhardt
2024-05-07 6:20 ` Junio C Hamano
2024-05-07 6:30 ` Patrick Steinhardt
2024-05-07 15:46 ` Junio C Hamano
2024-05-09 16:55 ` Jeff King
2024-05-10 5:54 ` Patrick Steinhardt
2024-05-03 18:58 ` Taylor Blau
2024-05-03 19:35 ` Junio C Hamano
2024-05-07 7:11 ` [PATCH v2 " Patrick Steinhardt
2024-05-07 7:11 ` [PATCH v2 1/5] refs: introduce missing functions that accept a `struct ref_store` Patrick Steinhardt
2024-05-07 7:11 ` [PATCH v2 2/5] refs: add `exclude_patterns` parameter to `for_each_fullref_in()` Patrick Steinhardt
2024-05-07 7:11 ` [PATCH v2 3/5] cocci: introduce rules to transform "refs" to pass ref store Patrick Steinhardt
2024-05-07 7:11 ` [PATCH v2 4/5] cocci: apply rules to rewrite callers of "refs" interfaces Patrick Steinhardt
2024-05-07 7:11 ` [PATCH v2 5/5] refs: remove functions without ref store Patrick Steinhardt
2024-05-07 17:27 ` [PATCH v2 0/5] " Taylor Blau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f34bb2e03479b4987ef30330f096650de354b06.1714717057.git.ps@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).