diff options
| author | Derrick Stolee <stolee@gmail.com> | 2025-05-16 14:55:29 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-16 12:02:47 -0700 |
| commit | efab7dc1f49ef95f00560c30bca357dd445e7cb4 (patch) | |
| tree | 65c3832fd7c2095c7acbc0be1d8b4f9281fb5a49 /t/t1092-sparse-checkout-compatibility.sh | |
| parent | 02ed8555f68440c5f533ad3c098ac01fc8965861 (diff) | |
| download | git-efab7dc1f49ef95f00560c30bca357dd445e7cb4.tar.gz | |
reset: integrate sparse index with --patch
Similar to the previous change for 'git add -p', the reset builtin
checked for integration with the sparse index after possibly redirecting
its logic toward the interactive logic. This means that the builtin
would expand the sparse index to a full one upon read.
Move this check earlier within cmd_reset() to improve performance here.
Add tests to guarantee that we are not universally expanding the index.
Add behavior tests to check that we are doing the same operations as a
full index.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1092-sparse-checkout-compatibility.sh')
| -rwxr-xr-x | t/t1092-sparse-checkout-compatibility.sh | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index f47cf8fa7f..e11dfd872e 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -384,7 +384,7 @@ test_expect_success 'add, commit, checkout' ' test_all_match git checkout - ' -test_expect_success 'git add -p' ' +test_expect_success 'git add, checkout, and reset with -p' ' init_repos && write_script edit-contents <<-\EOF && @@ -398,7 +398,7 @@ test_expect_success 'git add -p' ' test_write_lines y n >in && run_on_all git add -p <in && test_all_match git status --porcelain=v2 && - test_all_match git reset && + test_all_match git reset -p <in && test_write_lines u 1 "" q >in && run_on_all git add -i <in && @@ -413,6 +413,12 @@ test_expect_success 'git add -p' ' test_sparse_match git reset && test_write_lines u 2 3 "" q >in && run_on_all git add -i <in && + test_sparse_match git status --porcelain=v2 && + + run_on_all git add --sparse folder1 && + run_on_all git commit -m "take changes" && + test_write_lines y n y >in && + test_sparse_match git checkout HEAD~1 --patch <in && test_sparse_match git status --porcelain=v2 ' @@ -2460,6 +2466,38 @@ test_expect_success 'sparse-index is not expanded: git add -p' ' ensure_expanded add -i <in ' +test_expect_success 'sparse-index is not expanded: checkout -p, reset -p' ' + init_repos && + + # Does not expand when edits are within sparse checkout. + echo "new content" >sparse-index/deep/a && + echo "new content" >sparse-index/deep/deeper1/a && + git -C sparse-index commit -a -m "inside-changes" && + + test_write_lines y y >in && + ensure_not_expanded checkout HEAD~1 --patch <in && + + echo "new content" >sparse-index/deep/a && + echo "new content" >sparse-index/deep/deeper1/a && + git -C sparse-index add . && + ensure_not_expanded reset --patch <in && + + # -p does expand when edits are outside sparse checkout. + mkdir -p sparse-index/folder1 && + echo "new content" >sparse-index/folder1/a && + git -C sparse-index add --sparse folder1 && + git -C sparse-index sparse-checkout reapply && + ensure_expanded reset --patch <in && + + # Fully reset the index. + mkdir -p sparse-index/folder1 && + echo "new content" >sparse-index/folder1/a && + git -C sparse-index add --sparse folder1 && + git -C sparse-index commit -m "folder1 change" && + git -C sparse-index sparse-checkout reapply && + ensure_expanded checkout HEAD~1 --patch <in +' + test_expect_success 'advice.sparseIndexExpanded' ' init_repos && |
