@@ -194,24 +194,6 @@ static void determine_whence(struct wt_status *s)
194
194
s -> whence = whence ;
195
195
}
196
196
197
- static const char * whence_s (void )
198
- {
199
- const char * s = "" ;
200
-
201
- switch (whence ) {
202
- case FROM_COMMIT :
203
- break ;
204
- case FROM_MERGE :
205
- s = _ ("merge" );
206
- break ;
207
- case FROM_CHERRY_PICK :
208
- s = _ ("cherry-pick" );
209
- break ;
210
- }
211
-
212
- return s ;
213
- }
214
-
215
197
static void rollback_index_files (void )
216
198
{
217
199
switch (commit_style ) {
@@ -453,8 +435,12 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
453
435
*/
454
436
commit_style = COMMIT_PARTIAL ;
455
437
456
- if (whence != FROM_COMMIT )
457
- die (_ ("cannot do a partial commit during a %s." ), whence_s ());
438
+ if (whence != FROM_COMMIT ) {
439
+ if (whence == FROM_MERGE )
440
+ die (_ ("cannot do a partial commit during a merge." ));
441
+ else if (whence == FROM_CHERRY_PICK )
442
+ die (_ ("cannot do a partial commit during a cherry-pick." ));
443
+ }
458
444
459
445
memset (& partial , 0 , sizeof (partial ));
460
446
partial .strdup_strings = 1 ;
@@ -796,28 +782,31 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
796
782
char * ai_tmp , * ci_tmp ;
797
783
if (whence != FROM_COMMIT )
798
784
status_printf_ln (s , GIT_COLOR_NORMAL ,
799
- _ ("\n"
800
- "It looks like you may be committing a %s.\n"
801
- "If this is not correct, please remove the file\n"
802
- " %s\n"
803
- "and try again.\n"
804
- "" ),
805
- whence_s (),
785
+ whence == FROM_MERGE
786
+ ? _ ("\n"
787
+ "It looks like you may be committing a merge.\n"
788
+ "If this is not correct, please remove the file\n"
789
+ " %s\n"
790
+ "and try again.\n" )
791
+ : _ ("\n"
792
+ "It looks like you may be committing a cherry-pick.\n"
793
+ "If this is not correct, please remove the file\n"
794
+ " %s\n"
795
+ "and try again.\n" ),
806
796
git_path (whence == FROM_MERGE
807
797
? "MERGE_HEAD"
808
798
: "CHERRY_PICK_HEAD" ));
809
799
810
800
fprintf (s -> fp , "\n" );
811
- status_printf (s , GIT_COLOR_NORMAL ,
812
- _ ("Please enter the commit message for your changes." ));
813
801
if (cleanup_mode == CLEANUP_ALL )
814
- status_printf_more (s , GIT_COLOR_NORMAL ,
815
- _ (" Lines starting\n "
816
- "with '#' will be ignored, and an empty"
802
+ status_printf (s , GIT_COLOR_NORMAL ,
803
+ _ ("Please enter the commit message for your changes. "
804
+ " Lines starting\nwith '#' will be ignored, and an empty"
817
805
" message aborts the commit.\n" ));
818
806
else /* CLEANUP_SPACE, that is. */
819
- status_printf_more (s , GIT_COLOR_NORMAL ,
820
- _ (" Lines starting\n"
807
+ status_printf (s , GIT_COLOR_NORMAL ,
808
+ _ ("Please enter the commit message for your changes."
809
+ " Lines starting\n"
821
810
"with '#' will be kept; you may remove them"
822
811
" yourself if you want to.\n"
823
812
"An empty message aborts the commit.\n" ));
@@ -1072,8 +1061,12 @@ static int parse_and_validate_options(int argc, const char *argv[],
1072
1061
/* Sanity check options */
1073
1062
if (amend && !current_head )
1074
1063
die (_ ("You have nothing to amend." ));
1075
- if (amend && whence != FROM_COMMIT )
1076
- die (_ ("You are in the middle of a %s -- cannot amend." ), whence_s ());
1064
+ if (amend && whence != FROM_COMMIT ) {
1065
+ if (whence == FROM_MERGE )
1066
+ die (_ ("You are in the middle of a merge -- cannot amend." ));
1067
+ else if (whence == FROM_CHERRY_PICK )
1068
+ die (_ ("You are in the middle of a cherry-pick -- cannot amend." ));
1069
+ }
1077
1070
if (fixup_message && squash_message )
1078
1071
die (_ ("Options --squash and --fixup cannot be used together" ));
1079
1072
if (use_message )
0 commit comments