All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] commit: remove irrelavent prompt on `--allow-empty-message`
@ 2021-07-06  2:24 Hu Jialun
  2021-07-06 15:44 ` Junio C Hamano
  2021-07-07 16:23 ` Hu Jialun
  0 siblings, 2 replies; 20+ messages in thread
From: Hu Jialun @ 2021-07-06  2:24 UTC (permalink / raw)
  To: git; +Cc: Hu Jialun

Currently, COMMIT_EDITMSG contains "...and an empty message aborts the
commit", regardless of whether the --allow-empty-message option is
specified or not. This is deemed confusing and unintended.

Signed-off-by: Hu Jialun <hujialun@comp.nus.edu.sg>
---
 builtin/commit.c | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 190d215d43..61e3382db9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -910,21 +910,36 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		}
 
 		fprintf(s->fp, "\n");
-		if (cleanup_mode == COMMIT_MSG_CLEANUP_ALL)
-			status_printf(s, GIT_COLOR_NORMAL,
-				_("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) {
+		if (cleanup_mode == COMMIT_MSG_CLEANUP_ALL) {
+			if (allow_empty_message) {
+				status_printf(s, GIT_COLOR_NORMAL,
+					_("Please enter the commit message for your changes."
+					" Lines starting\nwith '%c' will be ignored.\n"), comment_line_char);
+			} else {
+				status_printf(s, GIT_COLOR_NORMAL,
+					_("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) {
 			if (whence == FROM_COMMIT && !merge_contains_scissors)
 				wt_status_add_cut_line(s->fp);
-		} else /* COMMIT_MSG_CLEANUP_SPACE, that is. */
-			status_printf(s, GIT_COLOR_NORMAL,
-				_("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);
+		} else { /* COMMIT_MSG_CLEANUP_SPACE, that is. */
+			if (allow_empty_message) {
+				status_printf(s, GIT_COLOR_NORMAL,
+					_("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"), comment_line_char);
+			} else {
+				status_printf(s, GIT_COLOR_NORMAL,
+					_("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
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-07-22 21:19 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06  2:24 [PATCH] commit: remove irrelavent prompt on `--allow-empty-message` Hu Jialun
2021-07-06 15:44 ` Junio C Hamano
2021-07-07  4:37   ` Felipe Contreras
2021-07-07 10:43   ` Hu Jialun
2021-07-07 16:23 ` Hu Jialun
2021-07-07 16:23   ` [PATCH v2 1/2] commit: reorganise duplicate commit prompt strings Hu Jialun
2021-07-07 16:57     ` Đoàn Trần Công Danh
2021-07-07 17:44       ` Junio C Hamano
2021-07-07 16:23   ` [PATCH v2 2/2] commit: remove irrelavent prompt on `--allow-empty-message` Hu Jialun
2021-07-07 17:42     ` Felipe Contreras
2021-07-08 15:19   ` [PATCH] " Hu Jialun
2021-07-08 16:05     ` Đoàn Trần Công Danh
2021-07-08 18:26       ` Junio C Hamano
2021-07-09 18:07   ` [PATCH v3 1/2] commit: reorganise commit hint strings Hu Jialun
2021-07-09 19:14     ` Junio C Hamano
2021-07-09 18:07   ` [PATCH v3 2/2] commit: remove irrelavent prompt on `--allow-empty-message` Hu Jialun
2021-07-09 19:14     ` Junio C Hamano
2021-07-10 17:26       ` Hu Jialun
2021-07-22 18:33       ` Hu Jialun
2021-07-22 21:18         ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.