Subject: Re: [PATCH v3] clone: add clone.<url>.defaultObjectFilter config

From: "brian m. carlson" <[email-masked]>
Date: Fri, 6 Mar 2026 10:39:31 +0000

On 2026-03-06 at 06:55:13, Alan Braithwaite via GitGitGadget wrote:
> From: Alan Braithwaite <[email-masked]>
> 
> 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