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

Re: [PATCH 3/3] commit: give a hint when a commit message has been abandoned

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 23, 2012, 21:35 UTC
Message-ID
<7veho2jh4q.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120723211312.GA12533@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 39 quoted lines
> Here's a documentation patch.
>
> -- >8 --
> Subject: [PATCH] commit: document the temporary commit message file
>
> We do not document COMMIT_EDITMSG at all, but users may want
> to know about it for two reasons:
>
>   1. They may want to tell their editor to configure itself
>      for formatting a commit message.
>
>   2. If a commit is aborted by an error, the user may want
>      to recover the commit message they typed.
>
> Let's put a note in git-commit(1).
> ---
>  Documentation/git-commit.txt | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
> index f400835..87297dc 100644
> --- a/Documentation/git-commit.txt
> +++ b/Documentation/git-commit.txt
> @@ -407,6 +407,15 @@ This command can run `commit-msg`, `prepare-commit-msg`, `pre-commit`,
>  and `post-commit` hooks.  See linkgit:githooks[5] for more
>  information.
>  
> +FILES
> +-----
> +
> +`$GIT_DIR/COMMIT_EDITMSG`::
> +	This file contains the commit message of a commit in progress.
> +	If `git-commit` exits due to an error before creating a commit,
> +	any commit message that has been provided by the user (e.g., in
> +	an editor session) will be available in this file, but will be
> +	overwritten by the next invocation of `git-commit`.
>  
>  SEE ALSO
>  --------
Very sensible, modulo s/git-commit/git commit/ and lack of S-o-b.

I also wondered if something like the following might be useful, but it probably falls into the "water under the bridge" category.

 builtin/commit.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/builtin/commit.c b/builtin/commit.c
index 149e07d..83bcee4 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -768,6 +768,11 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 				"with '#' will be kept; you may remove them"
 				" yourself if you want to.\n"
 				"An empty message aborts the commit.\n"));
+		status_printf(s, GIT_COLOR_NORMAL,
+			      _("The file '%s' keeps a copy of the log message\n"
+				"you edited, if you wish to inspect it later.\n"
+				"It will be wiped by the next invocation of 'git commit'.\n"),
+			      git_path("COMMIT_EDITMSG"));
 		if (only_include_assumed)
 			status_printf_ln(s, GIT_COLOR_NORMAL,
 					"%s", only_include_assumed);
Previous: Jeff KingNext: Jeff King
Message 14 of 16 in “Re: empty ident name trashes commit message”
  1. Ramana KumarJul 21, 2012
  2. Jeff KingJul 23, 2012
  3. Ramana KumarJul 23, 2012
  4. Jeff KingJul 23, 2012
  5. 1/3 advice: pass varargs to strbuf_vaddf, not strbuf_addfJeff King, Jul 23, 2012
  6. 2/3 commit: check committer identity more strictlyJeff King, Jul 23, 2012
  7. Junio C HamanoJul 23, 2012
  8. Jeff KingJul 23, 2012
  9. 3/3 commit: give a hint when a commit message has been abandonedJeff King, Jul 23, 2012
  10. Junio C HamanoJul 23, 2012
  11. Jeff KingJul 23, 2012
  12. Junio C HamanoJul 23, 2012
  13. Jeff KingJul 23, 2012
  14. Junio C HamanoJul 23, 2012
  15. Jeff KingJul 23, 2012
  16. Junio C HamanoJul 23, 2012

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.