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 --- t/t3705-add-sparse-checkout.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 't/t3705-add-sparse-checkout.sh') diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh index 0ae674a17a..339ec0ed2d 100755 --- a/t/t3705-add-sparse-checkout.sh +++ b/t/t3705-add-sparse-checkout.sh @@ -172,6 +172,9 @@ test_expect_success 'git add fails outside of sparse-checkout definition' ' test_must_fail git add --chmod=+x sparse_entry && test_sparse_entry_unstaged && + test_must_fail git add --renormalize sparse_entry && + test_sparse_entry_unstaged && + # Avoid munging CRLFs to avoid an error message git -c core.autocrlf=input add --sparse sparse_entry 2>stderr && test_must_be_empty stderr && @@ -181,7 +184,14 @@ test_expect_success 'git add fails outside of sparse-checkout definition' ' git add --sparse --chmod=+x sparse_entry 2>stderr && test_must_be_empty stderr && test-tool read-cache --table >actual && - grep "^100755 blob.*sparse_entry\$" actual + grep "^100755 blob.*sparse_entry\$" actual && + + git reset && + + # This will print a message over stderr on Windows. + git add --sparse --renormalize sparse_entry && + git status --porcelain >actual && + grep "^M sparse_entry\$" actual ' test_expect_success 'add obeys advice.updateSparsePath' ' -- cgit v1.2.3