git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] commit: check for empty message before the check for untouched template

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 17, 2017, 20:12 UTC
Message-ID
<xmqqh8yahlgt.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170717153615.16252-1-kaarticsivaraam91196@gmail.com>
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:
Show 14 quoted lines
> 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>
> ---
>  builtin/commit.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
Makes sense to me.
Show 30 quoted lines
> diff --git a/builtin/commit.c b/builtin/commit.c
> index aff6bf7aa..9c299d792 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1736,19 +1736,19 @@ 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) {
> -		rollback_index_files();
> -		fprintf(stderr, _("Aborting commit; you did not edit the message.\n"));
> -		exit(1);
> -	}
> +
>  	if (message_is_empty(&sb) && !allow_empty_message) {
>  		rollback_index_files();
>  		fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
>  		exit(1);
>  	}
> +	if (template_untouched(&sb) && !allow_empty_message) {
> +		rollback_index_files();
> +		fprintf(stderr, _("Aborting commit; you did not edit the message.\n"));
> +		exit(1);
> +	}
>  
>  	if (amend) {
>  		const char *exclude_gpgsig[2] = { "gpgsig", NULL };
Previous: Kaartic Sivaraam
Message 2 of 2 in “commit: check for empty message before the check for untouched template”
  1. commit: check for empty message before the check for untouched templateKaartic Sivaraam, Jul 17, 2017
  2. Junio C HamanoJul 17, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.