Git development
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH] fetch: add config to avoid fetching every branch in shallow repo
Date: Wed, 23 Sep 2026 16:19:06 +0100	[thread overview]
Message-ID: <05d0e6e0-e156-4a2a-95a0-4986ab18ef49@gmail.com> (raw)
In-Reply-To: <xmqqh5jhfbyw.fsf@gitster.g>

On 22/09/2026 18:11, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>> I think the sparse checkout is irrelevant? It is unclear to me if this
>> is talking about a case where there are many branches in the remote
>> repository and only one of them was cloned, then adding a second remote
>> created a wildcard fetch refspec; or if there are intentionally lots of
>> remote tracking branches in the local repository and you don't want to
>> wait for them all to update. If it is the former then we should think
>> how we can improve the behavior of "git remote add" in a sparse
>> repository to prevent it adding a wildcard fetch refspec and instead
>> setup the new remote to fetch only the branch(es) we're interested in.
> 
> Very good suggestions.  "Avoid wildcards" is easy, but designing a
> suitable alternative ("only the ones we are interested in") may be
> harder.
> 
> Perhaps we want to have something similar in spirit to the
> "matching" mode 'git push' has, where the set of local branches we
> have defines the set of branches we are interested in?  That is,
> when 'remote.*.fetch' is configured to signal that special mode,
> 'git fetch' would:
> 
>   - Find each local branch that has its '@{upstream}' set to a branch
>     at the remote we are fetching from.
> 
>   - Fetch these branches at the remote that our local branches care
>     about.

I can see that being useful fetch mode for a remote that we've already 
fetched from, but for a newly added remote there will be no local 
branches with their upstream set to it because "git branch 
--set-upstream-to" fails if the upstream does not already exist. So I 
like the idea for fetching from existing remotes, but it leaves us with 
a chicken-and-egg problem when adding new remotes, so I'm not sure how 
it would work in practice.

Thanks

Phillip
  > I said "in spirit" above, and I find it tempting to use ':' and '+:'
