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

Re: [PATCH 3/7] sparse-checkout: pay attention to prefix for {set, add}

From
Derrick Stolee <derrickstolee@github.com>
Date
Feb 15, 2022, 14:53 UTC
Message-ID
<d0e7c17b-b293-623e-b0cb-ddc6980886ca@github.com>
In-Reply-To
<CABPp-BHXZ-XLxY0a3wCATfdq=6-EjW62RzbxKAoFPeXfJswD2w@mail.gmail.com>
On 2/14/2022 10:52 PM, Elijah Newren wrote:
Show 72 quoted lines
> On Mon, Feb 14, 2022 at 7:50 AM Derrick Stolee <derrickstolee@github.com> wrote:
>>
>> On 2/12/2022 7:39 PM, Elijah Newren via GitGitGadget wrote:
>>> From: Elijah Newren <newren@gmail.com>
>>>
>>> In cone mode, non-option arguments to set & add are clearly paths, and
>>> as such, we should pay attention to prefix.
>>>
>>> In non-cone mode, it is not clear that folks intend to provide paths
>>> since the inputs are gitignore-style patterns.  Paying attention to
>>> prefix would prevent folks from doing things like
>>>    git sparse-checkout add /.gitattributes
>>>    git sparse-checkout add '/toplevel-dir/*'
>>> In fact, the former will result in
>>>    fatal: '/.gitattributes' is outside repository...
>>> while the later will result in
>>>    fatal: Invalid path '/toplevel-dir': No such file or directory
>>> despite the fact that both are valid gitignore-style patterns that would
>>> select real files if added to the sparse-checkout file.  However, these
>>> commands can be run successfully from the toplevel directory, and many
>>> gitignore-style patterns ARE paths, and bash completion seems to be
>>> suggesting directories and files, so perhaps for consistency we pay
>>> attention to the prefix?  It's not clear what is okay here, but maybe
>>> that's yet another reason to deprecate non-cone mode as we will do later
>>> in this series.
>>>
>>> For now, incorporate prefix into the positional arguments for either
>>> cone or non-cone mode.  For additional discussion of this issue, see
>>> https://lore.kernel.org/git/29f0410e-6dfa-2e86-394d-b1fb735e7608@gmail.com/
>>
>> Perhaps this was covered in the issue, but for non-cone mode, it
>> matters if there is a leading slash or not in the pattern. Will
>> this change make it impossible for a user to input that distinction?
>>
>> Will there still be a difference between:
>>
>>         git sparse-checkout set --no-cone /.vs/
>>
>> and
>>
>>         git sparse-checkout set --no-cone .vs/
>>
>> ?
> 
> If you are in the toplevel directory, you can run either of these and
> they have the same meaning they traditionally had.
> 
> Before this patch, if you are in a subdirectory, the first of those
> would have specified a toplevel ".vs" directory, and the second would
> have specified a ".vs/" directory in the toplevel OR any subdirectory.
> Those choices might be what the user wanted, or both of those could be
> a nasty surprise for the user.
> 
> After this patch, if you are in a subdirectory, the first of those
> throw an error:
>     $ git sparse-checkout set --no-cone /.vs/
>     fatal: Invalid path '/.vs': No such file or directory
> (which might be an annoyance, but how would you possibly specify a
> leading slash on a path that needs to be prefixed anyway?)  The second
> will specify a SUBDIR/.vs/ from the toplevel directory (which again,
> might be what the user wanted, or might be a nasty surprise if they
> were trying to specify a pattern relative to the root).
> 
> Does this change make sense?  For some users, sure -- especially those
> with the idea that you specify paths for non-cone mode (though
> bash-completion may guide folks to presume that).  But for those who
> understand that non-cone mode is all about patterns and that we have a
> single toplevel file where everything must be recorded, it's possibly
> detrimental to them.  To me, I wonder if it seems fraught with nasty
> surprises for us to do anything other than throw an error when
> --no-cone is specified and we are in a subdirectory.  Perhaps I should
> do that instead of this change here.
I'd be in favor of this second approach of requiring the base directory.
Show 16 quoted lines
>>> Helped-by: Junio Hamano <gitster@pobox.com>
>>> Signed-off-by: Elijah Newren <newren@gmail.com>
>>
>> This could probably use a
>>
>>   Reported-by: Lessley Dennington <lessleydennington@gmail.com>
> 
> It'd be more of a "Report-Formalized-by:" if we were to include such a
> tag.  Check the history here:
> https://lore.kernel.org/git/52d638fc-e7e7-1b0a-482b-cff7c9500b92@gmail.com/
> 
> In short: I was the original reporter; I noted the issue while
> reviewing her completion series.  The bug was not related to her
> series, but her series did prompt me to check and discover the issue.
> She didn't want the issue to get lost, and decided to make a formal
> report.
That makes sense. I wasn't caught up with that conversation.
Show 6 quoted lines
>> These tests could use a non-cone-mode version to demonstrate the behavior
>> in that mode.
> 
> Fair enough, though I hesitated in part because I wasn't sure we even
> wanted to make that change, and I figured getting that answer might be
> useful before writing the tests.
Understandable.

