Merge branch 'maint'
[git/mingw/4msysgit/kblees.git] / t / t1005-read-tree-reset.sh
blob849911683a799981a565416a88fe9092b3727853
1 #!/bin/sh
3 test_description='read-tree -u --reset'
5 . ./test-lib.sh
7 # two-tree test
9 test_expect_success 'setup' '
10 git init &&
11 mkdir df &&
12 echo content >df/file &&
13 git add df/file &&
14 git commit -m one &&
15 git ls-files >expect &&
16 rm -rf df &&
17 echo content >df &&
18 git add df &&
19 echo content >new &&
20 git add new &&
21 git commit -m two
24 test_expect_success 'reset should work' '
25 git read-tree -u --reset HEAD^ &&
26 git ls-files >actual &&
27 test_cmp expect actual
30 test_expect_success 'reset should remove remnants from a failed merge' '
31 git read-tree --reset -u HEAD &&
32 git ls-files -s >expect &&
33 sha1=$(git rev-parse :new) &&
35 echo "100644 $sha1 1 old"
36 echo "100644 $sha1 3 old"
37 ) | git update-index --index-info &&
38 >old &&
39 git ls-files -s &&
40 git read-tree --reset -u HEAD &&
41 git ls-files -s >actual &&
42 ! test -f old
45 test_expect_success 'Porcelain reset should remove remnants too' '
46 git read-tree --reset -u HEAD &&
47 git ls-files -s >expect &&
48 sha1=$(git rev-parse :new) &&
50 echo "100644 $sha1 1 old"
51 echo "100644 $sha1 3 old"
52 ) | git update-index --index-info &&
53 >old &&
54 git ls-files -s &&
55 git reset --hard &&
56 git ls-files -s >actual &&
57 ! test -f old
60 test_expect_success 'Porcelain checkout -f should remove remnants too' '
61 git read-tree --reset -u HEAD &&
62 git ls-files -s >expect &&
63 sha1=$(git rev-parse :new) &&
65 echo "100644 $sha1 1 old"
66 echo "100644 $sha1 3 old"
67 ) | git update-index --index-info &&
68 >old &&
69 git ls-files -s &&
70 git checkout -f &&
71 git ls-files -s >actual &&
72 ! test -f old
75 test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
76 git read-tree --reset -u HEAD &&
77 git ls-files -s >expect &&
78 sha1=$(git rev-parse :new) &&
80 echo "100644 $sha1 1 old"
81 echo "100644 $sha1 3 old"
82 ) | git update-index --index-info &&
83 >old &&
84 git ls-files -s &&
85 git checkout -f HEAD &&
86 git ls-files -s >actual &&
87 ! test -f old
90 test_done