> as the special '<refspec>' to trigger this mode, to mimic what 'git
> push' does when using the local branches we have as the set of
> branches we care about.  But there are important differences:
> 
>   (1) The correspondence between local and remote-tracking branches
>       is not one-to-one, as you can fork multiple local topics out
>       of the same upstream branch.  Maybe our 7 local branches build
>       on top of only 2 branches we fetch from the remote, for
>       example.
> 
>   (2) Corollary.  Unlike the matching mode in 'git push' where local
>       branch 'B' is used to update branch 'B' at the remote (if it
>       exists), this new mode in 'git fetch' only uses local branches
>       as a guide to determine which branches to fetch from the
>       remote.  If our local branch 'B' builds on top of branch 'U' at
>       the remote, it is branch 'U' we fetch and store as the
>       'refs/remotes/R/U' remote-tracking branch, where 'R' is the
>       remote, and 'B' as the name does not get anywhere in the
>       picture.
> 
> In other words, this is not "matching" at all, even though it takes
> inspiration from it.  I do not know what it should be called, but I
> think it would be a useful addition.
> 
> Thanks.


  parent reply	other threads:[~2026-09-23 15:19 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 14:47 [PATCH] fetch: add config to avoid fetching every branch in shallow repo Harald Nordgren via GitGitGadget
2026-09-21 13:28 ` Phillip Wood
2026-09-21 21:45   ` Harald Nordgren
2026-09-22 13:00     ` Harald Nordgren
2026-09-22 14:53       ` Phillip Wood
2026-09-22 15:37         ` Harald Nordgren
2026-09-23 15:14           ` Phillip Wood
2026-09-22 17:11   ` Junio C Hamano
2026-09-22 21:40     ` Harald Nordgren
2026-09-23 15:19     ` Phillip Wood [this message]
2026-09-23 15:34       ` Junio C Hamano
2026-09-23 16:55         ` D. Ben Knoble
2026-09-23 19:50           ` Junio C Hamano
2026-09-24 17:10             ` D. Ben Knoble
2026-09-24 18:02               ` Junio C Hamano
2026-09-23 20:35 ` [PATCH v2] fetch: avoid fetching every branch of a new remote in a " Harald Nordgren via GitGitGadget
2026-09-23 21:38   ` Junio C Hamano
2026-09-25 10:49 ` [PATCH v3 0/4] " Harald Nordgren via GitGitGadget
2026-09-25 10:49   ` [PATCH v3 1/4] fetch: add remote.<name>.refmap Harald Nordgren via GitGitGadget
2026-09-25 22:38     ` Junio C Hamano
2026-09-25 10:50   ` [PATCH v3 2/4] fetch: infer branches to fetch from a refmap-only remote Harald Nordgren via GitGitGadget
2026-09-25 23:26     ` Junio C Hamano
2026-09-25 10:50   ` [PATCH v3 3/4] remote: add "git remote add --limited-fetch" Harald Nordgren via GitGitGadget
2026-09-25 10:50   ` [PATCH v3 4/4] remote: default to --limited-fetch in a shallow repository Harald Nordgren via GitGitGadget
2026-09-29  9:19 ` [PATCH v4 0/4] fetch: avoid fetching every branch of a new remote in a shallow repo Harald Nordgren via GitGitGadget
2026-09-29  9:19   ` [PATCH v4 1/4] fetch: add remote.<name>.refmap Harald Nordgren via GitGitGadget
2026-09-29  9:19   ` [PATCH v4 2/4] fetch: infer branches to fetch from a refmap-only remote Harald Nordgren via GitGitGadget
2026-09-29  9:27     ` Harald Nordgren
2026-09-29 20:17     ` Junio C Hamano
2026-09-29  9:19   ` [PATCH v4 3/4] remote: add "git remote add --limited-fetch" Harald Nordgren via GitGitGadget
2026-09-29  9:19   ` [PATCH v4 4/4] remote: default to --limited-fetch in a shallow repository Harald Nordgren via GitGitGadget
2026-09-29 19:36   ` [PATCH v4 0/4] fetch: avoid fetching every branch of a new remote in a shallow repo Junio C Hamano
2026-10-02  7:13 ` [PATCH v5 " Harald Nordgren via GitGitGadget
2026-10-02  7:13   ` [PATCH v5 1/4] fetch: add remote.<name>.refmap Harald Nordgren via GitGitGadget
2026-10-02  7:13   ` [PATCH v5 2/4] fetch: infer branches to fetch from a refmap-only remote Harald Nordgren via GitGitGadget
2026-10-02  7:13   ` [PATCH v5 3/4] remote: add "git remote add --limited-fetch" Harald Nordgren via GitGitGadget
2026-10-02 16:28     ` Junio C Hamano
2026-10-02  7:13   ` [PATCH v5 4/4] remote: default to --limited-fetch in a shallow repository Harald Nordgren via GitGitGadget
2026-10-04  8:31 ` [PATCH v6 0/4] fetch: avoid fetching every branch of a new remote in a shallow repo Harald Nordgren via GitGitGadget
2026-10-04  8:31   ` [PATCH v6 1/4] fetch: add remote.<name>.refmap Harald Nordgren via GitGitGadget
2026-10-04  8:31   ` [PATCH v6 2/4] fetch: infer branches to fetch from a refmap-only remote Harald Nordgren via GitGitGadget
2026-10-04  8:31   ` [PATCH v6 3/4] remote: add "git remote add --limited-fetch" Harald Nordgren via GitGitGadget
2026-10-04  8:31   ` [PATCH v6 4/4] remote: default to --limited-fetch in a shallow repository Harald Nordgren via GitGitGadget
2026-10-04 17:17   ` [PATCH v6 0/4] fetch: avoid fetching every branch of a new remote in a shallow repo Junio C Hamano
2026-10-04 19:51     ` Harald Nordgren
2026-10-05 12:17       ` Junio C Hamano
2026-10-05 18:09         ` Harald Nordgren
2026-10-07 21:56 ` [PATCH v7 " Harald Nordgren via GitGitGadget
2026-10-07 21:56   ` [PATCH v7 1/4] fetch: add remote.<name>.refmap Harald Nordgren via GitGitGadget
2026-10-07 21:56   ` [PATCH v7 2/4] fetch: infer branches to fetch from a refmap-only remote Harald Nordgren via GitGitGadget
2026-10-08 16:59     ` Junio C Hamano
2026-10-09  7:05       ` Harald Nordgren
2026-10-09  8:09       ` Harald Nordgren
2026-10-07 21:56   ` [PATCH v7 3/4] remote: add "git remote add --limited-fetch" Harald Nordgren via GitGitGadget
2026-10-07 21:56   ` [PATCH v7 4/4] remote: default to --limited-fetch in a shallow repository Harald Nordgren via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05d0e6e0-e156-4a2a-95a0-4986ab18ef49@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=haraldnordgren@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox