From: Junio C Hamano <gitster@pobox.com>
To: Tao Klerks <tao@klerks.biz>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
git <git@vger.kernel.org>
Subject: Re: Plumbing for mapping from a remote tracking ref to the remote ref?
Date: Tue, 05 Sep 2023 15:18:14 -0700 [thread overview]
Message-ID: <xmqqpm2wqn6h.fsf@gitster.g> (raw)
In-Reply-To: <CAPMMpojUrfSmpgWVh3TTn_uamPCcyHRQf2R3APSpEjsqujNXvA@mail.gmail.com> (Tao Klerks's message of "Sun, 3 Sep 2023 09:16:00 +0200")
Tao Klerks <tao@klerks.biz> writes:
> On Sun, Jun 19, 2022 at 1:04 AM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>>
>> >> $ git refmap refs/remotes/somepath/{branch-A,branch-B}
>> >> origin refs/heads/branch-A
>> >> origin refs/heads/branch-B
>> >>
>> >> IOW, you give name(s) of remote-tracking branches and then you get
>> >> the remote and their ref for these?
>> >
>> > Modulo introducing a new top-level command (a subcommand of `git remote`
>> > would make much more sense and make the feature eminently more
>> > discoverable), and modulo allowing patterns in the ref to match, I agree.
>>
>> "git remote" is primarily about "I have this remote---tell me more
>> about it", but this query goes in the other direction, and that is
>> why I threw a non-existing command to solicit alternatives that are
>> potentially better than "git remote".
>
> Thank you for the responses here, and my apologies for not following
> up (much) earlier.
> ...
> Would something like the following be mutually agreeable?
>
> $ git remote origin map-ref
> refs/remotes/my-favorite-remotes/origin/someref
> refs/heads/someref
With strainge line wrapping, I cannot quite tell what is the input
and what is the output, but if you meant that the part up to the
long-ish refname in the refs/remotes is the command line, and map-ref
is the new subcommand name in the "git remote" command, i.e.
$ git remote map-ref origin refs/remotes/my-favorite-remotes/origin/someref
is the input, to which the output
refs/heads/someref
is given, I am not sure what its value is. First of all, the user
is giving a ref in a hierarchy that is usually used for the remote
whose name is "my-favorite-remotes". What made this user _know_
that the remote reference belongs to "origin"? Isn't that part of
what the user may want to _find_ _out_, instead of required to give
as input?
So, no, I do not think it is agreeable at least not from this end,
but I may be misunderstanding what you meant to present as your
design.
I would understand if it were more like
$ git remote refmap refs/remotes/somepath/{branch-A,branch-B}
origin:refs/heads/branch-A refs/remotes/somepath/branch-A
origin:refs/heads/branch-B refs/remotes/somepath/branch-B
that is,
(1) the new subcommand (refmap) takes one or more refs from the
command line; they typically are in the refs/remotes hiearchy
and each asks which remote's which ref needs to be fetched to
update the ref. Note that the user does *not* need to know
which remote the refs will be updated from.
(2) the subcommand goes through the "remote.*.fetch" configuration
items (and its older equivalents in .git/remotes, whose support
should come free if you used remote.c API properly) to find
what ref from what remote is fetched to update the refs given
from the command line.
(3) the output is "<remote>:<ref-at-remote> <our-remote-tracking-branch>"
one line at a time.
Note that this format allows the "two remotes can both update the
same remote tracking branches we have" arrangement.
next prev parent reply other threads:[~2023-09-05 22:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 19:12 Plumbing for mapping from a remote tracking ref to the remote ref? Tao Klerks
2022-06-15 20:18 ` Junio C Hamano
2022-06-18 22:04 ` Johannes Schindelin
2022-06-18 23:04 ` Junio C Hamano
2023-09-03 7:16 ` Tao Klerks
2023-09-05 22:18 ` Junio C Hamano [this message]
2023-09-06 4:21 ` Tao Klerks
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=xmqqpm2wqn6h.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=tao@klerks.biz \
/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;
as well as URLs for NNTP newsgroup(s).