Skip to content

Commit 54ba2f1

Browse files
SuibianPgitster
authored andcommitted
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 <[email protected]> Helped-by: Đoàn Trần Công Danh <[email protected]> Signed-off-by: Hu Jialun <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf3c04 commit 54ba2f1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

builtin/commit.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,14 @@ 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");
892900

893901
if (whence != FROM_COMMIT) {
894902
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
@@ -911,20 +919,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
911919

912920
fprintf(s->fp, "\n");
913921
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);
918923
else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
919924
if (whence == FROM_COMMIT && !merge_contains_scissors)
920925
wt_status_add_cut_line(s->fp);
921926
} 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);
928928

929929
/*
930930
* These should never fail because they come from our own

0 commit comments

Comments
 (0)