tests for sparse checkout, worktree protection
PATCH 7/12 tests for sparse checkout, worktree protection
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>
--- t/t2302-sparse-worktree.sh | 113 ++++++++++++++ t/t2302/add-u.expected | 1 + t/t2302/add.expected | 2 + t/t2302/commit.expected | 14 ++ t/t2302/diff-1.expected | 7 + t/t2302/diff-cc.expected | 9 + t/t2302/grep-work.expected | 2 + t/t2302/grep.expected | 2 + t/t2302/ls-files.expected | 2 + t/t2303-sparse-worktree-apply.sh | 62 ++++++++ t/t2303/apply-initial.patch | 14 ++ t/t2303/apply-inside.patch | 7 + t/t2303/apply-leading-dirs.patch | 3 + t/t2303/apply-outside.patch | 7 + t/t2303/apply-remove.patch | 7 + t/t2303/apply-rename.expected | 13 ++ t/t2303/apply-rename.patch | 4 + t/t2304-sparse-worktree-merge-recursive.sh | 233 ++++++++++++++++++++++++++++ 18 files changed, 502 insertions(+), 0 deletions(-) create mode 100755 t/t2302-sparse-worktree.sh create mode 100644 t/t2302/add-u.expected create mode 100644 t/t2302/add.expected create mode 100644 t/t2302/commit.expected create mode 100644 t/t2302/diff-1.expected create mode 100644 t/t2302/diff-cc.expected create mode 100644 t/t2302/grep-work.expected create mode 100644 t/t2302/grep.expected create mode 100644 t/t2302/ls-files.expected create mode 100755 t/t2303-sparse-worktree-apply.sh create mode 100644 t/t2303/apply-initial.patch create mode 100644 t/t2303/apply-inside.patch create mode 100644 t/t2303/apply-leading-dirs.patch create mode 100644 t/t2303/apply-outside.patch create mode 100644 t/t2303/apply-remove.patch create mode 100644 t/t2303/apply-rename.expected create mode 100644 t/t2303/apply-rename.patch create mode 100755 t/t2304-sparse-worktree-merge-recursive.sh
t/t2302-sparse-worktree.sh new file +113 -0
@@ -0,0 +1,113 @@ +#!/bin/sh + +test_description='sparse checkout -- worktree update + +This test makes sure all commands that will not write +worktree outside sparse prefix, once set. +' +. ./test-lib.sh + +test_expect_success 'setup' ' + test_tick && + mkdir work && + echo one > tracked && + cp tracked work/tracked && + cp tracked untracked && + cp tracked work/untracked && + cp tracked modified && + cp tracked work/modified && + git add tracked modified work/tracked work/modified && + echo two >> modified && + echo two >> work/modified && + git commit -m initial && + git config core.sparsecheckout work' + +test_expect_success 'rev-parse --show-sparse-prefix' ' + test "$(git rev-parse --show-sparse-prefix)" = "work" +' + +test_expect_success 'ls-files' ' + git ls-files | cmp ../t2302/ls-files.expected && + test "$(git ls-files -o)" = work/untracked && + test "$(git ls-files -o .)" = work/untracked && + test "$(git ls-files -m)" = work/modified + +' + +test_expect_success 'grep' 'git grep -l --no-external-grep one | cmp ../t2302/grep.expected' + +test_expect_success 'grep' ' + ( + cd work && + git grep -l --no-external-grep one | cmp ../../t2302/grep-work.expected + ) +' + +test_expect_success 'checkout-index' '! git checkout-index tracked' + +test_expect_success 'checkout-index -a' ' + mv work/modified work/modified.old && + git checkout-index -a && + mv work/modified.old work/modified +' + +test_expect_success 'checkout tracked' '! git checkout tracked' + +test_expect_success 'checkout work/tracked' 'rm work/tracked && git checkout work/tracked' + +test_expect_success 'clean' 'test "$(git clean -n)" = "Would remove work/untracked"' + +test_expect_success 'rm' '! git rm tracked && test -f tracked' + +test_expect_success 'add' ' + git add -n . | cmp ../t2302/add.expected && + git add -n -u | cmp ../t2302/add-u.expected && + ! git add -n modified +' + +test_expect_success 'commit' ' + test_tick && + echo one > work/one && + git add work/one + echo two >> work/one && + git commit -m one work/one && + git show HEAD > commit.result && + cmp commit.result ../t2302/commit.expected && + rm commit.result +' + +null_sha1=0000000000000000000000000000000000000000 +one_sha1=$(echo one|git hash-object --stdin) +onethree_sha1=$(echo -e "one\nthree"|git hash-object -w --stdin) +onefour_sha1=$(echo -e "one\nfour"|git hash-object -w --stdin) + +diff_expected=":100644 100644 $one_sha1 $null_sha1 M work/modified" +external_diff_pattern="^work/modified [^ ]* $one_sha1 100644 work/modified $null_sha1 100644\$" + +cat >index.info <<EOF +0 $null_sha1 work/modified +100644 $onethree_sha1 2 work/modified +100644 $onefour_sha1 3 work/modified +EOF + +test_expect_success 'diff-files' ' + test "$(git diff-files)" = "$diff_expected" && + test "$(git diff-files -- work/modified)" = "$diff_expected" + cp .git/index .git/index.save && + git update-index --index-info < index.info && + git diff-files --cc | diff - ../t2302/diff-cc.expected && + mv .git/index.save .git/index +' + +test_expect_success 'diff-index' ' + test "$(git diff-index HEAD)" = "$diff_expected" +' + +test_expect_success 'diff' ' + git diff HEAD | cmp ../t2302/diff-1.expected && + git diff | cmp ../t2302/diff-1.expected && + GIT_EXTERNAL_DIFF=echo git diff --ext-diff HEAD | grep -q "$external_diff_pattern" && + GIT_EXTERNAL_DIFF=echo git diff --ext-diff | grep -q "$external_diff_pattern" +' + +test_done
t/t2302/add-u.expected new file +1 -0
@@ -0,0 +1 @@ +add 'work/modified'
t/t2302/add.expected new file +2 -0
@@ -0,0 +1,2 @@ +add 'work/modified' +add 'work/untracked'
t/t2302/commit.expected new file +14 -0
@@ -0,0 +1,14 @@ +commit 33ce2cea204feebac3994cd4520cca60657e65de +Author: A U Thor <[email protected]> +Date: Thu Apr 7 15:14:13 2005 -0700 + + one + +diff --git a/work/one b/work/one +new file mode 100644 +index 0000000..814f4a4 +--- /dev/null ++++ b/work/one +@@ -0,0 +1,2 @@ ++one ++two
t/t2302/diff-1.expected new file +7 -0
@@ -0,0 +1,7 @@ +diff --git a/work/modified b/work/modified +index 5626abf..814f4a4 100644 +--- a/work/modified ++++ b/work/modified +@@ -1 +1,2 @@ + one ++two
t/t2302/diff-cc.expected new file +9 -0
@@ -0,0 +1,9 @@ +diff --cc work/modified +index 4c7442b,a9c7698..0000000 +--- a/work/modified ++++ b/work/modified +@@@ -1,2 -1,2 +1,2 @@@ + one +- three + -four +++two
t/t2302/grep-work.expected new file +2 -0
@@ -0,0 +1,2 @@ +modified +tracked
t/t2302/grep.expected new file +2 -0
@@ -0,0 +1,2 @@ +work/modified +work/tracked
t/t2302/ls-files.expected new file +2 -0
@@ -0,0 +1,2 @@ +work/modified +work/tracked
t/t2303-sparse-worktree-apply.sh new file +62 -0
62 lines not on this page · raw message
t/t2303/apply-initial.patch new file +14 -0
@@ -0,0 +1,14 @@ +diff --git a/one b/one +new file mode 100644 +index 0000000..5626abf +--- /dev/null ++++ b/one +@@ -0,0 +1 @@ ++one +diff --git a/work/one b/work/one +new file mode 100644 +index 0000000..da327ae +--- /dev/null ++++ b/work/one +@@ -0,0 +1 @@ ++work/one
t/t2303/apply-inside.patch new file +7 -0
@@ -0,0 +1,7 @@ +diff --git a/work/one b/work/one +index da327ae..6317017 100644 +--- a/work/one ++++ b/work/one +@@ -1 +1,2 @@ + work/one ++more
t/t2303/apply-leading-dirs.patch new file +3 -0
@@ -0,0 +1,3 @@ +diff --git a/work/for/me/now b/work/for/me/now +new file mode 100644 +index 0000000..e69de29
t/t2303/apply-outside.patch new file +7 -0
@@ -0,0 +1,7 @@ +diff --git a/one b/one +index 5626abf..9a72323 100644 +--- a/one ++++ b/one +@@ -1 +1,2 @@ + one ++more
t/t2303/apply-remove.patch new file +7 -0
@@ -0,0 +1,7 @@ +diff --git a/work/one b/work/one +deleted file mode 100644 +index da327ae..0000000 +--- a/work/one ++++ /dev/null +@@ -1 +0,0 @@ +-work/one
t/t2303/apply-rename.expected new file +13 -0
@@ -0,0 +1,13 @@ +diff --git a/work/one b/work/one +deleted file mode 100644 +index da327ae..0000000 +--- a/work/one ++++ /dev/null +@@ -1 +0,0 @@ +-work/one +diff --git a/work/two b/work/two +index e69de29..da327ae 100644 +--- a/work/two ++++ b/work/two +@@ -0,0 +1 @@ ++work/one
t/t2303/apply-rename.patch new file +4 -0
@@ -0,0 +1,4 @@ +diff --git a/work/one b/work/two +similarity index 100% +rename from work/one +rename to work/two
t/t2304-sparse-worktree-merge-recursive.sh new file +233 -0
233 lines not on this page · raw message
Signature · 1 line
1.5.5.GIT