From: Junio C Hamano <gitster@pobox.com>
To: Meet Soni <meetsoni3017@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [GSoC][PATCH] refspec: clarify function naming and documentation
Date: Fri, 14 Feb 2025 10:56:49 -0800 [thread overview]
Message-ID: <xmqqldu8l5hq.fsf@gitster.g> (raw)
In-Reply-To: <20250214053938.26807-1-meetsoni3017@gmail.com> (Meet Soni's message of "Fri, 14 Feb 2025 11:09:38 +0530")
Meet Soni <meetsoni3017@gmail.com> writes:
> Rename `match_name_with_pattern()` to `match_refname_with_pattern()` to
> better reflect its purpose and improve documentation comment clarity.
> The previous function name and parameter names were inconsistent, making
> it harder to understand their roles in refspec matching.
>
> - Rename parameters:
> - `key` -> `src_pattern` (source globbing pattern)
> - `name` -> `refname` (refname to check)
> - `value` -> `dst_pattern` (destination mapping pattern)
>
> Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
> ---
> This change was previously discussed in an earlier patch series [1], where
> Junio suggested making this update after the dust settled there.
>
> [1]: https://lore.kernel.org/git/xmqqa5bctbnx.fsf@gitster.g/
Yeah, and the dust settled a few days ago when the
ms/refspec-cleanup topic graduated to the 'master' branch.
Thanks for that work.
The tldr is that I like two things in the above rename, and find two
things problematic. "name->refname" is very good, adding "pattern"
is very good. using "src" and "dst" is problematic.
One thing to note is that match_refname_with_pattern() can also be
used to reverse map.
A refspec that says "refs/heads/*:refs/remotes/origin/*" can be used
to answer these two questions:
* I see what they call "refs/heads/master", where should I store it?
* I have "refs/remotes/origin/main", where did it come from?
The src/dst distinction you updated the parameters to the function
only reflects the first usage, and it is a bit confusing when the
code asks the other question.
Find the "refname" in A and replace the same glob part in B when
it finds a match
is what the function does, and we used to call A=key and B=value,
which were not great. With "pattern" in their names, the new names
"src/dst_pattern" are improvement, but src/dst hints as if they are
directly related to src/dst sides of a refspec, which is the source
of possible confusion when we talk about the "please map from our
remote-tracking branch name to the branch name at the origin" use
case.
So, I very much have problems with the "(*source* globbing pattern)"
you state as the reasoning beind the new name in the proposed log
message and "src/dst" in these names.
What do other people who wrote tools that do something very similar
call these two things? For example, "sed -e 's/A/B/'" command does
"find A and replace with B". They call A=RE and B=replacement
Perhaps "key -> pattern" and "value -> replacement" would be a
better pair of names that are easier to understand? I dunno.
> -int match_name_with_pattern(const char *key, const char *name,
> - const char *value, char **result)
> +int match_refname_with_pattern(const char *src_pattern, const char *refname,
> + const char *dst_pattern, char **result)
> {
Thanks.
next prev parent reply other threads:[~2025-02-14 18:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 5:39 [GSoC][PATCH] refspec: clarify function naming and documentation Meet Soni
2025-02-14 18:56 ` Junio C Hamano [this message]
2025-02-15 8:45 ` [GSoC][PATCH v2] " Meet Soni
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=xmqqldu8l5hq.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=meetsoni3017@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.