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

Re: [PATCH v2] Advertise the ability to abort a commit

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 29, 2008, 20:51 UTC
Message-ID
<7vfxpsct3f.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1217362342-30370-1-git-send-email-mail@cup.kalibalik.dk>
Anders Melchiorsen <mail@cup.kalibalik.dk> writes:
Show 12 quoted lines
> diff --git a/builtin-commit.c b/builtin-commit.c
> index 9a11ca0..75eeb4b 100644
> --- a/builtin-commit.c
> +++ b/builtin-commit.c
> @@ -555,6 +555,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
>  		fprintf(fp,
>  			"\n"
>  			"# Please enter the commit message for your changes.\n"
> +			"# To abort the commit, use an empty commit message.\n"
>  			"# (Comment lines starting with '#' will ");
>  		if (cleanup_mode == CLEANUP_ALL)
>  			fprintf(fp, "not be included)\n");
Thanks.  This sounds like a helpful message.
Show 9 quoted lines
> @@ -1003,7 +1004,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>  		stripspace(&sb, cleanup_mode == CLEANUP_ALL);
>  	if (sb.len < header_len || message_is_empty(&sb, header_len)) {
>  		rollback_index_files();
> -		die("no commit message?  aborting commit.");
> +		die("no commit message.  aborting commit.");
>  	}
>  	strbuf_addch(&sb, '\0');
>  	if (is_encoding_utf8(git_commit_encoding) && !is_utf8(sb.buf))
Sorry but I do not see a point in this hunk.

I am somewhere between neutral to mildly negative about changing "Abort with error and do not create a commit if there is no message" to "Do not create a commit if there is no message, and this condition is not an error". I further think the new message at the top is very helpful to the end users, with the understanding that users who changed their mind after running "git commit" _can_ deliberately trigger this _error condition_ to prevent commit from happening. I also agree this ability to trigger an error can be called a feature.

This still calls die(), which means this is still an error condition. I do not see a point in changing that question mark (which hints "perhaps you made a mistake, and that is the reason we are aborting") to a full stop. I think the current question mark is more helpful to people who did not pay close attention to the new message at the top.

If the change _were_ to reword the message to more neutral sounding "aborting commit due to missing log message.", and change die() to a normal exit, that would be making this not an error. As I already said, I am mildly negative, but at least such a change would be internally consistent.

I sense that the change from question mark to full stop might be showing the desire to go in that direction, but in that case your change from the question mark to full stop does not go far enough.

Previous: Anders MelchiorsenNext: Anders Melchiorsen
Message 3 of 19 in “Advertise the ability to abort a commit”
  1. Advertise the ability to abort a commitAnders Melchiorsen, Jul 29, 2008
  2. Advertise the ability to abort a commitAnders Melchiorsen, Jul 29, 2008
  3. Junio C HamanoJul 29, 2008
  4. Anders MelchiorsenJul 29, 2008
  5. Jeff KingJul 30, 2008
  6. Jeff KingJul 30, 2008
  7. Advertise the ability to abort a commitAnders Melchiorsen, Jul 30, 2008
  8. Brian GernhardtJul 30, 2008
  9. Avery PennarunJul 30, 2008
  10. Brian GernhardtJul 30, 2008
  11. Anders MelchiorsenJul 30, 2008
  12. Jeff KingJul 31, 2008
  13. Junio C HamanoJul 31, 2008
  14. Advertise the ability to abort a commitJeff King, Jul 31, 2008
  15. Jeff KingJul 31, 2008
  16. Petr BaudisJul 31, 2008
  17. Jeff KingJul 31, 2008
  18. Anders MelchiorsenJul 31, 2008
  19. Jeff KingJul 31, 2008

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.