52
error: could not apply \$picked... picked
53
hint: after resolving the conflicts, mark the corrected paths
54
hint: with 'git add <paths>' or 'git rm <paths>'
55
- hint: and commit the result with 'git commit -c \$picked'
55
+ hint: and commit the result with 'git commit -c CHERRY_PICK_HEAD'
56
EOF
57
test_must_fail git cherry-pick picked 2>actual &&
58
59
test_cmp expected actual
60
"
61
62
+test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '
63
+ pristine_detach initial &&
64
+ test_must_fail git cherry-pick picked &&
65
+ test_cmp_rev picked CHERRY_PICK_HEAD
66
+'
67
+
68
+test_expect_success 'successful cherry-pick does not set CHERRY_PICK_HEAD' '
69
+ pristine_detach initial &&
70
+ git cherry-pick base &&
71
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
72
+'
73
+
74
+test_expect_success 'cherry-pick --no-commit does not set CHERRY_PICK_HEAD' '
75
+ pristine_detach initial &&
76
+ git cherry-pick --no-commit base &&
77
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
78
+'
79
+
80
+test_expect_success 'GIT_CHERRY_PICK_HELP suppresses CHERRY_PICK_HEAD' '
81
+ pristine_detach initial &&
82
+ (
83
+ GIT_CHERRY_PICK_HELP="and then do something else" &&
84
+ export GIT_CHERRY_PICK_HELP &&
85
+ test_must_fail git cherry-pick picked
86
+ ) &&
87
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
88
+'
89
+
90
+test_expect_success 'git reset clears CHERRY_PICK_HEAD' '
91
+ pristine_detach initial &&
92
+
93
+ test_must_fail git cherry-pick picked &&
94
+ git reset &&
95
+
96
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
97
+'
98
+
99
+test_expect_success 'failed commit does not clear CHERRY_PICK_HEAD' '
100
+ pristine_detach initial &&
101
+
102
+ test_must_fail git cherry-pick picked &&
103
+ test_must_fail git commit &&
104
+
105
+ test_cmp_rev picked CHERRY_PICK_HEAD
106
+'
107
+
108
+test_expect_success 'cancelled commit does not clear CHERRY_PICK_HEAD' '
109
+ pristine_detach initial &&
110
+
111
+ test_must_fail git cherry-pick picked &&
112
+ echo resolved >foo &&
113
+ git add foo &&
114
+ git update-index --refresh -q &&
115
+ test_must_fail git diff-index --exit-code HEAD &&
116
+ (
117
+ GIT_EDITOR=false &&
118
+ export GIT_EDITOR &&
119
+ test_must_fail git commit
120
+ ) &&
121
+
122
+ test_cmp_rev picked CHERRY_PICK_HEAD
123
+'
124
+
125
+test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
126
+ pristine_detach initial &&
127
+
128
+ test_must_fail git cherry-pick picked &&
129
+ echo resolved >foo &&
130
+ git add foo &&
131
+ git commit &&
132
+
133
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
134
+'
135
+
136
test_expect_success 'failed cherry-pick produces dirty index' '
137
pristine_detach initial &&
138