Skip to content

Commit

Permalink
send-email: lazily assign editor variable
Browse files Browse the repository at this point in the history
b4479f0 (add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR",
2009-10-30) introduced the use of "git var GIT_EDITOR" to obtain the
preferred editor program, instead of reading environment variables
themselves.

However, "git var GIT_EDITOR" run without a tty (think "cron job") would
give a fatal error "Terminal is dumb, but EDITOR unset".  This is not a
problem for add-i, svn, p4 and callers of git_editor() defined in
git-sh-setup, as all of these call it just before launching the editor.
At that point, we know the caller wants to edit.

But send-email ran this near the beginning of the program, even if it is
not going to use any editor (e.g. run without --compose).  Fix this by
calling the command only when we edit a file.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Mar 25, 2010
1 parent a3d023d commit 0ce142c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,12 @@ sub format_2822_time {

# Handle interactive edition of files.
my $multiedit;
my $editor = Git::command_oneline('var', 'GIT_EDITOR');
my $editor;

sub do_edit {
if (!defined($editor)) {
$editor = Git::command_oneline('var', 'GIT_EDITOR');
}
if (defined($multiedit) && !$multiedit) {
map {
system('sh', '-c', $editor.' "$@"', $editor, $_);
Expand Down

0 comments on commit 0ce142c

Please sign in to comment.