Thanks, -Stolee

Previous: Elijah NewrenNext: Elijah Newren via GitGitGadget
Message 6 of 70 in “RFC: sparse checkout: make --cone mode the default, and check add/set argument validity”
  1. 0/7 RFC: sparse checkout: make --cone mode the default, and check add/set argument validityElijah Newren via GitGitGadget, Feb 13, 2022
  2. 1/7 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 13, 2022
  3. 3/7 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 13, 2022
  4. Derrick StoleeFeb 14, 2022
  5. Elijah NewrenFeb 15, 2022
  6. Derrick StoleeFeb 15, 2022
  7. 2/7 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 13, 2022
  8. Derrick StoleeFeb 14, 2022
  9. Elijah NewrenFeb 15, 2022
  10. 4/7 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 13, 2022
  11. Derrick StoleeFeb 14, 2022
  12. Elijah NewrenFeb 15, 2022
  13. Derrick StoleeFeb 15, 2022
  14. 6/7 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 13, 2022
  15. 5/7 sparse-checkout: reject non-cone-mode patterns starting with a '#'Elijah Newren via GitGitGadget, Feb 13, 2022
  16. Junio C HamanoFeb 14, 2022
  17. Elijah NewrenFeb 15, 2022
  18. Junio C HamanoFeb 16, 2022
  19. Elijah NewrenFeb 16, 2022
  20. Junio C HamanoFeb 16, 2022
  21. 7/7 sparse-checkout: make --cone the default and deprecate --no-coneElijah Newren via GitGitGadget, Feb 13, 2022
  22. Derrick StoleeFeb 14, 2022
  23. Elijah NewrenFeb 15, 2022
  24. Derrick StoleeFeb 14, 2022
  25. Elijah NewrenFeb 15, 2022
  26. Derrick StoleeFeb 15, 2022
  27. 0/6 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 15, 2022
  28. 1/6 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 15, 2022
  29. 2/6 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 15, 2022
  30. 3/6 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 15, 2022
  31. Ævar Arnfjörð BjarmasonFeb 17, 2022
  32. Elijah NewrenFeb 18, 2022
  33. 4/6 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 15, 2022
  34. Ævar Arnfjörð BjarmasonFeb 17, 2022
  35. 5/6 sparse-checkout: reject non-cone-mode patterns starting with a '#'Elijah Newren via GitGitGadget, Feb 15, 2022
  36. 6/6 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 15, 2022
  37. Derrick StoleeFeb 15, 2022
  38. 0/5 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 16, 2022
  39. 2/5 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 16, 2022
  40. 1/5 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 16, 2022
  41. 3/5 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 16, 2022
  42. 4/5 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 16, 2022
  43. 5/5 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 16, 2022
  44. Ævar Arnfjörð BjarmasonFeb 16, 2022
  45. Elijah NewrenFeb 16, 2022
  46. Victoria DyeFeb 16, 2022
  47. Junio C HamanoFeb 16, 2022
  48. Elijah NewrenFeb 17, 2022
  49. Junio C HamanoFeb 17, 2022
  50. Elijah NewrenFeb 17, 2022
  51. Elijah NewrenFeb 17, 2022
  52. Junio C HamanoFeb 16, 2022
  53. 0/5 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 17, 2022
  54. 1/5 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 17, 2022
  55. 2/5 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 17, 2022
  56. 3/5 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 17, 2022
  57. Junio C HamanoFeb 17, 2022
  58. 5/5 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 17, 2022
  59. 4/5 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 17, 2022
  60. Junio C HamanoFeb 17, 2022
  61. Elijah NewrenFeb 18, 2022
  62. Ævar Arnfjörð BjarmasonFeb 17, 2022
  63. 0/5 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 19, 2022
  64. 1/5 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 19, 2022
  65. 2/5 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 19, 2022
  66. 3/5 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 19, 2022
  67. 4/5 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 19, 2022
  68. 5/5 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 19, 2022
  69. Derrick StoleeFeb 20, 2022
  70. Junio C HamanoFeb 20, 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.