Skip to content

Commit bc17f35

Browse files
Kaartic Sivaraamgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08f9c32 commit bc17f35

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

builtin/commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,17 +1736,17 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17361736
if (verbose || /* Truncate the message just before the diff, if any. */
17371737
cleanup_mode == CLEANUP_SCISSORS)
17381738
strbuf_setlen(&sb, wt_status_locate_end(sb.buf, sb.len));
1739-
17401739
if (cleanup_mode != CLEANUP_NONE)
17411740
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) {
17431743
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"));
17451745
exit(1);
17461746
}
1747-
if (message_is_empty(&sb) && !allow_empty_message) {
1747+
if (template_untouched(&sb) && !allow_empty_message) {
17481748
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"));
17501750
exit(1);
17511751
}
17521752

0 commit comments

Comments
 (0)