t1005: add test for "read-tree --reset -u A B"
[git/git.git] / t / t1005-read-tree-reset.sh
CommitLineData
50753d00
JK
1#!/bin/sh
2
3test_description='read-tree -u --reset'
4
5. ./test-lib.sh
ea5070c9 6. "$TEST_DIRECTORY"/lib-read-tree.sh
50753d00
JK
7
8# two-tree test
9
10test_expect_success 'setup' '
76da5b1d
JH
11 git init &&
12 mkdir df &&
13 echo content >df/file &&
14 git add df/file &&
15 git commit -m one &&
16 git ls-files >expect &&
17 rm -rf df &&
18 echo content >df &&
19 git add df &&
20 echo content >new &&
21 git add new &&
22 git commit -m two
50753d00
JK
23'
24
34110cd4 25test_expect_success 'reset should work' '
76da5b1d
JH
26 read_tree_u_must_succeed -u --reset HEAD^ &&
27 git ls-files >actual &&
28 test_cmp expect actual
50753d00
JK
29'
30
d1a43f2a 31test_expect_success 'reset should remove remnants from a failed merge' '
76da5b1d
JH
32 read_tree_u_must_succeed --reset -u HEAD &&
33 git ls-files -s >expect &&
34 sha1=$(git rev-parse :new) &&
35 (
36 echo "100644 $sha1 1 old"
37 echo "100644 $sha1 3 old"
38 ) | git update-index --index-info &&
39 >old &&
40 git ls-files -s &&
41 read_tree_u_must_succeed --reset -u HEAD &&
42 git ls-files -s >actual &&
43 ! test -f old
d1a43f2a
JH
44'
45
77b43cac
JH
46test_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) &&
50 (
51 echo "100644 $sha1 1 old"
52 echo "100644 $sha1 3 old"
53 ) | git update-index --index-info &&
54 >old &&
55 git ls-files -s &&
56 read_tree_u_must_succeed --reset -u HEAD HEAD &&
57 git ls-files -s >actual &&
58 ! test -f old
59'
60
d1a43f2a 61test_expect_success 'Porcelain reset should remove remnants too' '
76da5b1d
JH
62 read_tree_u_must_succeed --reset -u HEAD &&
63 git ls-files -s >expect &&
64 sha1=$(git rev-parse :new) &&
65 (
66 echo "100644 $sha1 1 old"
67 echo "100644 $sha1 3 old"
68 ) | git update-index --index-info &&
69 >old &&
70 git ls-files -s &&
71 git reset --hard &&
72 git ls-files -s >actual &&
73 ! test -f old
d1a43f2a
JH
74'
75
76test_expect_success 'Porcelain checkout -f should remove remnants too' '
76da5b1d
JH
77 read_tree_u_must_succeed --reset -u HEAD &&
78 git ls-files -s >expect &&
79 sha1=$(git rev-parse :new) &&
80 (
81 echo "100644 $sha1 1 old"
82 echo "100644 $sha1 3 old"
83 ) | git update-index --index-info &&
84 >old &&
85 git ls-files -s &&
86 git checkout -f &&
87 git ls-files -s >actual &&
88 ! test -f old
d1a43f2a
JH
89'
90
91test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
76da5b1d
JH
92 read_tree_u_must_succeed --reset -u HEAD &&
93 git ls-files -s >expect &&
94 sha1=$(git rev-parse :new) &&
95 (
96 echo "100644 $sha1 1 old"
97 echo "100644 $sha1 3 old"
98 ) | git update-index --index-info &&
99 >old &&
100 git ls-files -s &&
101 git checkout -f HEAD &&
102 git ls-files -s >actual &&
103 ! test -f old
d1a43f2a
JH
104'
105
50753d00 106test_done