Skip to content

Commit 14793a4

Browse files
committed
Merge branch 'hj/commit-allow-empty-message'
"git commit --allow-empty-message" won't abort the operation upon an empty message, but the hint shown in the editor said otherwise. * hj/commit-allow-empty-message: commit: remove irrelavent prompt on `--allow-empty-message` commit: reorganise commit hint strings
2 parents 1e893a1 + 6f70f00 commit 14793a4

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

builtin/commit.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,22 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
889889
int ident_shown = 0;
890890
int saved_color_setting;
891891
struct ident_split ci, ai;
892-
892+
const char *hint_cleanup_all = allow_empty_message ?
893+
_("Please enter the commit message for your changes."
894+
" Lines starting\nwith '%c' will be ignored.\n") :
895+
_("Please enter the commit message for your changes."
896+
" Lines starting\nwith '%c' will be ignored, and an empty"
897+
" message aborts the commit.\n");
898+
const char *hint_cleanup_space = allow_empty_message ?
899+
_("Please enter the commit message for your changes."
900+
" Lines starting\n"
901+
"with '%c' will be kept; you may remove them"
902+
" yourself if you want to.\n") :
903+
_("Please enter the commit message for your changes."
904+
" Lines starting\n"
905+
"with '%c' will be kept; you may remove them"
906+
" yourself if you want to.\n"
907+
"An empty message aborts the commit.\n");
893908
if (whence != FROM_COMMIT) {
894909
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
895910
!merge_contains_scissors)
@@ -911,20 +926,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
911926

912927
fprintf(s->fp, "\n");
913928
if (cleanup_mode == COMMIT_MSG_CLEANUP_ALL)
914-
status_printf(s, GIT_COLOR_NORMAL,
915-
_("Please enter the commit message for your changes."
916-
" Lines starting\nwith '%c' will be ignored, and an empty"
917-
" message aborts the commit.\n"), comment_line_char);
929+
status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_all, comment_line_char);
918930
else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
919931
if (whence == FROM_COMMIT && !merge_contains_scissors)
920932
wt_status_add_cut_line(s->fp);
921933
} else /* COMMIT_MSG_CLEANUP_SPACE, that is. */
922-
status_printf(s, GIT_COLOR_NORMAL,
923-
_("Please enter the commit message for your changes."
924-
" Lines starting\n"
925-
"with '%c' will be kept; you may remove them"
926-
" yourself if you want to.\n"
927-
"An empty message aborts the commit.\n"), comment_line_char);
934+
status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_space, comment_line_char);
928935

929936
/*
930937
* These should never fail because they come from our own

t/t7500-commit-template-squash-signoff.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ test_expect_success 'invalid message options when using --fixup' '
498498
cat >expected-template <<EOF
499499
500500
# Please enter the commit message for your changes. Lines starting
501-
# with '#' will be ignored, and an empty message aborts the commit.
501+
# with '#' will be ignored.
502502
#
503503
# Author: A U Thor <[email protected]>
504504
#

0 commit comments

Comments
 (0)