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


  # [...]
  # 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 ran.

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 edition 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 <>
Junio, you'll get a trivial merge conflict with my other status
series, as they both add a few lines of code at the same location.
There should be no semantic conflict so I didn't consider the branches
as dependant.

 builtin/commit.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/builtin/commit.c b/builtin/commit.c
index 388acde..6251d29 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -702,6 +702,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);

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to