ci: fix setup of custom path for GitLab CI
[alt-git.git] / t / t1005-read-tree-reset.sh
blob26be4a2b5a007afa7ef1a9bd4438d16173c6aad5
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 &&
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 &&
56 >old &&
57 git ls-files -s &&
58 read_tree_u_must_succeed --reset -u HEAD HEAD &&
59 git ls-files -s >actual &&
60 ! test -f old &&
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 &&
72 >old &&
73 git ls-files -s &&
74 git reset --hard &&
75 git ls-files -s >actual &&
76 ! test -f old &&
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 &&
88 >old &&
89 git ls-files -s &&
90 git checkout -f &&
91 git ls-files -s >actual &&
92 ! test -f old &&
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 &&
104 >old &&
105 git ls-files -s &&
106 git checkout -f HEAD &&
107 git ls-files -s >actual &&
108 ! test -f old &&
109 test_cmp expect actual
112 test_done