1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-19 03:36:09 +02:00

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
This commit is contained in:
Junio C Hamano 2021-07-28 13:17:57 -07:00
commit 14793a4e37
2 changed files with 19 additions and 12 deletions

View File

@ -889,7 +889,22 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
int ident_shown = 0; int ident_shown = 0;
int saved_color_setting; int saved_color_setting;
struct ident_split ci, ai; struct ident_split ci, ai;
const char *hint_cleanup_all = allow_empty_message ?
_("Please enter the commit message for your changes."
" Lines starting\nwith '%c' will be ignored.\n") :
_("Please enter the commit message for your changes."
" Lines starting\nwith '%c' will be ignored, and an empty"
" message aborts the commit.\n");
const char *hint_cleanup_space = allow_empty_message ?
_("Please enter the commit message for your changes."
" Lines starting\n"
"with '%c' will be kept; you may remove them"
" yourself if you want to.\n") :
_("Please enter the commit message for your changes."
" Lines starting\n"
"with '%c' will be kept; you may remove them"
" yourself if you want to.\n"
"An empty message aborts the commit.\n");
if (whence != FROM_COMMIT) { if (whence != FROM_COMMIT) {
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS && if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
!merge_contains_scissors) !merge_contains_scissors)
@ -911,20 +926,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
fprintf(s->fp, "\n"); fprintf(s->fp, "\n");
if (cleanup_mode == COMMIT_MSG_CLEANUP_ALL) if (cleanup_mode == COMMIT_MSG_CLEANUP_ALL)
status_printf(s, GIT_COLOR_NORMAL, status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_all, comment_line_char);
_("Please enter the commit message for your changes."
" Lines starting\nwith '%c' will be ignored, and an empty"
" message aborts the commit.\n"), comment_line_char);
else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) { else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
if (whence == FROM_COMMIT && !merge_contains_scissors) if (whence == FROM_COMMIT && !merge_contains_scissors)
wt_status_add_cut_line(s->fp); wt_status_add_cut_line(s->fp);
} else /* COMMIT_MSG_CLEANUP_SPACE, that is. */ } else /* COMMIT_MSG_CLEANUP_SPACE, that is. */
status_printf(s, GIT_COLOR_NORMAL, status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_space, comment_line_char);
_("Please enter the commit message for your changes."
" Lines starting\n"
"with '%c' will be kept; you may remove them"
" yourself if you want to.\n"
"An empty message aborts the commit.\n"), comment_line_char);
/* /*
* These should never fail because they come from our own * These should never fail because they come from our own

View File

@ -498,7 +498,7 @@ test_expect_success 'invalid message options when using --fixup' '
cat >expected-template <<EOF cat >expected-template <<EOF
# Please enter the commit message for your changes. Lines starting # Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit. # with '#' will be ignored.
# #
# Author: A U Thor <author@example.com> # Author: A U Thor <author@example.com>
# #