git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how does "clone --filter=sparse:path" work?

From
Christian Couder <christian.couder@gmail.com>
Date
May 24, 2019, 08:05 UTC
Message-ID
<CAP8UFD0XbOUj70pt4X=HDvGBoLaG9qBv9SWGnM6N8FG3t-57rg@mail.gmail.com>
In-Reply-To
<20181122173931.GA22123@sigill.intra.peff.net>
(Sorry for the late reply to this.)
On Sat, Nov 24, 2018 at 8:07 AM Jeff King <peff@peff.net> wrote:
>
> On Thu, Nov 08, 2018 at 01:57:52PM -0500, Jeff Hostetler wrote:
>
> > > Should we simply be disallowing sparse:path filters over upload-pack?
I agree that it should either be disallowed or heavily restricted.
Show 11 quoted lines
> > The option to allow an absolute path over the wire probably needs more
> > thought as you suggest.
> >
> > Having it in the traverse code was useful for local testing in the
> > client.
> >
> > But mainly I was thinking of a use case on the client of the form:
> >
> >     git rev-list
> >         --objects
> >         --filter=spec:path=.git/sparse-checkout
Do you mean "sparse:path" instead of "spec:path"?
Show 16 quoted lines
> >         --missing=print
> >         <commit>
> >
> > and get a list of the blobs that you don't have and would need before
> > you could checkout <commit> using the current sparse-checkout definition.
> > You could then have a pre-checkout hook that would bulk
> > fetch them before starting the actual checkout.  Since that would be
> > more efficient than demand-loading blobs individually during the
> > checkout.  There's more work to do in this area, but that was the idea.
> >
> > But back to your point, yes, I think we should restrict this over the
> > wire.
>
> Thanks for your thorough response, and sorry for the slow reply. I had
> meant to reply with a patch adding in the restriction, but I haven't
> quite gotten to it. :)

The way I see it could be restricted is by adding a config option on the server, maybe called "uploadpack.sparsePathFilter", to tell which filenames can be accessed using "--filter=sparse:path=".

For example with uploadpack.sparsePathFilter set to "/home/user/git/sparse/*" and "--filter=sparse:path=foo" then "/home/user/git/sparse/foo" on the server would be used if it exists. (Of course care should be taken that things like "--filter=sparse:path=bar/../../foo" are rejected.)

If uploadpack.sparsePathFilter is unset or set to "false", then "--filter=sparse:path=<stuff>" would always error out.

Is this what you had in mind?
Previous: Jeff KingNext: Jeff King
Message 4 of 6 in “how does "clone --filter=sparse:path" work?”
  1. Jeff KingNov 8, 2018
  2. Jeff HostetlerNov 8, 2018
  3. Jeff KingNov 22, 2018
  4. Christian CouderMay 24, 2019
  5. Jeff KingMay 24, 2019
  6. Christian CouderMay 24, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.