To make sure git diff-files behaves as expected when inside or outside of sparse-checkout definition. Add test for git diff-files: Path is within sparse-checkout cone Path is outside sparse-checkout cone Signed-off-by: Shuqi Liang <cheskaqiqi@xxxxxxxxx> --- t/t1092-sparse-checkout-compatibility.sh | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 801919009e..f4815c619a 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -2054,5 +2054,37 @@ test_expect_success 'grep sparse directory within submodules' ' git grep --cached --recurse-submodules a -- "*/folder1/*" >actual && test_cmp actual expect ' +test_expect_success 'diff-files with pathspec inside sparse definition' ' + init_repos && + + write_script edit-contents <<-\EOF && + echo text >>$1 + EOF + + run_on_all ../edit-contents deep/a && + + test_all_match git diff-files && + test_all_match git diff-files deep/a && + test_all_match git diff-files --find-object=HEAD:a +' + +test_expect_success 'diff-files with pathspec outside sparse definition' ' + init_repos && + + write_script edit-contents <<-\EOF && + echo text >>$1 + EOF + + run_on_sparse mkdir newdirectory && + run_on_sparse ../edit-contents newdirectory/testfile && + test_sparse_match git sparse-checkout set newdirectory && + test_sparse_match git add newdirectory/testfile && + run_on_sparse ../edit-contents newdirectory/testfile && + test_sparse_match git sparse-checkout set && + + test_sparse_match git diff-files && + test_sparse_match git diff-files newdirectory/testfile && + test_sparse_match test_must_fail git diff-files --find-object=HEAD:testfile +' test_done -- 2.39.0