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

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

From
Tao Klerks <tao@klerks.biz>
Date
Jun 15, 2022, 19:12 UTC
Message-ID
<CAPMMpogUxq59zj+=7UDiURYbydAwvymOqhEWaheT9fkU8HaP4Q@mail.gmail.com>
Hi folks,
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 understand I can parse the fetch refspecs myself, assuming any asterisk is only ever on the tail end of the ref pattern... but that seems very complicated, given that this is *probably* something others have needed to do in the past?

Fwiw I've noticed that "git rev-parse --symbolic-full-name" knows how to do almost exactly the *opposite* of that, when presented with the "@{u}" pattern - it looks up the "branch.XXX.merge" value, which is written in a remote-relative form ("refs/heads/branch_A" in this example), and converts that to the "local" fetch destination (eg "refs/remotes/somepath/branch_A"). But I don't know how to go the opposite way, given only a local fetch destination and wanting to tell fetch what to get - it expects a remote-relative ref.

Any help appreciated!

Thanks, Tao

Next: Junio C Hamano
Message 1 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.