diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2021-09-24 17:39:09 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-28 19:31:02 +0200 |
commit | 63b60b3add7527c202124982e0b14a6a512f0450 (patch) | |
tree | b80551785be6bf6118a9c9f1c37a4f5a2fb637f0 /builtin/add.c | |
parent | add: implement the --sparse option (diff) | |
download | git-63b60b3add7527c202124982e0b14a6a512f0450.tar.xz git-63b60b3add7527c202124982e0b14a6a512f0450.zip |
add: update --chmod to skip sparse paths
We added checks for path_in_sparse_checkout() to portions of 'git add'
that add warnings and prevent staging a modification, but we skipped the
--chmod mode. Update chmod_pathspec() to ignore cache entries whose path
is outside of the sparse-checkout cone (unless --sparse is provided).
Add a test in t3705.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/add.c')
-rw-r--r-- | builtin/add.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/add.c b/builtin/add.c index f8e3930608..f87b8134b6 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -47,7 +47,9 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only) struct cache_entry *ce = active_cache[i]; int err; - if (!include_sparse && ce_skip_worktree(ce)) + if (!include_sparse && + (ce_skip_worktree(ce) || + !path_in_sparse_checkout(ce->name, &the_index))) continue; if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL)) |