[GSoC] [PATCH] t7012: turn TODOs into tests for skip-worktree operations
From: K Jayatheerth <hidden>
Date: 2026-01-01 15:59:28
Subsystem:
the rest · Maintainer:
Linus Torvalds
The t7012-skip-worktree-writing.sh test script contained several placeholders marked with '#TODO test_expect_failure ... false', indicating intended test coverage for skip-worktree interactions that had not yet been implemented. Implement these tests to verify the behavior of git-apply, git-mv, and git-checkout when dealing with skip-worktree entries. The results of the new tests are: 1. git-apply (adding a file): Works correctly. 2. git-mv (to skip-worktree): Works correctly. 3. git-checkout: Works correctly (updates index despite missing file). 4. git-apply (update/remove): Fails as expected. 5. git-mv (from skip-worktree): Fails as expected. Tests that pass have been marked as 'test_expect_success', while those that confirm known bugs are marked as 'test_expect_failure'. Signed-off-by: K Jayatheerth <redacted> --- t/t7012-skip-worktree-writing.sh | 101 +++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 6 deletions(-)
diff --git a/t/t7012-skip-worktree-writing.sh b/t/t7012-skip-worktree-writing.sh
index cd5c20fe51..7e6c529b6f 100755
--- a/t/t7012-skip-worktree-writing.sh
+++ b/t/t7012-skip-worktree-writing.sh@@ -188,11 +188,100 @@ test_expect_success 'stash restore in sparse checkout' ' ) ' -#TODO test_expect_failure 'git-apply adds file' false -#TODO test_expect_failure 'git-apply updates file' false -#TODO test_expect_failure 'git-apply removes file' false -#TODO test_expect_failure 'git-mv to skip-worktree' false -#TODO test_expect_failure 'git-mv from skip-worktree' false -#TODO test_expect_failure 'git-checkout' false +test_expect_success 'setup patches' ' + test_commit setup_apply && + + # 1. Modify patch + echo modified >setup_apply.t && + git diff setup_apply.t >modify.patch && + git checkout setup_apply.t && + + # 2. Remove patch + rm setup_apply.t && + git diff -- setup_apply.t >remove.patch && + git checkout setup_apply.t && + + # 3. Add patch + echo new >newfile.t && + git add newfile.t && + git diff --cached newfile.t >add.patch && + git rm --cached newfile.t && + rm newfile.t +' + +test_expect_success 'git-apply adds file' ' + test_when_finished "git update-index --no-skip-worktree newfile.t" && + + >newfile.t && + git add newfile.t && + git update-index --skip-worktree newfile.t && + rm newfile.t && + + git apply add.patch +' + +test_expect_failure 'git-apply updates file' ' + test_when_finished "git update-index --no-skip-worktree setup_apply.t" && + + git update-index --skip-worktree setup_apply.t && + rm setup_apply.t && + + git apply modify.patch +' + +test_expect_failure 'git-apply removes file' ' + test_when_finished "git update-index --no-skip-worktree setup_apply.t" && + + git update-index --skip-worktree setup_apply.t && + rm setup_apply.t && + + git apply remove.patch +' + +test_expect_success 'git-mv to skip-worktree' ' + test_when_finished "git update-index --no-skip-worktree dest.t" && + + test_commit mv_source && + >dest.t && + git add dest.t && + git update-index --skip-worktree dest.t && + rm dest.t && + + git mv mv_source.t dest.t +' + +test_expect_failure 'git-mv from skip-worktree' ' + test_when_finished "git update-index --no-skip-worktree mv_skip.t" && + + test_commit mv_skip && + git update-index --skip-worktree mv_skip.t && + rm mv_skip.t && + + git mv mv_skip.t moved_skip.t && + git ls-files --error-unmatch moved_skip.t +' + +test_expect_success 'git-checkout' ' + test_create_repo checkout_test && + ( + cd checkout_test && + git checkout -B master && + + test_commit checkout_base && + git checkout -b side && + test_commit modified_checkout && + git checkout master && + + git update-index --skip-worktree checkout_base.t && + rm checkout_base.t && + + git checkout side && + + test_path_is_missing checkout_base.t && + git rev-parse :checkout_base.t >actual && + git rev-parse side:checkout_base.t >expect && + test_cmp expect actual + ) +' test_done
--
2.52.0