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

Re: [PATCH v3 2/3] sparse-checkout: custom tab completion

From
Elijah Newren <newren@gmail.com>
Date
Jan 18, 2022, 23:30 UTC
Message-ID
<CABPp-BEwMAPHGt5xD9jDU58grbrAqCdqNY9Nh8UJGLKuLbArXQ@mail.gmail.com>
In-Reply-To
<20220118222234.GB2632@szeder.dev>
On Tue, Jan 18, 2022 at 2:22 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
Show 5 quoted lines
>
> On Sat, Jan 15, 2022 at 05:03:24PM -0800, Elijah Newren wrote:
> > On Sat, Jan 15, 2022 at 1:57 AM SZEDER Gábor <szeder.dev@gmail.com> wrote:
> > >
> > > On Mon, Jan 10, 2022 at 06:59:51PM +0000, Lessley Dennington via GitGitGadget wrote:
...
Show 11 quoted lines
> > > > 4. A list of directories (but not files) is provided when users enter git
> > > > sparse-checkout add <TAB> or git sparse-checkout set <TAB>.
> > >
> > > Why limit completion only to directories?  Both of those subcommands
> > > accept files,
> >
> > Discussed in part at [1], but let me give a more detailed answer.
>
> It was a semi-rhetorical question.  Whether the reasons for expluding
> files are sound or not, it should be convincingly justified in the
> commit message.
Fair enough.
...
Show 13 quoted lines
> I used the following command to create a sparse-checkout from
> linux.git to build and play with 'perf':
>
>   git sparse-checkout set tools/perf/ tools/scripts/ tools/build/ tools/include/ tools/arch/x86/ tools/lib/ /.gitignore /.gitattributes
>
> Including the top-level '.gitignore' and '.gitattributes' was
> important, becase those ignore object files and specify userdiff.
> Now, I wouldn't mind having other files present in the top-level
> directory, because there are only a handful of files there.  However,
> being able to specify just those two files to 'git sparse-checkout'
> was great, because I didn't even have to think about what wildcard
> pattern to use, and what negative pattern to use to exclude anything
> that might have been included recursively.

Yeah, we should really make cone mode the default, because then this simplifies to:

    git sparse-checkout set tools/perf/ tools/scripts/ tools/build/
tools/include/ tools/arch/x86/ tools/lib/
In cone-mode you automatically get the directories specified PLUS:
  * all files in the toplevel directory (you always get these in cone mode)
  * all files directly within a parent (or ancestor) of one of the
directories you specified (thus all files directly under tools/ and
tools/arch/).
> I don't remember having any performance issues with it, on the
> contrary, I do remember that Git suddenly became much faster that in
> the full worktree.
Cool, thanks for testing it out and reporting.
If I can be permitted to share a bit of my experience...

In this specific case, you did keep it to 8 patterns and the linux kernel "only" has ~60k files. So O(N*M) isn't too bad here...but experience at $DAYJOB is that even with only 60k files, the pattern list tends to grow and it's not clear to users why there are so many ugly pauses when "Git used to be fast". Users tend to not make the connection either between the sparsity patterns and the slowness for whatever reason, and when I'm asked questions about the slowness, I may have to check a few other possible causes before finally realizing that it's just "too many sparsity patterns".

At least, that's the way it was at $DAYJOB before I switched our internal "sparsify" tool to just use cone mode. Then that type of problem went away.

> So I'm fairly convinced that specifying files to sparse-checkout is a
> feature that can make users' life easier.  It certainly made my life
> easier.

