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

Re: [PATCH] unpack-trees: add core.sparseCheckoutRmFiles config

From
TSTim Renouf (open source) <tpr.ll@botech.co.uk>
Date
Jun 5, 2021, 15:33 UTC
Message-ID
<66290CC2-CC83-491F-84BD-3D9107B11EFB@botech.co.uk>
In-Reply-To
<CABPp-BHT3ZrGrDVBcSTuzhSmy0EdtGUeHF_RAVohw=nemGhoOA@mail.gmail.com>
Hi all
> Can you expand on this use case a bit? 
Fundamentally, I wanted sparse-checkout to cause all git commands to completely ignore all files outside sparse-checkout patterns, even if they happen to correspond to paths in the index. I realize that that is difficult to achieve, but I was hoping that my patch would make it close enough to be workable. In particular, I would need to avoid doing a merge (cherry-pick, rebase) with conflicts outside the sparse-checkout patterns.
Here is the (maybe slightly specialized) use case:
Due to decisions out of my hands, I have a monorepo containing some shared code and some separate components in subdirectories. There is a “main” branch where the code is built and delivered from. Each component is developed separately and has its own dev branch, e.g. “dev-component1”, “dev-component2”. Many developers develop on just one component, so they check out its dev branch. The “dev-component1” branch still contains the “main” version of the shared code and the other components, so you can merge it up to the main branch.
But some people want to be able to develop on two components at the same time. So they want to check out component1 on its dev-component1 branch, and component2 on its dev-component2 branch. They would ideally want to do this at the same time as maintaining the overall monorepo directory layout. The monorepo does not give a good way to do that.
I was experimenting with an approach combining sparse-checkout, worktrees, and the core.worktree config item, as follows:
The monorepo has its main worktree at the root of the overall workspace, with sparse-checkout set to check out just the shared code not considered part of any separate component. Each component has its own worktree in its subdirectory, with sparse-checkout set to only check out that component. To get the monorepo-like directory structure, a component’s worktree has its core.worktree config item set to point back up to the root of the overall workspace.
So, with that somewhat hairy structure, anything that touches a file outside of the worktree’s sparse-checkout actually touches a file in a different worktree, giving some surprising results.
Even with my patch, there is still a risk of that happening. And having a component’s worktree rooted somewhere other than where you think it is rooted gave some other surprising results.
I think I am going to abandon that approach and go a different way.
Thanks for the attention.
-tpr
Previous: Elijah NewrenNext: Derrick Stolee
Message 9 of 10 in “bug report: git checkout deletes worktree file even though it is excluded by sparse-checkout”
  1. Tim Renouf (open source)May 28, 2021
  2. Elijah NewrenMay 28, 2021
  3. unpack-trees: add core.sparseCheckoutRmFiles configTim Renouf, Jun 1, 2021
  4. Derrick StoleeJun 2, 2021
  5. Junio C HamanoJun 2, 2021
  6. Elijah NewrenJun 2, 2021
  7. Tim Renouf (open source)Jun 2, 2021
  8. Elijah NewrenJun 2, 2021
  9. Tim Renouf (open source)Jun 5, 2021
  10. Derrick StoleeJun 2, 2021

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.