From: Tian Yuchen <a3205153416@gmail.com>
To: JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
"brian m. carlson" <sandals@crustytoothpaste.net>,
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>,
git@vger.kernel.org, kumarayushjha123@gmail.com,
valusoutrik@gmail.com, pushkarkumarsingh1970@gmail.com
Subject: Re: [PATCH 0/4] repo: add support for path-related fields
Date: Tue, 3 Mar 2026 17:28:03 +0800 [thread overview]
Message-ID: <46c60949-87f1-426a-aeb9-706e97fd8e8a@gmail.com> (raw)
In-Reply-To: <CA+rGoLc+ULYUZaDCdAHxuL8T-qyjJKTRJfSe6Muhb7c6d12e_w@mail.gmail.com>
Hi JAYATHEERTH,
Thanks for the reply.
> To clarify my earlier comment: I wasn't arguing against ref-filter.
> In fact, I’m more inclined toward using the best tool for the job.
> My earlier point was mainly about behavioral similarity and how both
> belong to the same camp even though they might seem different.
> I just meant both the ideas are in the same camp just unrealized.
That's exactly right. I was just reminding that there's a ready-made
solution available that seems to work very well. Wouldn't reinventing
something that already exists, with only minor differences, cause
confusion? (´;ω;`)
> something like this:
>
> static const struct repo_info_field repo_info_field[] = {
> { "layout.bare", get_layout_bare },
> { "layout.shallow", get_layout_shallow },
> { "object.format", get_object_format },
> { "path.toplevel", get_path_toplevel },
> };
>
> This array contains all the keys
> You do not need to hardcode path.absolute.toplevel,
> path.relative.toplevel, etc., in the array...
>
> Instead,
>
> If the user asks for path.absolute.toplevel:
> You detect the absolute. middle part. strip it out to find the base
> key path.toplevel.
> You find path.toplevel in the aray, the array works with default
> values when entered --all
>
> /*
> * Helper to parse the key variant.
> * Takes "path.absolute.git-dir" -> returns "path.git-dir" and sets
> opts->format.
> */
> static char *normalize_key(const char *raw_key, struct repo_info_opts *opts)
> {
> const char *suffix;
>
> /* Check for "path.absolute." prefix */
> if (skip_prefix(raw_key, "path.absolute.", &suffix)) {
> opts->path_format = PATH_FORMAT_ABSOLUTE;
> return xstrfmt("path.%s", suffix);
> }
>
> /* Check for "path.relative." prefix */
> if (skip_prefix(raw_key, "path.relative.", &suffix)) {
> opts->path_format = PATH_FORMAT_RELATIVE;
> return xstrfmt("path.%s", suffix);
> }
>
> /* No variant found, return raw key as-is */
> return xstrdup(raw_key);
> }
I see. What you've written matches what you described — it essentially
replicates the functionality of ref-filter.c. While I understand this is
just a simple code implementation demo:
> opts->path_format = PATH_FORMAT_ABSOLUTE;
This implementation appears unable to support input like 'git repo-info
--keys=path.absolute.toplevel,path.relative.gitdir', meaning it cannot
handle multiple paths output from a single call as previously mentioned
by Brain. The 'opts' here should be a global shared state, right?
I think it's better for the parser to allocate a separate memory for
each arg it encounters. But then we'd be back to implementing something
like struct used_atom, hahaha (ゝ∀・)
Thank you again for your email.
Yuchen
(I feel like we've been on this topic for too long. If you don't want to
reply, you don't have to :-)
next prev parent reply other threads:[~2026-03-03 9:28 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-28 22:05 [PATCH 0/4] repo: add support for path-related fields Lucas Seiki Oshiro
2026-02-28 22:05 ` [PATCH 1/4] rev-parse: prepend `path_` to path-related enums Lucas Seiki Oshiro
2026-02-28 22:05 ` [PATCH 2/4] path: add new function strbuf_add_path Lucas Seiki Oshiro
2026-02-28 22:05 ` [PATCH 3/4] repo: add the --format-path flag Lucas Seiki Oshiro
2026-02-28 22:05 ` [PATCH 4/4] repo: add the field path.toplevel Lucas Seiki Oshiro
2026-03-01 4:24 ` Tian Yuchen
2026-03-01 20:21 ` Lucas Seiki Oshiro
2026-03-02 4:54 ` Tian Yuchen
2026-03-01 2:58 ` [PATCH 0/4] repo: add support for path-related fields JAYATHEERTH K
2026-03-01 5:45 ` Ayush Jha
2026-03-01 6:50 ` JAYATHEERTH K
2026-03-01 19:55 ` Lucas Seiki Oshiro
2026-03-03 3:27 ` Ayush Jha
2026-03-01 19:49 ` Lucas Seiki Oshiro
2026-03-01 10:44 ` Phillip Wood
2026-03-01 19:40 ` Lucas Seiki Oshiro
2026-03-01 21:25 ` brian m. carlson
2026-03-02 16:38 ` Junio C Hamano
2026-03-02 18:51 ` Tian Yuchen
2026-03-02 21:34 ` Junio C Hamano
2026-03-03 2:48 ` JAYATHEERTH K
2026-03-03 4:32 ` Tian Yuchen
2026-03-03 7:23 ` JAYATHEERTH K
2026-03-03 9:28 ` Tian Yuchen [this message]
2026-03-03 10:31 ` JAYATHEERTH K
2026-03-08 0:29 ` Lucas Seiki Oshiro
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=46c60949-87f1-426a-aeb9-706e97fd8e8a@gmail.com \
--to=a3205153416@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jayatheerthkulkarni2005@gmail.com \
--cc=kumarayushjha123@gmail.com \
--cc=lucasseikioshiro@gmail.com \
--cc=pushkarkumarsingh1970@gmail.com \
--cc=sandals@crustytoothpaste.net \
--cc=valusoutrik@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox