Merge branch 'jc/revision-dash-count-parsing'
[git.git] / t / t7111-reset-table.sh
blobce421ad5ac4b3a17d0e347a7d86a386e2b14547b
1 #!/bin/sh
3 # Copyright (c) 2010 Christian Couder
6 test_description='Tests to check that "reset" options follow a known table'
8 . ./test-lib.sh
11 test_expect_success 'creating initial commits' '
12 test_commit E file1 &&
13 test_commit D file1 &&
14 test_commit C file1
17 while read W1 I1 H1 T opt W2 I2 H2
19 test_expect_success "check: $W1 $I1 $H1 $T --$opt $W2 $I2 $H2" '
20 git reset --hard C &&
21 if test "$I1" != "$H1"
22 then
23 echo "$I1" >file1 &&
24 git add file1
25 fi &&
26 if test "$W1" != "$I1"
27 then
28 echo "$W1" >file1
29 fi &&
30 if test "$W2" != "XXXXX"
31 then
32 git reset --$opt $T &&
33 test "$(cat file1)" = "$W2" &&
34 git checkout-index -f -- file1 &&
35 test "$(cat file1)" = "$I2" &&
36 git checkout -f HEAD -- file1 &&
37 test "$(cat file1)" = "$H2"
38 else
39 test_must_fail git reset --$opt $T
42 done <<\EOF
43 A B C D soft A B D
44 A B C D mixed A D D
45 A B C D hard D D D
46 A B C D merge XXXXX
47 A B C D keep XXXXX
48 A B C C soft A B C
49 A B C C mixed A C C
50 A B C C hard C C C
51 A B C C merge XXXXX
52 A B C C keep A C C
53 B B C D soft B B D
54 B B C D mixed B D D
55 B B C D hard D D D
56 B B C D merge D D D
57 B B C D keep XXXXX
58 B B C C soft B B C
59 B B C C mixed B C C
60 B B C C hard C C C
61 B B C C merge C C C
62 B B C C keep B C C
63 B C C D soft B C D
64 B C C D mixed B D D
65 B C C D hard D D D
66 B C C D merge XXXXX
67 B C C D keep XXXXX
68 B C C C soft B C C
69 B C C C mixed B C C
70 B C C C hard C C C
71 B C C C merge B C C
72 B C C C keep B C C
73 EOF
75 test_expect_success 'setting up branches to test with unmerged entries' '
76 git reset --hard C &&
77 git branch branch1 &&
78 git branch branch2 &&
79 git checkout branch1 &&
80 test_commit B1 file1 &&
81 git checkout branch2 &&
82 test_commit B file1
85 while read W1 I1 H1 T opt W2 I2 H2
87 test_expect_success "check: $W1 $I1 $H1 $T --$opt $W2 $I2 $H2" '
88 git reset --hard B &&
89 test_must_fail git merge branch1 &&
90 cat file1 >X_file1 &&
91 if test "$W2" != "XXXXX"
92 then
93 git reset --$opt $T &&
94 if test "$W2" = "X"
95 then
96 test_cmp file1 X_file1
97 else
98 test "$(cat file1)" = "$W2"
99 fi &&
100 git checkout-index -f -- file1 &&
101 test "$(cat file1)" = "$I2" &&
102 git checkout -f HEAD -- file1 &&
103 test "$(cat file1)" = "$H2"
104 else
105 test_must_fail git reset --$opt $T
108 done <<\EOF
109 X U B C soft XXXXX
110 X U B C mixed X C C
111 X U B C hard C C C
112 X U B C merge C C C
113 X U B C keep XXXXX
114 X U B B soft XXXXX
115 X U B B mixed X B B
116 X U B B hard B B B
117 X U B B merge B B B
118 X U B B keep XXXXX
121 test_done