From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, phillip.wood123@gmail.com
Subject: Re: [PATCH v5 0/5] for-each-ref: add '--include-root-refs' option
Date: Tue, 27 Feb 2024 08:39:39 +0100 [thread overview]
Message-ID: <Zd2Ru7LWYyGprvcr@tanuki> (raw)
In-Reply-To: <20240223100112.44127-1-karthik.188@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5944 bytes --]
On Fri, Feb 23, 2024 at 11:01:07AM +0100, Karthik Nayak wrote:
> This is the fifth version of my patch series to print root refs
> in git-for-each-ref(1).
>
> With the introduction of the reftable backend, it becomes ever
> so important to provide the necessary tooling for printing all refs
> associated with a worktree.
>
> While regular refs stored within the "refs/" namespace are currently
> supported by multiple commands like git-for-each-ref(1),
> git-show-ref(1). Neither support printing root refs within the worktree.
>
> This patch series is a follow up to the RFC/discussion we had earlier on
> the list [1].
>
> The first 4 commits add the required functionality to ensure we can print
> all refs (regular, pseudo, HEAD). The 5th commit modifies the
> git-for-each-ref(1) command to add the "--include-root-refs" command which
> will include HEAD and pseudorefs with regular "refs/" refs.
>
> [1]: https://lore.kernel.org/git/20231221170715.110565-1-karthik.188@gmail.com/#t
>
> Changes from v4:
> 1. Fixed erratic whitespace
> 2. Remove braces from single line block
> 3. Starting the comments with a capital and also adding more context.
> 4. Removed a duplicate check.
>
> Thanks for the reviews.
>
> Range diff against v4:
The range-diff looks as expected, so this patch series looks good to me.
Thanks!
Patrick
> 1: 98130a7ad7 ! 1: 6016042965 refs: introduce `is_pseudoref()` and `is_headref()`
> @@ refs.c: static int is_pseudoref_syntax(const char *refname)
> +
> + if (ends_with(refname, "_HEAD")) {
> + refs_resolve_ref_unsafe(refs, refname,
> -+ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
> -+ &oid, NULL);
> -+ return !is_null_oid(&oid);
> ++ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
> ++ &oid, NULL);
> ++ return !is_null_oid(&oid);
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(irregular_pseudorefs); i++)
> + if (!strcmp(refname, irregular_pseudorefs[i])) {
> + refs_resolve_ref_unsafe(refs, refname,
> -+ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
> -+ &oid, NULL);
> ++ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
> ++ &oid, NULL);
> + return !is_null_oid(&oid);
> + }
> +
> 2: 060ab08af5 = 2: acaa014841 refs: extract out `loose_fill_ref_dir_regular_file()`
> 3: 40d2375ad9 = 3: f51c5bc307 refs: introduce `refs_for_each_include_root_refs()`
> 4: b4b9435505 = 4: 7c004db6e7 ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'
> 5: ee99ac41ae ! 5: 53f6c0a6db for-each-ref: add new option to include root refs
> @@ builtin/for-each-ref.c: int cmd_for_each_ref(int argc, const char **argv, const
> filter.name_patterns = argv;
> }
>
> -+ if (include_root_refs) {
> ++ if (include_root_refs)
> + flags |= FILTER_REFS_ROOT_REFS;
> -+ }
> +
> filter.match_as_path = 1;
> - filter_and_format_refs(&filter, FILTER_REFS_REGULAR, sorting, &format);
> @@ ref-filter.c: static int for_each_fullref_in_pattern(struct ref_filter *filter,
> void *cb_data)
> {
> + if (filter->kind == FILTER_REFS_KIND_MASK) {
> -+ /* in this case, we want to print all refs including root refs. */
> ++ /* In this case, we want to print all refs including root refs. */
> + return refs_for_each_include_root_refs(get_main_ref_store(the_repository),
> + cb, cb_data);
> + }
> @@ ref-filter.c: static struct ref_array_item *apply_ref_filter(const char *refname
>
> /* Obtain the current ref kind from filter_ref_kind() and ignore unwanted refs. */
> kind = filter_ref_kind(filter, refname);
> +- if (!(kind & filter->kind))
> +
> + /*
> -+ * When printing HEAD with all other refs, we want to apply the same formatting
> -+ * rules as the other refs, so we simply ask it to be treated as a pseudoref.
> ++ * Generally HEAD refs are printed with special description denoting a rebase,
> ++ * detached state and so forth. This is useful when only printing the HEAD ref
> ++ * But when it is being printed along with other pseudorefs, it makes sense to
> ++ * keep the formatting consistent. So we mask the type to act like a pseudoref.
> + */
> + if (filter->kind == FILTER_REFS_KIND_MASK && kind == FILTER_REFS_DETACHED_HEAD)
> + kind = FILTER_REFS_PSEUDOREFS;
> + else if (!(kind & filter->kind))
> -+ return NULL;
> -+
> - if (!(kind & filter->kind))
> return NULL;
>
> + if (!filter_pattern_match(filter, refname))
> @@ ref-filter.c: static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref
> ret = for_each_fullref_in("refs/tags/", fn, cb_data);
> else if (filter->kind & FILTER_REFS_REGULAR)
>
>
> Karthik Nayak (5):
> refs: introduce `is_pseudoref()` and `is_headref()`
> refs: extract out `loose_fill_ref_dir_regular_file()`
> refs: introduce `refs_for_each_include_root_refs()`
> ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'
> for-each-ref: add new option to include root refs
>
> Documentation/git-for-each-ref.txt | 5 +-
> builtin/for-each-ref.c | 10 ++-
> ref-filter.c | 30 ++++++-
> ref-filter.h | 7 +-
> refs.c | 48 +++++++++++
> refs.h | 9 ++
> refs/files-backend.c | 127 +++++++++++++++++++++--------
> refs/refs-internal.h | 6 ++
> refs/reftable-backend.c | 11 ++-
> t/t6302-for-each-ref-filter.sh | 31 +++++++
> 10 files changed, 237 insertions(+), 47 deletions(-)
>
> --
> 2.43.GIT
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-02-27 7:39 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 14:27 [PATCH 0/5] for-each-ref: print all refs on empty string pattern Karthik Nayak
2024-01-19 14:27 ` [PATCH 1/5] refs: expose `is_pseudoref_syntax()` Karthik Nayak
2024-01-19 20:37 ` Junio C Hamano
2024-01-22 15:40 ` Karthik Nayak
2024-01-19 14:27 ` [PATCH 2/5] refs: make `is_pseudoref_syntax()` stricter Karthik Nayak
2024-01-19 20:44 ` Junio C Hamano
2024-01-22 20:13 ` Phillip Wood
2024-01-22 20:22 ` Junio C Hamano
2024-01-23 11:03 ` Phillip Wood
2024-01-23 12:49 ` Karthik Nayak
2024-01-23 16:40 ` phillip.wood123
2024-01-23 17:46 ` Junio C Hamano
2024-01-23 17:38 ` Junio C Hamano
2024-01-23 11:16 ` Patrick Steinhardt
2024-01-23 16:30 ` Phillip Wood
2024-01-23 17:44 ` Junio C Hamano
2024-01-24 8:51 ` Patrick Steinhardt
2024-01-19 14:27 ` [PATCH 3/5] refs: extract out `loose_fill_ref_dir_regular_file()` Karthik Nayak
2024-01-19 14:27 ` [PATCH 4/5] refs: introduce `refs_for_each_all_refs()` Karthik Nayak
2024-01-19 20:57 ` Junio C Hamano
2024-01-22 15:48 ` Karthik Nayak
2024-01-22 17:45 ` Junio C Hamano
2024-01-19 14:27 ` [PATCH 5/5] for-each-ref: avoid filtering on empty pattern Karthik Nayak
2024-01-24 15:27 ` [PATCH v2 0/4] for-each-ref: print all refs on empty string pattern Karthik Nayak
2024-01-24 15:27 ` [PATCH v2 1/4] refs: introduce `is_pseudoref()` and `is_headref()` Karthik Nayak
2024-01-24 19:09 ` Junio C Hamano
2024-01-25 16:20 ` Karthik Nayak
2024-01-25 16:28 ` Junio C Hamano
2024-01-25 21:48 ` Karthik Nayak
2024-01-24 15:27 ` [PATCH v2 2/4] refs: extract out `loose_fill_ref_dir_regular_file()` Karthik Nayak
2024-01-24 15:27 ` [PATCH v2 3/4] refs: introduce `refs_for_each_all_refs()` Karthik Nayak
2024-01-24 15:27 ` [PATCH v2 4/4] for-each-ref: avoid filtering on empty pattern Karthik Nayak
2024-01-29 11:35 ` [PATCH v3 0/4] for-each-ref: print all refs on empty string pattern Karthik Nayak
2024-01-29 11:35 ` [PATCH v3 1/4] refs: introduce `is_pseudoref()` and `is_headref()` Karthik Nayak
2024-02-07 1:48 ` Jeff King
2024-02-07 9:27 ` Karthik Nayak
2024-01-29 11:35 ` [PATCH v3 2/4] refs: extract out `loose_fill_ref_dir_regular_file()` Karthik Nayak
2024-01-29 11:35 ` [PATCH v3 3/4] refs: introduce `refs_for_each_all_refs()` Karthik Nayak
2024-01-29 11:35 ` [PATCH v3 4/4] for-each-ref: avoid filtering on empty pattern Karthik Nayak
2024-02-05 18:48 ` Phillip Wood
2024-02-06 5:33 ` Patrick Steinhardt
2024-02-06 10:49 ` Phillip Wood
2024-02-06 8:52 ` Karthik Nayak
2024-02-06 13:55 ` Phillip Wood
2024-02-06 15:30 ` Karthik Nayak
2024-02-06 17:03 ` Junio C Hamano
2024-02-06 18:47 ` Junio C Hamano
2024-02-06 22:10 ` Karthik Nayak
2024-02-06 22:16 ` Junio C Hamano
2024-02-07 14:10 ` Karthik Nayak
2024-02-07 16:00 ` Junio C Hamano
2024-02-07 16:18 ` Karthik Nayak
2024-02-07 16:46 ` Junio C Hamano
2024-02-07 17:02 ` Karthik Nayak
2024-02-08 8:50 ` Patrick Steinhardt
2024-02-08 17:04 ` Junio C Hamano
2024-02-08 17:24 ` Patrick Steinhardt
2024-02-08 17:53 ` Junio C Hamano
2024-02-09 8:08 ` Patrick Steinhardt
2024-02-09 17:15 ` Junio C Hamano
2024-02-09 18:27 ` Karthik Nayak
2024-02-12 6:51 ` Patrick Steinhardt
2024-02-08 10:28 ` Phillip Wood
2024-02-08 17:07 ` Junio C Hamano
2024-02-07 7:48 ` Patrick Steinhardt
2024-02-07 16:01 ` Junio C Hamano
2024-01-29 20:37 ` [PATCH v3 0/4] for-each-ref: print all refs on empty string pattern Junio C Hamano
2024-02-11 18:39 ` [PATCH v4 0/5] for-each-ref: add '--include-root-refs' option Karthik Nayak
2024-02-11 18:39 ` [PATCH v4 1/5] refs: introduce `is_pseudoref()` and `is_headref()` Karthik Nayak
2024-02-12 12:47 ` Patrick Steinhardt
2024-02-12 17:01 ` Junio C Hamano
2024-02-13 15:48 ` Karthik Nayak
2024-02-13 19:42 ` Junio C Hamano
2024-02-14 10:28 ` Karthik Nayak
2024-02-14 16:59 ` Junio C Hamano
2024-02-14 18:15 ` Karthik Nayak
2024-02-12 18:05 ` Junio C Hamano
2024-02-11 18:39 ` [PATCH v4 2/5] refs: extract out `loose_fill_ref_dir_regular_file()` Karthik Nayak
2024-02-11 18:39 ` [PATCH v4 3/5] refs: introduce `refs_for_each_include_root_refs()` Karthik Nayak
2024-02-11 18:39 ` [PATCH v4 4/5] ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR' Karthik Nayak
2024-02-11 18:39 ` [PATCH v4 5/5] for-each-ref: add new option to include root refs Karthik Nayak
2024-02-22 8:46 ` Patrick Steinhardt
2024-02-22 12:57 ` Karthik Nayak
2024-02-22 13:17 ` Patrick Steinhardt
2024-02-23 10:01 ` [PATCH v5 0/5] for-each-ref: add '--include-root-refs' option Karthik Nayak
2024-02-23 10:01 ` [PATCH v5 1/5] refs: introduce `is_pseudoref()` and `is_headref()` Karthik Nayak
2024-02-23 10:01 ` [PATCH v5 2/5] refs: extract out `loose_fill_ref_dir_regular_file()` Karthik Nayak
2024-02-23 10:01 ` [PATCH v5 3/5] refs: introduce `refs_for_each_include_root_refs()` Karthik Nayak
2024-02-23 10:01 ` [PATCH v5 4/5] ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR' Karthik Nayak
2024-02-23 10:01 ` [PATCH v5 5/5] for-each-ref: add new option to include root refs Karthik Nayak
2024-02-23 18:41 ` [PATCH v5 0/5] for-each-ref: add '--include-root-refs' option Junio C Hamano
2024-02-23 20:13 ` Junio C Hamano
2024-02-27 7:39 ` Patrick Steinhardt [this message]
2024-02-27 16:54 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zd2Ru7LWYyGprvcr@tanuki \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
--cc=phillip.wood123@gmail.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.