Re: [RFC] clone: allow sparse-checkout paths to be specified during clone
- From
Jeff King <peff@peff.net>
- Date
- Jun 30, 2026, 05:32 UTC
- Message-ID
- <20260630053235.GB2495216@coredump.intra.peff.net>
- In-Reply-To
- <CALE2CrTVVQF4rGhGG-9kmjweFHHYw+xnPU6Jtt=QmHpq7L6P2w@mail.gmail.com>
On Mon, Jun 22, 2026 at 05:05:06PM +0530, Pushkar Singh wrote:
Show 18 quoted lines
> Currently, the workflow for this is: > > git clone --sparse <repo> > cd <repo> > git sparse-checkout set <paths> > > While this works as intended, it feels somewhat cumbersome, especially > for someone who is new to Git or not familiar with sparse-checkout > workflows. > > Personally, I do not think of the problem as: > "I need to initialize sparse-checkout and then configure pathspecs." > > Instead, I usually think: > "I only want to clone these directories from the repository." > > With that in mind, I was wondering if it would make sense to allow > sparse-checkout patterns to be specified directly during clone.
I haven't ever really used sparse-checkout, so I don't have much of an opinion. IIRC the sparseness is contained in a patterns file, so I'd have expected the first level of fix to be "you can provide that file at clone time, rather than afterwards". But maybe nobody really touches that file manually, and they just use the sparse-checkout helper. Like I said, I don't have any experience. :)
You might try cc-ing folks who worked on sparse checkouts, especially Stolee.
One final thought from a non-sparse-checkout user: you're coming at it from the point of view of ergonomics (it is annoying to clone and then set up sparsity separately) but there is also a performance question. If the clone knows which paths are of interest, would that make it possible to request a partial clone of the specific paths?
I think probably not in practice, because most servers have path-based filters disabled (because they're expensive and work against bitmaps). So the strategy is usually more like "don't ask for any blobs at all, and then let checkout lazy-load them as we increase the sparse checkout". But I'm also not really a partial-clone user, either. ;)
-Peff