commit: check for empty message before the check for untouched template
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>
Kaartic Sivaraam committed
Jul 17, 2017 at 21:06 UTC
bc17f35f8c65295fbfcb281dda8560136fb26fb4
1 file changed
+5
-5
builtin/commit.c
+5
-5
@@ -1736,17 +1736,17 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1736
if (verbose || /* Truncate the message just before the diff, if any. */
1737
cleanup_mode == CLEANUP_SCISSORS)
1738
strbuf_setlen(&sb, wt_status_locate_end(sb.buf, sb.len));
1739
-
1739
if (cleanup_mode != CLEANUP_NONE)
1740
strbuf_stripspace(&sb, cleanup_mode == CLEANUP_ALL);
1742
- if (template_untouched(&sb) && !allow_empty_message) {
1741
+
1742
+ if (message_is_empty(&sb) && !allow_empty_message) {
1743
rollback_index_files();
1744
- fprintf(stderr, _("Aborting commit; you did not edit the message.\n"));
1744
+ fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
1745
exit(1);
1746
}
1747
- if (message_is_empty(&sb) && !allow_empty_message) {
1747
+ if (template_untouched(&sb) && !allow_empty_message) {
1748
rollback_index_files();
1749
- fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
1749
+ fprintf(stderr, _("Aborting commit; you did not edit the message.\n"));
1750
exit(1);
1751
}
1752