Skip to content

Commit 6f70f00

Browse files
SuibianPgitster
authored andcommitted
commit: remove irrelavent prompt on --allow-empty-message
Even when the `--allow-empty-message` option is given, "git commit" offers an interactive editor session with prefilled message that says the commit will be aborted if the buffer is emptied, which is wrong. Remove the "an empty message aborts" part from the message when the option is given to fix it. Helped-by: Junio C Hamano <[email protected]> Helped-by: Đoàn Trần Công Danh <[email protected]> Helped-by: Felipe Contreras <[email protected]> Signed-off-by: Hu Jialun <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54ba2f1 commit 6f70f00

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

builtin/commit.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -889,15 +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-
const char *hint_cleanup_all = _("Please enter the commit message for your changes."
893-
" Lines starting\nwith '%c' will be ignored,"
894-
" and an empty message aborts the commit.\n");
895-
const char *hint_cleanup_space = _("Please enter the commit message for your changes."
896-
" Lines starting\n"
897-
"with '%c' will be kept; you may remove them"
898-
" yourself if you want to.\n"
899-
"An empty message aborts the commit.\n");
900-
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");
901908
if (whence != FROM_COMMIT) {
902909
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
903910
!merge_contains_scissors)

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)