3 test_description
='read-tree -u --reset'
5 TEST_PASSES_SANITIZE_LEAK
=true
7 .
"$TEST_DIRECTORY"/lib-read-tree.sh
11 test_expect_success
'setup' '
14 echo content >df/file &&
17 git ls-files >expect &&
26 test_expect_success
'reset should work' '
27 read_tree_u_must_succeed -u --reset HEAD^ &&
28 git ls-files >actual &&
29 test_cmp expect actual
32 test_expect_success
'reset should remove remnants from a failed merge' '
33 read_tree_u_must_succeed --reset -u HEAD &&
34 git ls-files -s >expect &&
35 sha1=$(git rev-parse :new) &&
37 echo "100644 $sha1 1 old" &&
38 echo "100644 $sha1 3 old"
39 ) | git update-index --index-info &&
42 read_tree_u_must_succeed --reset -u HEAD &&
43 git ls-files -s >actual &&
47 test_expect_success
'two-way reset should remove remnants too' '
48 read_tree_u_must_succeed --reset -u HEAD &&
49 git ls-files -s >expect &&
50 sha1=$(git rev-parse :new) &&
52 echo "100644 $sha1 1 old" &&
53 echo "100644 $sha1 3 old"
54 ) | git update-index --index-info &&
57 read_tree_u_must_succeed --reset -u HEAD HEAD &&
58 git ls-files -s >actual &&
62 test_expect_success
'Porcelain reset should remove remnants too' '
63 read_tree_u_must_succeed --reset -u HEAD &&
64 git ls-files -s >expect &&
65 sha1=$(git rev-parse :new) &&
67 echo "100644 $sha1 1 old" &&
68 echo "100644 $sha1 3 old"
69 ) | git update-index --index-info &&
73 git ls-files -s >actual &&
77 test_expect_success
'Porcelain checkout -f should remove remnants too' '
78 read_tree_u_must_succeed --reset -u HEAD &&
79 git ls-files -s >expect &&
80 sha1=$(git rev-parse :new) &&
82 echo "100644 $sha1 1 old" &&
83 echo "100644 $sha1 3 old"
84 ) | git update-index --index-info &&
88 git ls-files -s >actual &&
92 test_expect_success
'Porcelain checkout -f HEAD should remove remnants too' '
93 read_tree_u_must_succeed --reset -u HEAD &&
94 git ls-files -s >expect &&
95 sha1=$(git rev-parse :new) &&
97 echo "100644 $sha1 1 old" &&
98 echo "100644 $sha1 3 old"
99 ) | git update-index --index-info &&
102 git checkout -f HEAD &&
103 git ls-files -s >actual &&