commit: reorganise commit hint strings

Strings of hint messages inserted into editor on interactive commit was scattered in-line, rendering the code harder to understand at first glance. Extract those messages out into separate variables to make the code outline easier to follow. Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Đoàn Trần Công Danh <congdanhqx@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 54ba2f1862df7144eb3a8b192d992b520bdc3743
1 file changed +10 -10
builtin/commit.c
+10 -10
@@ -889,6 +889,14 @@ 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
901 if (whence != FROM_COMMIT) {
902 if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
@@ -911,20 +919,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
919
920 fprintf(s->fp, "\n");
921 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);
922 + status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_all, comment_line_char);
923 else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
924 if (whence == FROM_COMMIT && !merge_contains_scissors)
925 wt_status_add_cut_line(s->fp);
926 } 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);
927 + status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_space, comment_line_char);
928
929 /*
930 * These should never fail because they come from our own