Commit | Line | Data |
---|---|---|
6232b343 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='cherry picking and reverting a merge | |
4 | ||
5 | b---c | |
6 | / / | |
7 | initial---a | |
8 | ||
9 | ' | |
10 | ||
11 | . ./test-lib.sh | |
12 | ||
13 | test_expect_success setup ' | |
14 | ||
15 | >A && | |
16 | >B && | |
17 | git add A B && | |
18 | git commit -m "Initial" && | |
19 | git tag initial && | |
20 | git branch side && | |
21 | echo new line >A && | |
22 | git commit -m "add line to A" A && | |
23 | git tag a && | |
24 | git checkout side && | |
25 | echo new line >B && | |
26 | git commit -m "add line to B" B && | |
27 | git tag b && | |
28 | git checkout master && | |
29 | git merge side && | |
30 | git tag c | |
31 | ||
32 | ' | |
33 | ||
34 | test_expect_success 'cherry-pick a non-merge with -m should fail' ' | |
35 | ||
36 | git reset --hard && | |
37 | git checkout a^0 && | |
bf71009e | 38 | test_expect_code 128 git cherry-pick -m 1 b && |
9f12bec4 | 39 | git diff --exit-code a -- |
6232b343 JH |
40 | |
41 | ' | |
42 | ||
43 | test_expect_success 'cherry pick a merge without -m should fail' ' | |
44 | ||
45 | git reset --hard && | |
46 | git checkout a^0 && | |
d492b31c | 47 | test_must_fail git cherry-pick c && |
9f12bec4 | 48 | git diff --exit-code a -- |
6232b343 JH |
49 | |
50 | ' | |
51 | ||
52 | test_expect_success 'cherry pick a merge (1)' ' | |
53 | ||
54 | git reset --hard && | |
55 | git checkout a^0 && | |
56 | git cherry-pick -m 1 c && | |
57 | git diff --exit-code c | |
58 | ||
59 | ' | |
60 | ||
61 | test_expect_success 'cherry pick a merge (2)' ' | |
62 | ||
63 | git reset --hard && | |
64 | git checkout b^0 && | |
65 | git cherry-pick -m 2 c && | |
66 | git diff --exit-code c | |
67 | ||
68 | ' | |
69 | ||
70 | test_expect_success 'cherry pick a merge relative to nonexistent parent should fail' ' | |
71 | ||
72 | git reset --hard && | |
73 | git checkout b^0 && | |
d492b31c | 74 | test_must_fail git cherry-pick -m 3 c |
6232b343 JH |
75 | |
76 | ' | |
77 | ||
78 | test_expect_success 'revert a non-merge with -m should fail' ' | |
79 | ||
80 | git reset --hard && | |
81 | git checkout c^0 && | |
d492b31c | 82 | test_must_fail git revert -m 1 b && |
6232b343 JH |
83 | git diff --exit-code c |
84 | ||
85 | ' | |
86 | ||
87 | test_expect_success 'revert a merge without -m should fail' ' | |
88 | ||
89 | git reset --hard && | |
90 | git checkout c^0 && | |
d492b31c | 91 | test_must_fail git revert c && |
6232b343 JH |
92 | git diff --exit-code c |
93 | ||
94 | ' | |
95 | ||
96 | test_expect_success 'revert a merge (1)' ' | |
97 | ||
98 | git reset --hard && | |
99 | git checkout c^0 && | |
100 | git revert -m 1 c && | |
9f12bec4 | 101 | git diff --exit-code a -- |
6232b343 JH |
102 | |
103 | ' | |
104 | ||
105 | test_expect_success 'revert a merge (2)' ' | |
106 | ||
107 | git reset --hard && | |
108 | git checkout c^0 && | |
109 | git revert -m 2 c && | |
9f12bec4 | 110 | git diff --exit-code b -- |
6232b343 JH |
111 | |
112 | ' | |
113 | ||
114 | test_expect_success 'revert a merge relative to nonexistent parent should fail' ' | |
115 | ||
116 | git reset --hard && | |
117 | git checkout c^0 && | |
d492b31c | 118 | test_must_fail git revert -m 3 c && |
6232b343 JH |
119 | git diff --exit-code c |
120 | ||
121 | ' | |
122 | ||
123 | test_done |