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

[PATCH v2 3/3] commit: disable status hints when writing to COMMIT_EDITMSG

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Sep 12, 2013, 10:50 UTC
Message-ID
<1378983006-3980-3-git-send-email-Matthieu.Moy@imag.fr>
In-Reply-To
<1378983006-3980-1-git-send-email-Matthieu.Moy@imag.fr>
This turns the template COMMIT_EDITMSG from e.g
  # [...]
  # Changes to be committed:
  #   (use "git reset HEAD <file>..." to unstage)
  #
  #	modified:   builtin/commit.c
  #
  # Untracked files:
  #   (use "git add <file>..." to include in what will be committed)
  #
  #	t/foo
  #
to
  # [...]
  # Changes to be committed:
  #	modified:   builtin/commit.c
  #
  # Untracked files:
  #	t/foo
  #

Most status hints were written to be accurate when running "git status" before running a commit. Many of them are not applicable when the commit has already been started, and should not be shown in COMMIT_EDITMSG. The most obvious are hints advising to run "git commit", "git rebase/am/cherry-pick --continue", which do not make sense when the command has already been run.

Other messages become slightly inaccurate (e.g. hint to use "git add" to add untracked files), as the suggested commands are not immediately applicable during the editing of COMMIT_EDITMSG, but would be applicable if the commit is aborted. These messages are both potentially helpful and slightly misleading. This patch chose to remove them too, to avoid introducing too much complexity in the status code.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Unchanged since v1.
 builtin/commit.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/builtin/commit.c b/builtin/commit.c
index 7bfce94..e32246a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -705,6 +705,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	if (s->fp == NULL)
 		die_errno(_("could not open '%s'"), git_path(commit_editmsg));
 
+	/*
+	 * Most hints are counter-productive when the commit has
+	 * already started.
+	 */
+	s->hints = 0;
+
 	if (clean_message_contents)
 		stripspace(&sb, 0);
 
-- 
1.8.4.8.g834017f
Previous: Matthieu Moy
Message 3 of 3 in “commit: factor status configuration is a helper function”
  1. 1/3 commit: factor status configuration is a helper functionMatthieu Moy, Sep 12, 2013
  2. 2/3 wt-status: turn advice_status_hints into a field of wt_statusMatthieu Moy, Sep 12, 2013
  3. 3/3 commit: disable status hints when writing to COMMIT_EDITMSGMatthieu Moy, Sep 12, 2013

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.