git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [PATCH] send-email: do not check for editor until needed

From
Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Date
Mar 23, 2010, 09:15 UTC
Message-ID
<A612847CFE53224C91B23E3A5B48BAC73EC0B01EE8@xmail3.se.axis.com>
In-Reply-To
<20100322232531.GA2168@progeny.tock>
Show 65 quoted lines
> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Jonathan Nieder
> Sent: den 23 mars 2010 00:26
> To: Uwe Kleine-König
> Cc: git@vger.kernel.org; Junio C Hamano; Marc Kleine-Budde; Jay Soffian
> Subject: [PATCH] send-email: do not check for editor until needed
> 
> Since b4479f074 (add -i, send-email, svn, p4, etc: use "git var
> GIT_EDITOR", 2009-10-30), when called with TERM=dumb and without
> GIT_EDITOR set, git send-email has been failing whether it needs
> an editor or not:
> 
>  $ ssh localhost git send-email --to=me --suppress-cc=all HEAD^..HEAD
>  fatal: Terminal is dumb, but EDITOR unset
>  var GIT_EDITOR: command returned error: 128
> 
> This breaks use of git send-email in existing hook scripts.
> 
> So do not check for an editor unless it is needed.
> 
> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> Uwe Kleine-König wrote:
> 
> > since b4479f074760a788dd4e353b8c86a7d735afc53e git send-email (and
> > others) use git var GIT_EDITOR.  This is OK as such but it breaks the
> > post-receive hooks that I use on several repositories.
> [...]
> > IMHO git send-email should only call $(git var GIT_EDITOR) when it
> > actually needs it.
> 
> Thanks for reporting.  Does this patch work for you?
> 
> Now if I try without a tty, I get a different error:
> 
>  $ ssh localhost cd $(pwd) '&&' \
> 	git send-email --to=me --suppress-cc=all HEAD^..HEAD
>  Can't locate object method "IN" via package "FakeTerm" at
>  /home/jrn/tmp-git/libexec/git-core/git-send-email line 645.
>  /tmp/olTiwjzrjx/0001-Git-1.7.0.3.patch
> 
> I assume I am not using it correctly, since the relevant code has
> been around for a while.
> 
>  git-send-email.perl |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index e05455f..9406cdd 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -162,9 +162,16 @@ my $compose_filename;
> 
>  # Handle interactive edition of files.
>  my $multiedit;
> -my $editor = Git::command_oneline('var', 'GIT_EDITOR');
> 
>  sub do_edit {
> +	my $editor;
> +
> +	if ($#_ == 0) {
> +		return;
> +	}
Shouldn't that be:
	if ($#_ == -1) {
		return;
	}
or more readable:
	return if (!@_);

as I assume you are trying to protect do_edit() from being called without arguments?

Show 13 quoted lines
> +	git_cmd_try {
> +		$editor = Git::command_oneline('var', 'GIT_EDITOR');
> +	} "no suitable text editor configured\n";
>  	if (defined($multiedit) && !$multiedit) {
>  		map {
>  			system('sh', '-c', $editor.' "$@"', $editor, $_);
> --
> 1.7.0.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
//Peter
Previous: Jonathan NiederNext: Jonathan Nieder
Message 13 of 14 in “[REGRESSION] git var GIT_EDITOR fails without tty”
  1. Uwe Kleine-KönigMar 22, 2010
  2. send-email: lazily assign editor variableMichael J Gruber, Mar 22, 2010
  3. Uwe Kleine-KönigMar 22, 2010
  4. Jonathan NiederMar 23, 2010
  5. Michael J GruberMar 23, 2010
  6. Junio C HamanoMar 24, 2010
  7. Jonathan NiederMar 25, 2010
  8. Junio C HamanoMar 26, 2010
  9. Jonathan NiederMar 26, 2010
  10. Michael J GruberMar 25, 2010
  11. Junio C HamanoMar 26, 2010
  12. send-email: do not check for editor until neededJonathan Nieder, Mar 22, 2010
  13. Peter KjellerstedtMar 23, 2010
  14. Jonathan NiederMar 23, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.