@@ -122,7 +122,6 @@ static enum commit_msg_cleanup_mode cleanup_mode;
122
122
static const char * cleanup_arg ;
123
123
124
124
static enum commit_whence whence ;
125
- static int sequencer_in_use ;
126
125
static int use_editor = 1 , include_status = 1 ;
127
126
static int have_option_m ;
128
127
static struct strbuf message = STRBUF_INIT ;
@@ -179,11 +178,9 @@ static void determine_whence(struct wt_status *s)
179
178
{
180
179
if (file_exists (git_path_merge_head (the_repository )))
181
180
whence = FROM_MERGE ;
182
- else if (file_exists (git_path_cherry_pick_head (the_repository ))) {
183
- whence = FROM_CHERRY_PICK ;
184
- if (file_exists (git_path_seq_dir ()))
185
- sequencer_in_use = 1 ;
186
- }
181
+ else if (file_exists (git_path_cherry_pick_head (the_repository )))
182
+ whence = file_exists (git_path_seq_dir ()) ?
183
+ FROM_CHERRY_PICK_MULTI : FROM_CHERRY_PICK_SINGLE ;
187
184
else
188
185
whence = FROM_COMMIT ;
189
186
if (s )
@@ -453,7 +450,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
453
450
if (whence != FROM_COMMIT ) {
454
451
if (whence == FROM_MERGE )
455
452
die (_ ("cannot do a partial commit during a merge." ));
456
- else if (whence == FROM_CHERRY_PICK )
453
+ else if (is_from_cherry_pick ( whence ) )
457
454
die (_ ("cannot do a partial commit during a cherry-pick." ));
458
455
}
459
456
@@ -771,7 +768,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
771
768
*/
772
769
else if (whence == FROM_MERGE )
773
770
hook_arg1 = "merge" ;
774
- else if (whence == FROM_CHERRY_PICK ) {
771
+ else if (is_from_cherry_pick ( whence ) ) {
775
772
hook_arg1 = "commit" ;
776
773
hook_arg2 = "CHERRY_PICK_HEAD" ;
777
774
}
@@ -948,9 +945,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
948
945
run_status (stdout , index_file , prefix , 0 , s );
949
946
if (amend )
950
947
fputs (_ (empty_amend_advice ), stderr );
951
- else if (whence == FROM_CHERRY_PICK ) {
948
+ else if (is_from_cherry_pick ( whence ) ) {
952
949
fputs (_ (empty_cherry_pick_advice ), stderr );
953
- if (! sequencer_in_use )
950
+ if (whence == FROM_CHERRY_PICK_SINGLE )
954
951
fputs (_ (empty_cherry_pick_advice_single ), stderr );
955
952
else
956
953
fputs (_ (empty_cherry_pick_advice_multi ), stderr );
@@ -1156,7 +1153,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
1156
1153
if (amend && whence != FROM_COMMIT ) {
1157
1154
if (whence == FROM_MERGE )
1158
1155
die (_ ("You are in the middle of a merge -- cannot amend." ));
1159
- else if (whence == FROM_CHERRY_PICK )
1156
+ else if (is_from_cherry_pick ( whence ) )
1160
1157
die (_ ("You are in the middle of a cherry-pick -- cannot amend." ));
1161
1158
}
1162
1159
if (fixup_message && squash_message )
@@ -1179,7 +1176,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
1179
1176
use_message = edit_message ;
1180
1177
if (amend && !use_message && !fixup_message )
1181
1178
use_message = "HEAD" ;
1182
- if (!use_message && whence != FROM_CHERRY_PICK && renew_authorship )
1179
+ if (!use_message && ! is_from_cherry_pick ( whence ) && renew_authorship )
1183
1180
die (_ ("--reset-author can be used only with -C, -c or --amend." ));
1184
1181
if (use_message ) {
1185
1182
use_message_buffer = read_commit_message (use_message );
@@ -1188,7 +1185,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
1188
1185
author_message_buffer = use_message_buffer ;
1189
1186
}
1190
1187
}
1191
- if (whence == FROM_CHERRY_PICK && !renew_authorship ) {
1188
+ if (is_from_cherry_pick ( whence ) && !renew_authorship ) {
1192
1189
author_message = "CHERRY_PICK_HEAD" ;
1193
1190
author_message_buffer = read_commit_message (author_message );
1194
1191
}
@@ -1606,7 +1603,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1606
1603
reduce_heads_replace (& parents );
1607
1604
} else {
1608
1605
if (!reflog_msg )
1609
- reflog_msg = (whence == FROM_CHERRY_PICK )
1606
+ reflog_msg = is_from_cherry_pick (whence )
1610
1607
? "commit (cherry-pick)"
1611
1608
: "commit" ;
1612
1609
commit_list_insert (current_head , & parents );
0 commit comments