Skip to content

Commit 0ce142c

Browse files
Michael J Grubergitster
authored andcommitted
send-email: lazily assign editor variable
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 <[email protected]> Signed-off-by: Michael J Gruber <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Acked-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a3d023d commit 0ce142c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

git-send-email.perl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,12 @@ sub format_2822_time {
162162

163163
# Handle interactive edition of files.
164164
my $multiedit;
165-
my $editor = Git::command_oneline('var', 'GIT_EDITOR');
165+
my $editor;
166166

167167
sub do_edit {
168+
if (!defined($editor)) {
169+
$editor = Git::command_oneline('var', 'GIT_EDITOR');
170+
}
168171
if (defined($multiedit) && !$multiedit) {
169172
map {
170173
system('sh', '-c', $editor.' "$@"', $editor, $_);

0 commit comments

Comments
 (0)