summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaartic Sivaraam <kaarticsivaraam91196@gmail.com>2017-07-17 21:06:15 +0530
committerJunio C Hamano <gitster@pobox.com>2017-07-17 15:10:41 -0700
commitbc17f35f8c65295fbfcb281dda8560136fb26fb4 (patch)
tree0ed2f0e5bbaa8e07ebda466083b9546ccf4bf3a9
parent08f9c32463bf9e578acb7ac5f77afd36e803c6bc (diff)
downloadgit-ks/commit-abort-on-empty-message-fix.tar.gz
commit: check for empty message before the check for untouched templateks/commit-abort-on-empty-message-fix
The check for whether the template given to 'git commit' is untouched is done before the empty message check. This results in a wrong error message being displayed in the following case. When the user removes everything in template completely to abort the commit he is shown the "template untouched" error which is wrong. He should be shown the "empty message" error. Do the empty message check before checking for an untouched template thus fixing this issue. Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/commit.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index aff6bf7aad..9c299d7925 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1736,17 +1736,17 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (verbose || /* Truncate the message just before the diff, if any. */
cleanup_mode == CLEANUP_SCISSORS)
strbuf_setlen(&sb, wt_status_locate_end(sb.buf, sb.len));
-
if (cleanup_mode != CLEANUP_NONE)
strbuf_stripspace(&sb, cleanup_mode == CLEANUP_ALL);
- if (template_untouched(&sb) && !allow_empty_message) {
+
+ if (message_is_empty(&sb) && !allow_empty_message) {
rollback_index_files();
- fprintf(stderr, _("Aborting commit; you did not edit the message.\n"));
+ fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
exit(1);
}
- if (message_is_empty(&sb) && !allow_empty_message) {
+ if (template_untouched(&sb) && !allow_empty_message) {
rollback_index_files();
- fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
+ fprintf(stderr, _("Aborting commit; you did not edit the message.\n"));
exit(1);
}