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 <gitster@pobox.com> Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Helped-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Hu Jialun <hujialun@comp.nus.edu.sg> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Hu Jialun committed Jul 10, 2021 at 02:07 UTC 6f70f00b4f94c036767cbe0f4cd23db573a4e8ba
2 files changed +17 -10
builtin/commit.c
+16 -9
@@ -889,15 +889,22 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
889 int ident_shown = 0;
890 int saved_color_setting;
891 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");
908 if (whence != FROM_COMMIT) {
909 if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
910 !merge_contains_scissors)
t/t7500-commit-template-squash-signoff.sh
+1 -1
@@ -498,7 +498,7 @@ test_expect_success 'invalid message options when using --fixup' '
498 cat >expected-template <<EOF
499
500 # 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.
502 #
503 # Author: A U Thor <author@example.com>
504 #