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