From 61d450f049eeb61e6cb3c07750e806db29ff0ea3 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 24 Sep 2021 15:39:10 +0000 Subject: add: update --renormalize to skip sparse paths We added checks for path_in_sparse_checkout() to portions of 'git add' that add warnings and prevent stagins a modification, but we skipped the --renormalize mode. Update renormalize_tracked_files() 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 Signed-off-by: Junio C Hamano --- builtin/add.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/add.c b/builtin/add.c index f87b8134b6..f8f0dfa404 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -154,7 +154,9 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags) for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; - if (ce_skip_worktree(ce)) + if (!include_sparse && + (ce_skip_worktree(ce) || + !path_in_sparse_checkout(ce->name, &the_index))) continue; if (ce_stage(ce)) continue; /* do not touch unmerged paths */ -- cgit v1.2.3