Re: [PATCH v10 1/5] fetch: add remote.<name>.refmap
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Oct 24, 2026, 15:08 UTC
- Message-ID
- <CALnO6CAhUNRMf=KZmY6YbC-5g3h8DE6U40HehGwbcRTPhDasrg@mail.gmail.com>
- In-Reply-To
- <ba7f1354cd5492ef964ad4d1d398b5ecfc4e0086.1792503778.git.gitgitgadget@gmail.com>
On Tue, Oct 20, 2026 at 9:43 AM Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 17 quoted lines
> > From: Harald Nordgren <haraldnordgren@gmail.com> > > Add a per-remote config variable, remote.<name>.refmap, that provides > the default value for --refmap the same way remote.<name>.fetch > already provides the default refspecs to fetch. Like --refmap itself, > it only maps refs that are actually being fetched, so it has nothing > to do when there is nothing explicit to fetch, on the command line or > via remote.<name>.fetch. > > A refspec-less fetch with a refmap configured but nothing else to say > what to fetch falls back to the same defaults as a remote with no > refspec or refmap at all. Only an explicit --refmap given on the > command line with no command-line refspec to go with it is still > rejected, since that combination is a plain mistake to type, unlike a > remote.<name>.refmap configured on its own. A remote.<name>.fetch > that is also configured is used as before.
A bit wordy in the 2nd paragraph (and LLM-tasting), but… :shrug:
> > Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com> > ---
Show 7 quoted lines
> int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
> {
> - return refspec_find_match(&remote->fetch, refspec);
> + if (remote->fetch.nr)
> + return refspec_find_match(&remote->fetch, refspec);
> + return refspec_find_match(&remote->refmap, refspec);
> }I think this appeared in v2 a bit open-coded, then was refactored in v3, but I haven't seen any comment on it? I might just be missing some.
Anyway, let me think aloud about this. At first glance, we can't fallback to refmap if fetch *fails* to find refspec. Should we or not? I'm not sure.
remote.h says this procedure does "For the given remote, reads the refspec's src and sets the other fields." Ok, and glancing at refspec_find_match the idea is that "refspec" input is a query (with a src or dst) and we find the matching entry and fill out the input's fields.
So… I assume the usual idea would be that refmap is a "superset" of the fetch refspec, since I might want to map refs that I don't normally fetch. (Or it might be disjoint, if none of the mappings apply to my usual fetches.) But that means that remote_find_tracking() won't be able to find entries for the mapped refs that aren't part of my "normal" fetches? Are there downstream consequences of that? I'm not sure, I haven't looked at how else remote_find_tracking is used.
Could that affect, for example, --delete-merged?
-- D. Ben Knoble