This is based on the discussion at [1]. It makes `rm` honor sparse checkouts and adds a warning to both `rm` and `add`, for the case where a pathspec _only_ matches skip-worktree entries. The first two patches are somewhat unrelated fixes, but they are used by the later patches. [1]: https://lore.kernel.org/git/CABPp-BHwNoVnooqDFPAsZxBT9aR5Dwk5D9sDRCvYSb8akxAJgA@xxxxxxxxxxxxxx/ Matheus Tavares (7): add --chmod: don't update index when --dry-run is used add: include magic part of pathspec on --refresh error t3705: add tests for `git add` in sparse checkouts add: make --chmod and --renormalize honor sparse checkouts pathspec: allow to ignore SKIP_WORKTREE entries on index matching add: warn when pathspec only matches SKIP_WORKTREE entries rm: honor sparse checkout patterns Documentation/config/advice.txt | 4 + Documentation/git-rm.txt | 4 +- advice.c | 19 +++++ advice.h | 4 + builtin/add.c | 72 ++++++++++++++---- builtin/check-ignore.c | 2 +- builtin/rm.c | 35 ++++++--- pathspec.c | 25 ++++++- pathspec.h | 13 +++- read-cache.c | 3 +- t/t3600-rm.sh | 54 ++++++++++++++ t/t3700-add.sh | 26 +++++++ t/t3705-add-sparse-checkout.sh | 122 +++++++++++++++++++++++++++++++ t/t7011-skip-worktree-reading.sh | 5 -- t/t7012-skip-worktree-writing.sh | 19 ----- 15 files changed, 349 insertions(+), 58 deletions(-) create mode 100755 t/t3705-add-sparse-checkout.sh -- 2.29.2