Skip to content

Commit

Permalink
git-commit: set GIT_EDITOR=: if editor will not be launched
Browse files Browse the repository at this point in the history
This is a preparatory patch that provides a simple way for the future
prepare-commit-msg hook to discover if the editor will be launched.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Paolo Bonzini authored and Junio C Hamano committed Feb 6, 2008
1 parent 3473f30 commit 406400c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Documentation/hooks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ The default 'pre-commit' hook, when enabled, catches introduction
of lines with trailing whitespaces and aborts the commit when
such a line is found.

All the `git-commit` hooks are invoked with the environment
variable `GIT_EDITOR=:` if the command will not bring up an editor
to modify the commit message.

commit-msg
----------

Expand Down
2 changes: 2 additions & 0 deletions builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
use_editor = 0;
if (edit_flag)
use_editor = 1;
if (!use_editor)
setenv("GIT_EDITOR", ":", 1);

if (get_sha1("HEAD", head_sha1))
initial_commit = 1;
Expand Down

0 comments on commit 406400c

Please sign in to comment.