On Mon, Sep 20, 2021 at 10:45 AM Derrick Stolee via GitGitGadget <gitgitgadget@xxxxxxxxx> 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. > > This means that commands that worked before this series can now fail. In > particular, if 'git merge' results in a conflict outside of the > sparse-checkout cone, then 'git add ' will now fail. > > In order to allow users to circumvent these protections, a new '--sparse' > option is added that ignores the sparse-checkout patterns and the > SKIP_WORKTREE bit. The message for advice.updateSparsePath is adjusted to > assist with discovery of this option. > > There is a subtle issue with git mv in that it does not check the index > until it discovers a directory and then uses the index to find the contained > entries. This means that in non-cone-mode patterns, a pattern such as > "sub/dir" will not match the path "sub" and this can cause an issue. > > In order to allow for checking arbitrary paths against the sparse-checkout > patterns, some changes to the underlying pattern matching code is required. > It turns out that there are some bugs in the methods as advertised, but > these bugs were never discovered because of the way methods like > unpack_trees() will check a directory for a pattern match before checking > its contained paths. Our new "check patterns on-demand" approach pokes holes > in that approach, specifically with patterns that match entire directories. > > > Updates in v3 > ============= > > * Fixed an incorrectly-squashed commit. Spread out some changes in a better > way. For example, I don't add --sparse to tests before introducing the > option. > > * Use a NULL struct strbuf pointer to indicate an uninitialized value > instead of relying on an internal member. > > * Use grep over test_i18ngrep. > > * Fixed line wrapping for error messages. > > * Use strbuf_setlen() over modifying the len member manually. I see that you and Junio had some interesting comments on the first 3 patches, so I look forward to seeing how those play out, but you addressed all my feedback from the previous rounds here.