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

Re: [PATCH v2 00/14] Sparse-checkout: modify 'git add', 'git rm', and 'git add' behavior

From
SCSean Christopherson <seanjc@google.com>
Date
Oct 19, 2021, 16:50 UTC
Message-ID
<YW73QD7a+NzHd8dq@google.com>
In-Reply-To
<00188c99-386f-8d4f-08f6-11a49d31184c@gmail.com>
On Tue, Oct 19, 2021, Derrick Stolee wrote:
Show 18 quoted lines
> On 10/18/2021 5:28 PM, Sean Christopherson wrote:
> > On Sun, Sep 12, 2021, Derrick Stolee via GitGitGadget wrote:
> >> This series is based on ds/mergies-with-sparse-index.
> >>
> >> As requested, this series looks to update the behavior of git add, git rm,
> >> and git mv when they attempt to modify paths outside of the sparse-checkout
> >> cone. In particular, this care is expanded to not just cache entries with
> >> the SKIP_WORKTREE bit, but also paths that do not match the sparse-checkout
> >> definition.
> > 
> > I suspect something in this series broke 'git add' and friends with "odd" sparse
> > definitions (I haven't actually bisected).  git 2.33.0 rejects attempts to add
> > files with the below sparse-checkout and modified files.  There appears to be a
> > discrepancy in the query vs. checkout logic as the rejected files are checked out
> > in the working tree, e.g. git sees that the local file was deleted, yet will not
> > stage the deletion.
> 
> Are you using v2.33.0? This change is not in that version.

Hrm, it's an internal build that says v2.33.0 is the bsae, but the --sparse option is available so who knows what's actually underneath the hood. I can try vanilla upstream builds if that would help narrow down the issue.

Show 35 quoted lines
> However, mt/add-rm-in-sparse-checkout [1] was introduced in v2.33.0 and
> introduced these advice suggestions.
> 
> [1] https://github.com/git/git/compare/a5828ae6b52137b913b978e16cd2334482eb4c1f...d5f4b8260f623d6fdef36d5eaa8a0c2350390472
>
> The series you are commenting on goes even farther in restricting adds to
> be within the sparse-checkout definitions, even for unstaged files or files
> that removed the skip-worktree bit due to a merge conflict. It also creates
> an override '--sparse' option that allows you to ignore these protections.
> 
> > There's also arguably a flaw in the "advise" trigger.  AFAICT, the help message
> > is displayed if and only if the entire path is excluded from the working tree.
> > In my perfect world, git would complain and advise if there are unstaged changes
> > for tracked files covered by the specified path.
> >> Note, my sparse-checkout is very much the result of trial and error to get the
> > exact files I care about.  It's entirely possible I'm doing something weird, but
> > at the same time git itself is obviously confused.
> > 
> > Thanks!
> > 
> > $ cat .git/info/sparse-checkout
> > !arch/*
> > !tools/arch/*
> > !virt/kvm/arm/*
> > /*
> > arch/.gitignore
> > arch/Kconfig
> > arch/x86
> > tools/arch/x86
> > tools/include/uapi/linux/kvm.h
> > !Documentation
> > !drivers
> 
> Have you tried using 'arch/x86/' and 'tools/arch/x86/' to specify
> that these are directories? Just a thought.

Nice! That workaround resolves the issue. I vaguely recall intentionally omitting the trailing slash, but adding it back doesn't seem to have any unwanted side effects on the current git versions I'm using.

Show 10 quoted lines
> > $ git read-tree -mu HEAD
> > 
> > $ rm arch/x86/kvm/x86.c
> > 
> > $ git commit -a
> ...
> > 	deleted:    arch/x86/kvm/x86.c
> 
> This is certainly odd. Worth more investigation that I don't have
> time for at this moment.

I've no objection to punting on this now that I have a workaround. The man pages are quite clear that sparse checkouts are still experimental and it's no trouble for me to whine again if something breaks in the future :-)

Thanks again!
Previous: Derrick StoleeNext: Junio C Hamano
Message 111 of 116 in “[RFC] Sparse-checkout: modify 'git add', 'git rm', and 'git add' behavior”
  1. 00/13 [RFC] Sparse-checkout: modify 'git add', 'git rm', and 'git add' behaviorDerrick Stolee via GitGitGadget, Aug 24, 2021
  2. 01/13 t1092: behavior for adding sparse filesDerrick Stolee via GitGitGadget, Aug 24, 2021
  3. 02/13 dir: extract directory-matching logicDerrick Stolee via GitGitGadget, Aug 24, 2021
  4. 03/13 dir: select directories correctlyDerrick Stolee via GitGitGadget, Aug 24, 2021
  5. René ScharfeSep 24, 2021
  6. 04/13 dir: fix pattern matching on dirsDerrick Stolee via GitGitGadget, Aug 24, 2021
  7. 05/13 add: fail when adding an untracked sparse fileDerrick Stolee via GitGitGadget, Aug 24, 2021
  8. Matheus Tavares BernardinoAug 27, 2021
  9. Matheus Tavares BernardinoAug 27, 2021
  10. Derrick StoleeSep 8, 2021
  11. 06/13 add: skip paths that are outside sparse-checkout coneDerrick Stolee via GitGitGadget, Aug 24, 2021
  12. Matheus TavaresAug 27, 2021
  13. Derrick StoleeSep 8, 2021
  14. Derrick StoleeSep 8, 2021
  15. Derrick StoleeSep 8, 2021
  16. 07/13 add: implement the --sparse optionDerrick Stolee via GitGitGadget, Aug 24, 2021
  17. Matheus Tavares BernardinoAug 27, 2021
  18. 08/13 add: prevent adding sparse conflict filesDerrick Stolee via GitGitGadget, Aug 24, 2021
  19. Matheus Tavares BernardinoAug 27, 2021
  20. 09/13 rm: add --sparse optionDerrick Stolee via GitGitGadget, Aug 24, 2021
  21. Matheus Tavares BernardinoAug 27, 2021
  22. Derrick StoleeSep 8, 2021
  23. 10/13 rm: skip sparse paths with missing SKIP_WORKTREEDerrick Stolee via GitGitGadget, Aug 24, 2021
  24. Matheus Tavares BernardinoAug 27, 2021
  25. 11/13 mv: refuse to move sparse pathsDerrick Stolee via GitGitGadget, Aug 24, 2021
  26. Matheus Tavares BernardinoAug 27, 2021
  27. Matheus Tavares BernardinoAug 27, 2021
  28. Derrick StoleeSep 8, 2021
  29. 12/13 mv: add '--sparse' option to ignore sparse-checkoutDerrick Stolee via GitGitGadget, Aug 24, 2021
  30. Matheus Tavares BernardinoAug 28, 2021
  31. 13/13 advice: update message to suggest '--sparse'Derrick Stolee via GitGitGadget, Aug 24, 2021
  32. 00/14 Sparse-checkout: modify 'git add', 'git rm', and 'git add' behaviorDerrick Stolee via GitGitGadget, Sep 12, 2021
  33. 01/14 t3705: test that 'sparse_entry' is unstagedDerrick Stolee via GitGitGadget, Sep 12, 2021
  34. Elijah NewrenSep 15, 2021
  35. Derrick StoleeSep 15, 2021
  36. Matheus TavaresSep 15, 2021
  37. Derrick StoleeSep 15, 2021
  38. 02/14 t1092: behavior for adding sparse filesDerrick Stolee via GitGitGadget, Sep 12, 2021
  39. Ævar Arnfjörð BjarmasonSep 12, 2021
  40. Derrick StoleeSep 13, 2021
  41. 03/14 dir: extract directory-matching logicDerrick Stolee via GitGitGadget, Sep 12, 2021
  42. 04/14 dir: select directories correctlyDerrick Stolee via GitGitGadget, Sep 12, 2021
  43. Ævar Arnfjörð BjarmasonSep 12, 2021
  44. Derrick StoleeSep 15, 2021
  45. Elijah NewrenSep 15, 2021
  46. Derrick StoleeSep 15, 2021
  47. 05/14 dir: fix pattern matching on dirsDerrick Stolee via GitGitGadget, Sep 12, 2021
  48. 06/14 add: fail when adding an untracked sparse fileDerrick Stolee via GitGitGadget, Sep 12, 2021
  49. 07/14 add: skip tracked paths outside sparse-checkout coneDerrick Stolee via GitGitGadget, Sep 12, 2021
  50. 09/14 add: update --chmod to skip sparse pathsDerrick Stolee via GitGitGadget, Sep 12, 2021
  51. 08/14 add: implement the --sparse optionDerrick Stolee via GitGitGadget, Sep 12, 2021
  52. Elijah NewrenSep 15, 2021
  53. Derrick StoleeSep 20, 2021
  54. 10/14 add: update --renormalize to skip sparse pathsDerrick Stolee via GitGitGadget, Sep 12, 2021
  55. 11/14 rm: add --sparse optionDerrick Stolee via GitGitGadget, Sep 12, 2021
  56. 14/14 advice: update message to suggest '--sparse'Derrick Stolee via GitGitGadget, Sep 12, 2021
  57. Ævar Arnfjörð BjarmasonSep 12, 2021
  58. Derrick StoleeSep 15, 2021
  59. 12/14 rm: skip sparse paths with missing SKIP_WORKTREEDerrick Stolee via GitGitGadget, Sep 12, 2021
  60. 13/14 mv: refuse to move sparse pathsDerrick Stolee via GitGitGadget, Sep 12, 2021
  61. Elijah NewrenSep 15, 2021
  62. 00/14 Sparse-checkout: modify 'git add', 'git rm', and 'git add' behaviorDerrick Stolee via GitGitGadget, Sep 20, 2021
  63. 02/14 t1092: behavior for adding sparse filesDerrick Stolee via GitGitGadget, Sep 20, 2021
  64. Junio C HamanoSep 22, 2021
  65. Derrick StoleeSep 23, 2021
  66. 01/14 t3705: test that 'sparse_entry' is unstagedDerrick Stolee via GitGitGadget, Sep 20, 2021
  67. Junio C HamanoSep 22, 2021
  68. 03/14 dir: extract directory-matching logicDerrick Stolee via GitGitGadget, Sep 20, 2021
  69. Junio C HamanoSep 22, 2021
  70. Derrick StoleeSep 23, 2021
  71. Derrick StoleeSep 23, 2021
  72. Junio C HamanoSep 23, 2021
  73. Derrick StoleeSep 24, 2021
  74. 04/14 dir: select directories correctlyDerrick Stolee via GitGitGadget, Sep 20, 2021
  75. 05/14 dir: fix pattern matching on dirsDerrick Stolee via GitGitGadget, Sep 20, 2021
  76. 06/14 add: fail when adding an untracked sparse fileDerrick Stolee via GitGitGadget, Sep 20, 2021
  77. 07/14 add: skip tracked paths outside sparse-checkout coneDerrick Stolee via GitGitGadget, Sep 20, 2021
  78. 08/14 add: implement the --sparse optionDerrick Stolee via GitGitGadget, Sep 20, 2021
  79. 09/14 add: update --chmod to skip sparse pathsDerrick Stolee via GitGitGadget, Sep 20, 2021
  80. 10/14 add: update --renormalize to skip sparse pathsDerrick Stolee via GitGitGadget, Sep 20, 2021
  81. 11/14 rm: add --sparse optionDerrick Stolee via GitGitGadget, Sep 20, 2021
  82. 12/14 rm: skip sparse paths with missing SKIP_WORKTREEDerrick Stolee via GitGitGadget, Sep 20, 2021
  83. 13/14 mv: refuse to move sparse pathsDerrick Stolee via GitGitGadget, Sep 20, 2021
  84. 14/14 advice: update message to suggest '--sparse'Derrick Stolee via GitGitGadget, Sep 20, 2021
  85. Elijah NewrenSep 24, 2021
  86. 00/13 Sparse-checkout: modify 'git add', 'git rm', and 'git mv' behaviorDerrick Stolee via GitGitGadget, Sep 24, 2021
  87. 01/13 t3705: test that 'sparse_entry' is unstagedDerrick Stolee via GitGitGadget, Sep 24, 2021
  88. 02/13 t1092: behavior for adding sparse filesDerrick Stolee via GitGitGadget, Sep 24, 2021
  89. 03/13 dir: select directories correctlyDerrick Stolee via GitGitGadget, Sep 24, 2021
  90. 04/13 dir: fix pattern matching on dirsDerrick Stolee via GitGitGadget, Sep 24, 2021
  91. Glen ChooNov 2, 2021
  92. Junio C HamanoNov 2, 2021
  93. Derrick StoleeNov 2, 2021
  94. Derrick StoleeNov 2, 2021
  95. Ævar Arnfjörð BjarmasonNov 2, 2021
  96. Derrick StoleeNov 3, 2021
  97. Junio C HamanoNov 3, 2021
  98. 05/13 add: fail when adding an untracked sparse fileDerrick Stolee via GitGitGadget, Sep 24, 2021
  99. 06/13 add: skip tracked paths outside sparse-checkout coneDerrick Stolee via GitGitGadget, Sep 24, 2021
  100. 07/13 add: implement the --sparse optionDerrick Stolee via GitGitGadget, Sep 24, 2021
  101. 08/13 add: update --chmod to skip sparse pathsDerrick Stolee via GitGitGadget, Sep 24, 2021
  102. 09/13 add: update --renormalize to skip sparse pathsDerrick Stolee via GitGitGadget, Sep 24, 2021
  103. 10/13 rm: add --sparse optionDerrick Stolee via GitGitGadget, Sep 24, 2021
  104. 11/13 rm: skip sparse paths with missing SKIP_WORKTREEDerrick Stolee via GitGitGadget, Sep 24, 2021
  105. 12/13 mv: refuse to move sparse pathsDerrick Stolee via GitGitGadget, Sep 24, 2021
  106. 13/13 advice: update message to suggest '--sparse'Derrick Stolee via GitGitGadget, Sep 24, 2021
  107. Elijah NewrenSep 27, 2021
  108. Junio C HamanoSep 27, 2021
  109. Sean ChristophersonOct 18, 2021
  110. Derrick StoleeOct 19, 2021
  111. Sean ChristophersonOct 19, 2021
  112. Junio C HamanoOct 20, 2021
  113. Sean ChristophersonOct 20, 2021
  114. add|rm|mv: fix bug that prevent the update of non-sparseMatheus Tavares, Oct 22, 2021
  115. Matheus TavaresOct 22, 2021
  116. Derrick StoleeOct 25, 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.