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

Re: [PATCH] sparse-checkout.txt: new document with sparse-checkout directions

From
Elijah Newren <newren@gmail.com>
Date
Sep 28, 2022, 06:13 UTC
Message-ID
<CABPp-BEuPMZzTc5Lj_cO43XpivZ3+TKhxC11oqzP5_YSLsBrsw@mail.gmail.com>
In-Reply-To
<xmqqzgek7qd9.fsf@gitster.g>
On Tue, Sep 27, 2022 at 9:07 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 27 quoted lines
>
> Elijah Newren <newren@gmail.com> writes:
>
> > Oh, wow, that's something completely outside what I had considered.  I
> > had viewed sparse-checkouts as splitting "tracked files" into two
> > subsets.  As such, `--[no-]restrict` could only affect selecting
> > whether the smaller or larger set of tracked files was of interest.
> > From that viewpoint, untracked files seemed orthogonal, and thus there
> > couldn't be such a thing as an "anamalous untracked file".
> >
> > But this idea is very interesting.  Hmm...
>
> We need to design the behaviour of "git add" sensibly.  Even we say
> "untracked files are just one class and there are two classes of
> tracked ones, those path of current interest and those that are
> uninteresting", we would need to say "'git add F' behaves this way
> if F would become 'tracked path of current interest' when added, but
> the command behaves this other way if F becomes 'tracked path that
> is not interesting right now'".  It may be cleaner to separate the
> untracked ones along the same line as the tracked ones.
>
> Which in turn would mean that the skip-worktree bit cannot be the
> source of truth.  Sparsity specification (either pattern matching or
> being in listed directories) authoritatively decides if a path is of
> the current interest or not.  This is simply because untracked ones
> cannot have that bit ;-)  We can treat the skip-worktree bit as mere
> implementation detail, a measure for optimization.

I like this idea. Seems I should then move 'status' into the category with add/rm/mv -- commands that need to be modified to treat untracked files carefully.

Of course, this also may drag "git clean" into that category...though I'm not sure how or if it'd differ.

[...]
Show 11 quoted lines
> > It feels like "git grep --cached" is perhaps the next thing along this
> > sequence, and I don't see a clear line where to draw that we should
> > limit things to the sparse specification for the index while treating
> > the other operations as full tree; it seems like something feels
> > broken or inconsistent in this sequence of commands if we attempt to
> > do so.
>
> OK, it seems that "--cached" has many cases that it wants to operate
> on full tree.  I am in general more in favor of making things work
> on full tree, simply because I feel it would have less chance of
> going wrong, so defaulting to --no-restrict would be fine ;-)

Yeah, I think for the camp B folks, "--no-restrict" may make more sense for operations searching or comparing to the index.

However, there's also another possibility I'm still mulling over. To understand it, first note that relative to the working tree, the "sparse specification" can temporarily differ from the "paths matching the sparsity patterns", because additional files might be transiently present. This most often happens due to conflicts, and we want worktree related operations that behave under "restrict" mode (such as "diff" or "grep" or "switch") to operate on all present tracked files[1]. With that understanding, we could similarly consider that relative to the index, the "sparse specification" could temporarily differ from the "paths matching the sparsity patterns", because additional paths outside the sparsity patterns could have been modified in the index (e.g. during a merge or rebase or whatever).

Using a temporarily expanded sparsity specification may allow a "restrict-like" behavior to make sense for index-related operations. I currently think that'd be more useful for the camp A folks than the camp B folks, though.

Either way, I don't think the index should use the sparsity defined by or for the working tree. The idea of using the working tree sparsity for index-related operations may sound nice at first, but I think it only behaves well when all paths modified in the index or working tree are limited to those paths matching the sparsity patterns. And there's too many normal cases where that just doesn't hold.

[1] See also 82386b4496 ("Merge branch 'en/present-despite-skipped'", 2022-03-09)

Previous: Junio C HamanoNext: Elijah Newren
Message 10 of 46 in “sparse-checkout.txt: new document with sparse-checkout directions”
  1. sparse-checkout.txt: new document with sparse-checkout directionsElijah Newren via GitGitGadget, Sep 25, 2022
  2. Junio C HamanoSep 26, 2022
  3. Junio C HamanoSep 26, 2022
  4. Elijah NewrenSep 27, 2022
  5. Junio C HamanoSep 27, 2022
  6. Victoria DyeSep 26, 2022
  7. Junio C HamanoSep 26, 2022
  8. Elijah NewrenSep 27, 2022
  9. Junio C HamanoSep 27, 2022
  10. Elijah NewrenSep 28, 2022
  11. Elijah NewrenSep 27, 2022
  12. Derrick StoleeSep 27, 2022
  13. Elijah NewrenSep 28, 2022
  14. Junio C HamanoSep 27, 2022
  15. Elijah NewrenSep 28, 2022
  16. Derrick StoleeSep 27, 2022
  17. Elijah NewrenSep 28, 2022
  18. Derrick StoleeSep 28, 2022
  19. Elijah NewrenOct 6, 2022
  20. Derrick StoleeOct 6, 2022
  21. Elijah NewrenOct 7, 2022
  22. ZheNing HuSep 30, 2022
  23. Elijah NewrenOct 6, 2022
  24. ZheNing HuOct 15, 2022
  25. Elijah NewrenOct 15, 2022
  26. ZheNing HuOct 15, 2022
  27. ZheNing HuSep 30, 2022
  28. sparse-checkout.txt: new document with sparse-checkout directionsElijah Newren via GitGitGadget, Sep 28, 2022
  29. sparse-checkout.txt: new document with sparse-checkout directionsElijah Newren via GitGitGadget, Oct 8, 2022
  30. sparse-checkout.txt: new document with sparse-checkout directionsElijah Newren via GitGitGadget, Nov 6, 2022
  31. Derrick StoleeNov 7, 2022
  32. Elijah NewrenNov 16, 2022
  33. ZheNing HuNov 15, 2022
  34. ZheNing HuNov 16, 2022
  35. Elijah NewrenNov 16, 2022
  36. Elijah NewrenNov 16, 2022
  37. ZheNing HuNov 16, 2022
  38. ZheNing HuNov 16, 2022
  39. ZheNing HuNov 16, 2022
  40. Elijah NewrenNov 19, 2022
  41. Elijah NewrenNov 19, 2022
  42. ZheNing HuNov 23, 2022
  43. ZheNing HuJan 14, 2023
  44. Elijah NewrenJan 20, 2023
  45. ZheNing HuJan 23, 2023
  46. Elijah NewrenJan 24, 2023

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.