Skip to content

Commit ea9882b

Browse files
moygitster
authored andcommitted
commit: disable status hints when writing to COMMIT_EDITMSG
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a964f5 commit ea9882b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

builtin/commit.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
705705
if (s->fp == NULL)
706706
die_errno(_("could not open '%s'"), git_path(commit_editmsg));
707707

708+
/*
709+
* Most hints are counter-productive when the commit has
710+
* already started.
711+
*/
712+
s->hints = 0;
713+
708714
if (clean_message_contents)
709715
stripspace(&sb, 0);
710716

0 commit comments

Comments
 (0)