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 &&
45 test_cmp expect actual
48 test_expect_success
'two-way reset should remove remnants too' '
49 read_tree_u_must_succeed --reset -u HEAD &&
50 git ls-files -s >expect &&
51 sha1=$(git rev-parse :new) &&
53 echo "100644 $sha1 1 old" &&
54 echo "100644 $sha1 3 old"
55 ) | git update-index --index-info &&
58 read_tree_u_must_succeed --reset -u HEAD HEAD &&
59 git ls-files -s >actual &&
61 test_cmp expect actual
64 test_expect_success
'Porcelain reset should remove remnants too' '
65 read_tree_u_must_succeed --reset -u HEAD &&
66 git ls-files -s >expect &&
67 sha1=$(git rev-parse :new) &&
69 echo "100644 $sha1 1 old" &&
70 echo "100644 $sha1 3 old"
71 ) | git update-index --index-info &&
75 git ls-files -s >actual &&
77 test_cmp expect actual
80 test_expect_success
'Porcelain checkout -f should remove remnants too' '
81 read_tree_u_must_succeed --reset -u HEAD &&
82 git ls-files -s >expect &&
83 sha1=$(git rev-parse :new) &&
85 echo "100644 $sha1 1 old" &&
86 echo "100644 $sha1 3 old"
87 ) | git update-index --index-info &&
91 git ls-files -s >actual &&
93 test_cmp expect actual
96 test_expect_success
'Porcelain checkout -f HEAD should remove remnants too' '
97 read_tree_u_must_succeed --reset -u HEAD &&
98 git ls-files -s >expect &&
99 sha1=$(git rev-parse :new) &&
101 echo "100644 $sha1 1 old" &&
102 echo "100644 $sha1 3 old"
103 ) | git update-index --index-info &&
106 git checkout -f HEAD &&
107 git ls-files -s >actual &&
109 test_cmp expect actual