Skip to content

Commit ba80825

Browse files
ffyuandagitster
authored andcommitted
t1092: add tests for git-rm
Add tests for `git-rm`, make sure it behaves as expected when <pathspec> is both inside or outside of sparse-checkout definition. Helped-by: Victoria Dye <[email protected]> Helped-by: Derrick Stolee <[email protected]> Signed-off-by: Shaoxuan Yuan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f61790 commit ba80825

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,4 +1878,61 @@ test_expect_success 'mv directory from out-of-cone to in-cone' '
18781878
grep -e "H deep/0/1" actual
18791879
'
18801880

1881+
test_expect_success 'rm pathspec inside sparse definition' '
1882+
init_repos &&
1883+
1884+
test_all_match git rm deep/a &&
1885+
test_all_match git status --porcelain=v2 &&
1886+
1887+
# test wildcard
1888+
run_on_all git reset --hard &&
1889+
test_all_match git rm deep/* &&
1890+
test_all_match git status --porcelain=v2 &&
1891+
1892+
# test recursive rm
1893+
run_on_all git reset --hard &&
1894+
test_all_match git rm -r deep &&
1895+
test_all_match git status --porcelain=v2
1896+
'
1897+
1898+
test_expect_failure 'rm pathspec outside sparse definition' '
1899+
init_repos &&
1900+
1901+
for file in folder1/a folder1/0/1
1902+
do
1903+
test_sparse_match test_must_fail git rm $file &&
1904+
test_sparse_match test_must_fail git rm --cached $file &&
1905+
test_sparse_match git rm --sparse $file &&
1906+
test_sparse_match git status --porcelain=v2
1907+
done &&
1908+
1909+
cat >folder1-full <<-EOF &&
1910+
rm ${SQ}folder1/0/0/0${SQ}
1911+
rm ${SQ}folder1/0/1${SQ}
1912+
rm ${SQ}folder1/a${SQ}
1913+
EOF
1914+
1915+
cat >folder1-sparse <<-EOF &&
1916+
rm ${SQ}folder1/${SQ}
1917+
EOF
1918+
1919+
# test wildcard
1920+
run_on_sparse git reset --hard &&
1921+
run_on_sparse git sparse-checkout reapply &&
1922+
test_sparse_match test_must_fail git rm folder1/* &&
1923+
run_on_sparse git rm --sparse folder1/* &&
1924+
test_cmp folder1-full sparse-checkout-out &&
1925+
test_cmp folder1-sparse sparse-index-out &&
1926+
test_sparse_match git status --porcelain=v2 &&
1927+
1928+
# test recursive rm
1929+
run_on_sparse git reset --hard &&
1930+
run_on_sparse git sparse-checkout reapply &&
1931+
test_sparse_match test_must_fail git rm --sparse folder1 &&
1932+
run_on_sparse git rm --sparse -r folder1 &&
1933+
test_cmp folder1-full sparse-checkout-out &&
1934+
test_cmp folder1-sparse sparse-index-out &&
1935+
test_sparse_match git status --porcelain=v2
1936+
'
1937+
18811938
test_done

0 commit comments

Comments
 (0)