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

Questions about partial clone with '--filter=tree:0'

From
AMAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Date
Oct 20, 2020, 17:09 UTC
Message-ID
<aa7b89ee-08aa-7943-6a00-28dcf344426e@syntevo.com>

This is a edited copy of message I sent 2 weeks ago, which unfortunately didn't receive any replies. I tried to make make it shorter this time :)

----

We are implementing a git UI. One interesting case is the repository cloned with '--filter=tree:0', because it makes it a lot harder to run basic git operations such as file log and blame.

The problems and potential solutions are outlined below. We should be able to make patches for (2) and (3) if it makes sense to patch these.

(1) Is it even considered a realistic use case?
-----------------------------------------------
Summary: is '--filter=tree:0' a realistic or "crazy" scenario that is
not considered worthy of supporting?

I decided to use Linux repo, which is reasonably large, and it seems that '--filter=tree:0' could be desired because it helps with disk space (~0.66gb) and network (~0.54gb):

https://github.com/torvalds/linux.git
   951025 commits total.
   git clone --bare <url>
	7'624'042 objects
	   2.86gb network
	   3.10gb disk
   git clone --bare --filter=blob:none <url>
	5'484'714 (71.9%) objects
	   1.01gb (35.3%) network
	   1.16gb (37.4%) disk
   git clone --bare --filter=tree:0 <url>
	  951'693 (12.5%) objects
	   0.47gb (16.4%) network
	   0.50gb (16.1%) disk
   git clone --bare --depth 1 --branch master <url>
	   74'380 ( 0.9%) objects
	   0.19gb ( 6.6%) network
	   0.19gb ( 6.1%) disk

(2) A command to enrich repo with trees --------------------------------------- There is no good way to "un-partial" repository that was cloned with '--filter=tree:0' to have all trees, but no blobs.

There seems to be a dirty way of doing that by abusing 'fetch --deepen' which happens to skip "ref tip already present locally" check, but it will also re-download all commits, which means extra ~0.5gb network in case of Linux repo.

(3) A command to download ALL trees and/or blobs for a subpath
-----------------------------------------------
Summary: Running a Blame or file log in '--filter=tree:0' repo is
currently very inefficient, up to a point where it can be discussed
as not really working.

The suggested command will be able to accept a path and download ALL trees and/or blobs that match it.

This will solve many problems at once:
* Solve (2)
* Make it possible to prepare for efficient blame and file log
* Make a new experience with super-mono-repos, where user will now
   be able to only download a part of it by path.

Currently '--filter=sparse:oid' is there to support that, but it is very hard to use on client side, because it requires paths to be already present in a commit on server.

For a possible solution, it sounds reasonable to have such filter:
   --filter=sparse:pathlist=/1/2'
Path list could be delimited with some special character, and paths
themselves could be escaped.
Next: Taylor Blau
Message 1 of 9 in “Questions about partial clone with '--filter=tree:0'”
  1. Alexandr MiloslavskiyOct 20, 2020
  2. Taylor BlauOct 20, 2020
  3. Alexandr MiloslavskiyOct 21, 2020
  4. Taylor BlauOct 21, 2020
  5. Alexandr MiloslavskiyOct 21, 2020
  6. Jonathan TanOct 26, 2020
  7. Alexandr MiloslavskiyOct 26, 2020
  8. Jonathan TanOct 26, 2020
  9. Alexandr MiloslavskiyOct 26, 2020

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.