Or we can make it even easier and faster by using cone mode. That really, really should be the default (as we've been talking about for a couple cycles now), and I think your email reinforces my belief in it. I've got a series ready after some other things merge down to next.

Show 7 quoted lines
> On a related note: I just noticed the leading slashes in '/.gitignore'
> and '/.gitattributes'.  __git_complete_index_file() is not ready for
> that, I'm afraid; but I don't think the proposed patches could deal
> with that, either (but I didn't actually try).
>
> It would be great if completion could cope with patterns starting with
> '/' and/or '!'.

Ah, very good point. The leading '/' is kind of critical here, otherwise you get all .gitignore files in every directory at every depth, so completing on files (as currently done) wouldn't really help at all in your case.

Since you brought up a new good point here, can I also mention two others not previously covered in this thread (i.e. besides scaling)?

* If we complete file and directory names in non-cone mode, and those
file and directory names contain a leading '#' or '!' or contain
anywhere in their names a '*', '?', '\', '[', or ']', then the users
may be in for a very nasty surprise.  (Which perhaps suggests that in
non-cone mode, we shouldn't provide file OR directory completions for
set/add?)
* sparse-checkout currently ignores prefix[1], causing file and
directory completions to be wrong if the user is running from a
subdirectory.  This is just a bug in cone mode, though I'm not sure if
it's bug or feature in non-cone mode[2].  A decision about what it is
might have a bearing on what kinds of completions make sense in
non-cone mode (and might reinforce files/directories, or suggest
something else.).

[1] https://lore.kernel.org/git/29f0410e-6dfa-2e86-394d-b1fb735e7608@gmail.com/ [2] https://lore.kernel.org/git/CABPp-BH5woi6KY7OBpnsS-M2EmgLHii9zs8rSwrgcPFkOAvn_A@mail.gmail.com/

Previous: SZEDER GáborNext: Lessley Dennington via GitGitGadget
Message 41 of 95 in “sparse checkout: custom bash completion updates”
  1. 0/2 sparse checkout: custom bash completion updatesLessley Dennington via GitGitGadget, Dec 30, 2021
  2. 2/2 sparse-checkout: custom tab completionLessley Dennington via GitGitGadget, Dec 30, 2021
  3. Derrick StoleeDec 30, 2021
  4. Lessley DenningtonDec 30, 2021
  5. 1/2 sparse-checkout: custom tab completion testsLessley Dennington via GitGitGadget, Dec 30, 2021
  6. Derrick StoleeDec 30, 2021
  7. Lessley DenningtonDec 30, 2021
  8. Derrick StoleeDec 30, 2021
  9. Elijah NewrenDec 31, 2021
  10. Lessley DenningtonJan 4, 2022
  11. 0/2 sparse checkout: custom bash completion updatesLessley Dennington via GitGitGadget, Dec 30, 2021
  12. 1/2 sparse-checkout: custom tab completion testsLessley Dennington via GitGitGadget, Dec 30, 2021
  13. Elijah NewrenDec 31, 2021
  14. Junio C HamanoDec 31, 2021
  15. Elijah NewrenDec 31, 2021
  16. Lessley DenningtonJan 4, 2022
  17. Elijah NewrenJan 4, 2022
  18. Lessley DenningtonJan 5, 2022
  19. Lessley DenningtonJan 4, 2022
  20. 2/2 sparse-checkout: custom tab completionLessley Dennington via GitGitGadget, Dec 30, 2021
  21. Elijah NewrenDec 31, 2021
  22. Lessley DenningtonJan 4, 2022
  23. Elijah NewrenJan 4, 2022
  24. Lessley DenningtonJan 5, 2022
  25. Elijah NewrenJan 5, 2022
  26. 0/3 sparse checkout: custom bash completion updatesLessley Dennington via GitGitGadget, Jan 10, 2022
  27. 2/3 sparse-checkout: custom tab completionLessley Dennington via GitGitGadget, Jan 10, 2022
  28. SZEDER GáborJan 15, 2022
  29. Elijah NewrenJan 16, 2022
  30. Junio C HamanoJan 16, 2022
  31. Elijah NewrenJan 17, 2022
  32. Junio C HamanoJan 17, 2022
  33. Lessley DenningtonJan 18, 2022
  34. Lessley DenningtonJan 22, 2022
  35. Lessley DenningtonJan 22, 2022
  36. Lessley DenningtonJan 22, 2022
  37. SZEDER GáborJan 18, 2022
  38. Elijah NewrenJan 18, 2022
  39. Lessley DenningtonJan 18, 2022
  40. SZEDER GáborJan 18, 2022
  41. Elijah NewrenJan 18, 2022
  42. 1/3 sparse-checkout: custom tab completion testsLessley Dennington via GitGitGadget, Jan 10, 2022
  43. 3/3 sparse-checkout: limit tab completion to a single levelLessley Dennington via GitGitGadget, Jan 10, 2022
  44. Lessley DenningtonJan 12, 2022
  45. Junio C HamanoJan 13, 2022
  46. Elijah NewrenJan 13, 2022
  47. Lessley DenningtonJan 13, 2022
  48. Elijah NewrenJan 10, 2022
  49. Lessley DenningtonJan 11, 2022
  50. Taylor BlauJan 11, 2022
  51. Lessley DenningtonJan 12, 2022
  52. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Jan 27, 2022
  53. 1/3 completion: add sparse-checkout testsLessley Dennington via GitGitGadget, Jan 27, 2022
  54. Elijah NewrenJan 28, 2022
  55. Junio C HamanoJan 28, 2022
  56. Elijah NewrenJan 28, 2022
  57. 2/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Jan 27, 2022
  58. Elijah NewrenJan 28, 2022
  59. Lessley DenningtonJan 31, 2022
  60. Elijah NewrenJan 31, 2022
  61. 3/3 completion: ensure cone mode completion with multiple <TAB>sLessley Dennington via GitGitGadget, Jan 27, 2022
  62. Elijah NewrenJan 28, 2022
  63. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Feb 3, 2022
  64. 1/3 completion: address sparse-checkout issuesLessley Dennington via GitGitGadget, Feb 3, 2022
  65. Elijah NewrenFeb 3, 2022
  66. Lessley DenningtonFeb 4, 2022
  67. 2/3 completion: improve sparse-checkout cone mode directory completionLessley Dennington via GitGitGadget, Feb 3, 2022
  68. 3/3 completion: handle unusual characters for sparse-checkoutLessley Dennington via GitGitGadget, Feb 3, 2022
  69. Elijah NewrenFeb 3, 2022
  70. Lessley DenningtonFeb 4, 2022
  71. Ævar Arnfjörð BjarmasonFeb 4, 2022
  72. Junio C HamanoFeb 4, 2022
  73. Junio C HamanoFeb 3, 2022
  74. Lessley DenningtonFeb 3, 2022
  75. Junio C HamanoFeb 3, 2022
  76. Lessley DenningtonFeb 3, 2022
  77. Lessley DenningtonFeb 4, 2022
  78. Lessley DenningtonFeb 4, 2022
  79. Ævar Arnfjörð BjarmasonFeb 4, 2022
  80. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Feb 4, 2022
  81. 1/3 completion: address sparse-checkout issuesLessley Dennington via GitGitGadget, Feb 4, 2022
  82. 2/3 completion: improve sparse-checkout cone mode directory completionLessley Dennington via GitGitGadget, Feb 4, 2022
  83. 3/3 completion: handle unusual characters for sparse-checkoutLessley Dennington via GitGitGadget, Feb 4, 2022
  84. Elijah NewrenFeb 4, 2022
  85. Junio C HamanoFeb 4, 2022
  86. Elijah NewrenFeb 4, 2022
  87. Junio C HamanoFeb 4, 2022
  88. Elijah NewrenFeb 4, 2022
  89. Junio C HamanoFeb 4, 2022
  90. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Feb 7, 2022
  91. 2/3 completion: improve sparse-checkout cone mode directory completionLessley Dennington via GitGitGadget, Feb 7, 2022
  92. 3/3 completion: handle unusual characters for sparse-checkoutLessley Dennington via GitGitGadget, Feb 7, 2022
  93. Adam DinwoodieApr 6, 2022
  94. 1/3 completion: address sparse-checkout issuesLessley Dennington via GitGitGadget, Feb 7, 2022
  95. Elijah NewrenFeb 8, 2022

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.