Re: [PATCH v3] clone: add clone.<url>.defaultObjectFilter config
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Mar 6, 2026, 10:39 UTC
- Message-ID
- <aaqu44_sDJYcftWd@fruit.crustytoothpaste.net>
- In-Reply-To
- <pull.2058.v3.git.1772780113400.gitgitgadget@gmail.com>
On 2026-03-06 at 06:55:13, Alan Braithwaite via GitGitGadget wrote:
Show 27 quoted lines
> From: Alan Braithwaite <alan@braithwaite.dev> > > Add a new configuration option that lets users specify a default > partial clone filter per URL pattern. When cloning a repository > whose URL matches a configured pattern, git-clone automatically > applies the filter, equivalent to passing --filter on the command > line. > > [clone "https://github.com/"] > defaultObjectFilter = blob:limit=5m > > [clone "https://internal.corp.com/large-project/"] > defaultObjectFilter = blob:none > > URL matching uses the existing urlmatch_config_entry() infrastructure, > following the same rules as http.<url>.* — you can match a domain, > a namespace path, or a specific project, and the most specific match > wins. > > The config only affects the initial clone. Once the clone completes, > the filter is recorded in remote.<name>.partialCloneFilter, so > subsequent fetches inherit it automatically. An explicit --filter > flag on the command line takes precedence. > > Only the URL-qualified form (clone.<url>.defaultObjectFilter) is > honored; a bare clone.defaultObjectFilter without a URL subsection > is ignored.
We've historically not implemented default filtering for clones because it makes it hard to reason about the behaviour of the clone command. For instance, if I have a script that clones a repository, it almost certainly expects a full clone unless it requested something else.
For instance, I run `foo setup` which clones my repository and then I suspend my laptop. I go the airport and get on an airplane which lacks Wi-Fi. I then run `foo blargle`, which operates on the repository, but that fails because it was a partial clone and I'm offline. I didn't realize this wouldn't work because I didn't know that the foo command required a full clone since it's just a script I got from my distro.
We've traditionally placed this kind of customizable configuration into `scalar` instead, which is designed to be configurable and set options for large repositories that would want to control clone and fetch options.
-- brian m. carlson (they/them) Toronto, Ontario, CA