git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Plumbing for mapping from a remote tracking ref to the remote ref?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jun 18, 2022, 22:04 UTC
Message-ID
<nycvar.QRO.7.76.6.2206182358350.349@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqqilp1znn1.fsf@gitster.g>
Hi Junio,
On Wed, 15 Jun 2022, Junio C Hamano wrote:
Show 18 quoted lines
> Tao Klerks <tao@klerks.biz> writes:
>
> > Given the following configured fetch refspec for a remote:
> >
> > [remote "origin"]
> >         url = git@someserver:somerepo.git
> >         fetch = +refs/heads/*:refs/remotes/somepath/*
> >
> > And given a ref of the form "refs/remotes/somepath/branch_A",
> >
> > I'm wondering whether there is any plumbing that would be able to tell
> > me what to put in a "fetch" command, to get
> > "refs/remotes/somepath/branch_A" fetched - in other words, is there
> > any plumbing that can use the configured fetch refspecs to map
> > "refs/remotes/somepath/branch_A" to "refs/heads/branch_A" for me, so
> > that I can then do "git fetch origin refs/heads/branch_A".
>
> I am fairly certain that I never have written one myself ;-)

I looked for something like that, but did not find it. We seem to have the functions `apply_refspecs()`, `query_refspecs()` and `remote_find_tracking()` that could be used to that end, but I do not see any of them being used in plumbing that would expose the ref mapping in the desired way.

Show 11 quoted lines
> I wonder how the end-user experience should look like.
>
> 	$ git refmap refs/remotes/somepath/branch-A
> 	origin refs/heads/branch-A
>
> 	$ 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.

Show 19 quoted lines
> I do not oppose to such a command existing, but I do not know what
> the right answer should be for a case like this:
>
> 	[remote "origin"]
> 		url = ... the official project repository ...
> 		fetch = +refs/heads/*:refs/remotes/upstream/*
>
> 	[remote "mirror"]
> 		url = ... a local mirror you'd use regularly ...
> 		fetch = +refs/heads/*:refs/remotes/upstream/*
>
> In order to support such a "more than one can update the same" case
> sensibly, the output may have to repeat the input, e.g.
>
> 	$ git refmap refs/remotes/upstream/main
> 	refs/remotes/upstream/main	origin refs/heads/main
> 	refs/remotes/upstream/main	mirror refs/heads/main
>
> perhaps?
Sounds like a good plan to me.

Ciao, Dscho

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “Plumbing for mapping from a remote tracking ref to the remote ref?”
  1. Tao KlerksJun 15, 2022
  2. Junio C HamanoJun 15, 2022
  3. Johannes SchindelinJun 18, 2022
  4. Junio C HamanoJun 18, 2022
  5. Tao KlerksSep 3, 2023
  6. Junio C HamanoSep 5, 2023
  7. Tao KlerksSep 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.