fetch-pack: remove unused 'struct loose_object_iter'
[alt-git.git] / t / t1005-read-tree-reset.sh
blob12e30d77d096d5108396f90ecd4f9088c0f27413
1 #!/bin/sh
3 test_description='read-tree -u --reset'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-read-tree.sh
9 # two-tree test
11 test_expect_success 'setup' '
12 git init &&
13 mkdir df &&
14 echo content >df/file &&
15 git add df/file &&
16 git commit -m one &&
17 git ls-files >expect &&
18 rm -rf df &&
19 echo content >df &&
20 git add df &&
21 echo content >new &&
22 git add new &&
23 git commit -m two
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 &&
40 >old &&
41 git ls-files -s &&
42 read_tree_u_must_succeed --reset -u HEAD &&
43 git ls-files -s >actual &&
44 ! test -f old
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 &&
55 >old &&
56 git ls-files -s &&
57 read_tree_u_must_succeed --reset -u HEAD HEAD &&
58 git ls-files -s >actual &&
59 ! test -f old
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 &&
70 >old &&
71 git ls-files -s &&
72 git reset --hard &&
73 git ls-files -s >actual &&
74 ! test -f old
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 &&
85 >old &&
86 git ls-files -s &&
87 git checkout -f &&
88 git ls-files -s >actual &&
89 ! test -f old
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 &&
100 >old &&
101 git ls-files -s &&
102 git checkout -f HEAD &&
103 git ls-files -s >actual &&
104 ! test -f old
107 test_done