Re: [PATCH v10 2/5] fetch: extract collect_upstream_from_remote() helper
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Oct 27, 2026, 19:41 UTC
- Message-ID
- <CALnO6CBEPcPeTmZj2_O6WMXdjo4e6YiQCctN3Bs-o9LSN2rsrw@mail.gmail.com>
- In-Reply-To
- <CAHwyqnVELh2ZyCy5W8+jHHWN=UvcgMJP0k0i1PJKU5bU_AhUrw@mail.gmail.com>
On Sun, Oct 25, 2026 at 1:20 PM Harald Nordgren <haraldnordgren@gmail.com> wrote:
Show 40 quoted lines
> > > > The latter is independent of the former on purpose: a narrow > > > refspec (for example from "git remote add -t") can leave the current > > > branch's own upstream uncovered, and we still need to be able to fetch > > > it. > > > > I don't really understand the meaning here. I can guess that you mean > > something like "A remote with a narrow refspec, like what you get from > > 'git remote add -t', can omit a branch's upstream from the remote's > > fetch refspec, and we still want to fetch that upstream." But it's > > taken me a while to put that together (after puzzling out the above) > > after first not knowing what "uncovered" meant. > > > > I think the whole thing would be clearer with an example: > > > > """ > > Imagine a remote with a narrow refspec: > > > > git remote add -t main colleague <remote> > > > > and a branch whose upstream points at that remote, but isn't part of > > the remote's refspec: > > > > git fetch colleague work:refs/remotes/colleague/work > > git switch -c work colleague/work > > > > When we "git fetch colleague" without a refspec, we decide what to > > fetch by combining the remote's refspec (main -> remote-tracking > > branch, in this case) and the current branch's upstream, if it was > > based on that remote (work -> remote-tracking branch, in this case). > > """ > > > > Note: we aren't "guessing" what to fetch! > > Thanks! Maybe this should be the example instead? > > git clone --single-branch <url> > git switch -c work > git push -u origin work >
I'm not sure if that captures the same "narrow refspec" remote or not, to be honest, though it might be simpler? I'm not sure what the push has to do with it, though, and I don't know what you think about the rest of the proposed wording ;)
[later]
Reading the new version, I think I see what you're after. I personally would love to see an example adding a remote, since I tend to want "big" fetches from my primary remotes, but that's fine.