3 test_description
='read-tree -u --reset'
6 .
"$TEST_DIRECTORY"/lib-read-tree.sh
10 test_expect_success
'setup' '
13 echo content >df/file &&
16 git ls-files >expect &&
25 test_expect_success
'reset should work' '
26 read_tree_u_must_succeed -u --reset HEAD^ &&
27 git ls-files >actual &&
28 test_cmp expect actual
31 test_expect_success
'reset should remove remnants from a failed merge' '
32 read_tree_u_must_succeed --reset -u HEAD &&
33 git ls-files -s >expect &&
34 sha1=$(git rev-parse :new) &&
36 echo "100644 $sha1 1 old"
37 echo "100644 $sha1 3 old"
38 ) | git update-index --index-info &&
41 read_tree_u_must_succeed --reset -u HEAD &&
42 git ls-files -s >actual &&
46 test_expect_success
'two-way reset should remove remnants too' '
47 read_tree_u_must_succeed --reset -u HEAD &&
48 git ls-files -s >expect &&
49 sha1=$(git rev-parse :new) &&
51 echo "100644 $sha1 1 old"
52 echo "100644 $sha1 3 old"
53 ) | git update-index --index-info &&
56 read_tree_u_must_succeed --reset -u HEAD HEAD &&
57 git ls-files -s >actual &&
61 test_expect_success
'Porcelain reset should remove remnants too' '
62 read_tree_u_must_succeed --reset -u HEAD &&
63 git ls-files -s >expect &&
64 sha1=$(git rev-parse :new) &&
66 echo "100644 $sha1 1 old"
67 echo "100644 $sha1 3 old"
68 ) | git update-index --index-info &&
72 git ls-files -s >actual &&
76 test_expect_success
'Porcelain checkout -f should remove remnants too' '
77 read_tree_u_must_succeed --reset -u HEAD &&
78 git ls-files -s >expect &&
79 sha1=$(git rev-parse :new) &&
81 echo "100644 $sha1 1 old"
82 echo "100644 $sha1 3 old"
83 ) | git update-index --index-info &&
87 git ls-files -s >actual &&
91 test_expect_success
'Porcelain checkout -f HEAD should remove remnants too' '
92 read_tree_u_must_succeed --reset -u HEAD &&
93 git ls-files -s >expect &&
94 sha1=$(git rev-parse :new) &&
96 echo "100644 $sha1 1 old"
97 echo "100644 $sha1 3 old"
98 ) | git update-index --index-info &&
101 git checkout -f HEAD &&
102 git ls-files -s >actual &&