Hi Junio, On Wed, 15 Jun 2022, Junio C Hamano wrote: > Tao Klerks <tao@xxxxxxxxxx> 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. > 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. > 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