{"thread":{"id":"61114","subject":"Sparse worktree always contains root files","startedAt":"2024-03-13T18:16:57Z","lastAt":"2024-03-13T18:34:29Z","messageCount":2,"participants":["Jeppe Øland","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"490566","messageId":"CA+osTZWsGv01xinFPKbTQOF9mpvfwWs4wJczHSZXLdRxf1OmwA@mail.gmail.com","threadId":"61114","inReplyTo":null,"subject":"Sparse worktree always contains root files","fromName":"Jeppe Øland","fromEmail":"joland@gmail.com","sentAt":"2024-03-13T18:16:46Z","receivedAt":"2024-03-13T18:16:57Z","isPatch":false,"sender":{"key":"joland@gmail.com","avatar":null},"body":"Hi there,\n\nI'm trying to use sparse checkouts in a large project, and one oddity\n(bug?) came up.\n\nIf I do a normal full clone of a repository, then do:\n    git worktree add ../sparse --no-checkout\n    cd ../sparse\n    git sparse-checkout set somepath\n    git checkout\nNow indeed it is a sparse worktree, but the files from the root\ndirectory are also there.\n\nThis also happens with traditional (non-worktree) partial clones.\n(I did both shallow, blob-less and tree-less, and all of them behave\nthe same way)\n\nRegards,\n-Jeppe\n"},{"id":"490570","messageId":"xmqqr0geaslp.fsf@gitster.g","threadId":"61114","inReplyTo":"CA+osTZWsGv01xinFPKbTQOF9mpvfwWs4wJczHSZXLdRxf1OmwA@mail.gmail.com","subject":"Re: Sparse worktree always contains root files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-13T18:34:26Z","receivedAt":"2024-03-13T18:34:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeppe Øland <joland@gmail.com> writes:\n\n> I'm trying to use sparse checkouts in a large project, and one oddity\n> (bug?) came up.\n>\n> If I do a normal full clone of a repository, then do:\n>     git worktree add ../sparse --no-checkout\n>     cd ../sparse\n>     git sparse-checkout set somepath\n>     git checkout\n> Now indeed it is a sparse worktree, but the files from the root\n> directory are also there.\n\nI think this is working as intended.\n\nWithout knowing about the non-tree entries' object names, you cannot\ncreate your next commit on top, as you need to be able to compute\nthe tree object's contents.  You'd update some files in \"somepath\",\nand that directory being populated you can compute the object name\nof the tree that represents the state of \"somepath\" after your\nupdate.  But that object name must be mixed with other things in the\nsame directory as \"somepath\" (i.e. in the root tree), so they must\nbe known.\n"}]}