mirror of
https://github.com/git/git
synced 2024-10-31 01:43:41 +00:00
ea5070c91f
The option can be used to check if read-tree with the same set of other options like "-m" and "-u" would succeed without actually changing either the index or the working tree. The relevant tests in the t10?? range were extended to do a read-tree -n before the real read-tree to make sure neither the index nor any local files were changed with -n and the same exit code as without -n is returned. The helper functions added for that purpose reside in the new t/lib-read-tree.sh file. The only exception is #13 in t1004 ("unlinking an un-unlink-able symlink"). As this is an issue of wrong directory permissions it is not detected with -n. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
91 lines
2 KiB
Bash
Executable file
91 lines
2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='read-tree -u --reset'
|
|
|
|
. ./test-lib.sh
|
|
. "$TEST_DIRECTORY"/lib-read-tree.sh
|
|
|
|
# two-tree test
|
|
|
|
test_expect_success 'setup' '
|
|
git init &&
|
|
mkdir df &&
|
|
echo content >df/file &&
|
|
git add df/file &&
|
|
git commit -m one &&
|
|
git ls-files >expect &&
|
|
rm -rf df &&
|
|
echo content >df &&
|
|
git add df &&
|
|
echo content >new &&
|
|
git add new &&
|
|
git commit -m two
|
|
'
|
|
|
|
test_expect_success 'reset should work' '
|
|
read_tree_u_must_succeed -u --reset HEAD^ &&
|
|
git ls-files >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'reset should remove remnants from a failed merge' '
|
|
read_tree_u_must_succeed --reset -u HEAD &&
|
|
git ls-files -s >expect &&
|
|
sha1=$(git rev-parse :new) &&
|
|
(
|
|
echo "100644 $sha1 1 old"
|
|
echo "100644 $sha1 3 old"
|
|
) | git update-index --index-info &&
|
|
>old &&
|
|
git ls-files -s &&
|
|
read_tree_u_must_succeed --reset -u HEAD &&
|
|
git ls-files -s >actual &&
|
|
! test -f old
|
|
'
|
|
|
|
test_expect_success 'Porcelain reset should remove remnants too' '
|
|
read_tree_u_must_succeed --reset -u HEAD &&
|
|
git ls-files -s >expect &&
|
|
sha1=$(git rev-parse :new) &&
|
|
(
|
|
echo "100644 $sha1 1 old"
|
|
echo "100644 $sha1 3 old"
|
|
) | git update-index --index-info &&
|
|
>old &&
|
|
git ls-files -s &&
|
|
git reset --hard &&
|
|
git ls-files -s >actual &&
|
|
! test -f old
|
|
'
|
|
|
|
test_expect_success 'Porcelain checkout -f should remove remnants too' '
|
|
read_tree_u_must_succeed --reset -u HEAD &&
|
|
git ls-files -s >expect &&
|
|
sha1=$(git rev-parse :new) &&
|
|
(
|
|
echo "100644 $sha1 1 old"
|
|
echo "100644 $sha1 3 old"
|
|
) | git update-index --index-info &&
|
|
>old &&
|
|
git ls-files -s &&
|
|
git checkout -f &&
|
|
git ls-files -s >actual &&
|
|
! test -f old
|
|
'
|
|
|
|
test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
|
|
read_tree_u_must_succeed --reset -u HEAD &&
|
|
git ls-files -s >expect &&
|
|
sha1=$(git rev-parse :new) &&
|
|
(
|
|
echo "100644 $sha1 1 old"
|
|
echo "100644 $sha1 3 old"
|
|
) | git update-index --index-info &&
|
|
>old &&
|
|
git ls-files -s &&
|
|
git checkout -f HEAD &&
|
|
git ls-files -s >actual &&
|
|
! test -f old
|
|
'
|
|
|
|
test_done
|