* [PATCH v2] Make git send-email accept $EDITOR with arguments
2007-12-20 20:32 [PATCH] " Luciano Rocha
@ 2007-12-21 11:36 ` Gustaf Hendeby
2007-12-21 13:34 ` Jeff King
2007-12-21 17:02 ` Junio C Hamano
0 siblings, 2 replies; 8+ messages in thread
From: Gustaf Hendeby @ 2007-12-21 11:36 UTC (permalink / raw)
To: luciano; +Cc: git, gitster, Gustaf Hendeby
Currently git send-email does not accept $EDITOR with arguments, eg,
emacs -nw, when starting an editor to produce a cover letter. This
fix uses perl's implicit splitting to perform the task and that should
hopefully cover most interesting cases.
Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
---
Thanks to Luciano for the tip to use the internal splitting in perl,
that should be a better solution than to split on all spaces. I don't
think it is necessary, though, to add an extra error message if the
system call fails, system in it self already produces something that
should be clear enough. If anyone got a strong oppinion for another
error message I'll fix that.
Junio, even if this is technically not a bug fix, it would be nice to
get this fix into the 1.5.4 so that the usage of $EDITOR becomes more
consistent throughout git.
/Gustaf
git-send-email.perl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 248d035..5764668 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -400,7 +400,7 @@ EOT
close(C);
my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
- system($editor, $compose_filename);
+ system("$editor $compose_filename");
open(C2,">",$compose_filename . ".final")
or die "Failed to open $compose_filename.final : " . $!;
--
1.5.4.rc1.4.gb8173-dirty
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
2007-12-21 11:36 ` [PATCH v2] " Gustaf Hendeby
@ 2007-12-21 13:34 ` Jeff King
2007-12-21 15:23 ` Gustaf Hendeby
2007-12-21 17:02 ` Junio C Hamano
1 sibling, 1 reply; 8+ messages in thread
From: Jeff King @ 2007-12-21 13:34 UTC (permalink / raw)
To: Gustaf Hendeby; +Cc: luciano, git, gitster
On Fri, Dec 21, 2007 at 12:36:42PM +0100, Gustaf Hendeby wrote:
> - system($editor, $compose_filename);
> + system("$editor $compose_filename");
If you are going to do it that way, I suspect you want to quotemeta
$compose_filename.
-Peff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
2007-12-21 13:34 ` Jeff King
@ 2007-12-21 15:23 ` Gustaf Hendeby
2007-12-21 19:23 ` Jeff King
0 siblings, 1 reply; 8+ messages in thread
From: Gustaf Hendeby @ 2007-12-21 15:23 UTC (permalink / raw)
To: Jeff King; +Cc: luciano, git, gitster
On 12/21/2007 02:34 PM, Jeff King wrote:
> On Fri, Dec 21, 2007 at 12:36:42PM +0100, Gustaf Hendeby wrote:
>
>> - system($editor, $compose_filename);
>> + system("$editor $compose_filename");
>
> If you are going to do it that way, I suspect you want to quotemeta
> $compose_filename.
>
> -Peff
Generally that would be true, but is that really necessary when I know
$compose_filename is defined as:
my $compose_filename = ".msg.$$";
Or, should I take it that you prefer the version using split? I didn't
really feel good about the possibility of splitting paths with spaces
that came with that one though.
/Gustaf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
2007-12-21 11:36 ` [PATCH v2] " Gustaf Hendeby
2007-12-21 13:34 ` Jeff King
@ 2007-12-21 17:02 ` Junio C Hamano
1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2007-12-21 17:02 UTC (permalink / raw)
To: Gustaf Hendeby; +Cc: luciano, git, gitster
Gustaf Hendeby <hendeby@isy.liu.se> writes:
> Junio, even if this is technically not a bug fix, it would be nice to
> get this fix into the 1.5.4 so that the usage of $EDITOR becomes more
> consistent throughout git.
I can buy that, but at least a single line comment in front of that
system() explaining why this is safe to do so would be beneficial. I
suspect that somebody would propose moving $compse_filename inside
$GIT_DIR, now people realized $compose_filename is currently "./.msg.$$",
and $GIT_DIR could be anything. Quotemeta would probably be better as the
code you are touching won't be affected by a future change to the value of
that constant defined far away in the source.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
2007-12-21 15:23 ` Gustaf Hendeby
@ 2007-12-21 19:23 ` Jeff King
2007-12-21 21:07 ` Gustaf Hendeby
0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2007-12-21 19:23 UTC (permalink / raw)
To: Gustaf Hendeby; +Cc: luciano, git, gitster
On Fri, Dec 21, 2007 at 04:23:11PM +0100, Gustaf Hendeby wrote:
> > If you are going to do it that way, I suspect you want to quotemeta
> > $compose_filename.
> Generally that would be true, but is that really necessary when I know
> $compose_filename is defined as:
>
> my $compose_filename = ".msg.$$";
I know; it is just easier to see that it is correct with the quotemeta
(and correct in the face of somebody changing the message later).
> Or, should I take it that you prefer the version using split? I didn't
> really feel good about the possibility of splitting paths with spaces
> that came with that one though.
I am fine with using the shell. Though keep in mind that the two
solutions will behave differently with
EDITOR='foo; bar'
That is, system("$editor $message") will actually invoke the shell,
whereas system(split(/ /, $editor), $message) will _just_ split on
whitespace. We should do whatever is consistent with the rest of the git
commands (off the top of my head, I don't know).
-Peff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
2007-12-21 19:23 ` Jeff King
@ 2007-12-21 21:07 ` Gustaf Hendeby
2007-12-21 21:17 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Gustaf Hendeby @ 2007-12-21 21:07 UTC (permalink / raw)
To: Jeff King; +Cc: luciano, git, gitster
[-- Attachment #1: Type: text/plain, Size: 1490 bytes --]
On 2007-12-21 20:23, Jeff King wrote:
> On Fri, Dec 21, 2007 at 04:23:11PM +0100, Gustaf Hendeby wrote:
>
>>> If you are going to do it that way, I suspect you want to quotemeta
>>> $compose_filename.
>> Generally that would be true, but is that really necessary when I know
>> $compose_filename is defined as:
>>
>> my $compose_filename = ".msg.$$";
>
> I know; it is just easier to see that it is correct with the quotemeta
> (and correct in the face of somebody changing the message later).
Point taken!
>
>> Or, should I take it that you prefer the version using split? I didn't
>> really feel good about the possibility of splitting paths with spaces
>> that came with that one though.
>
> I am fine with using the shell. Though keep in mind that the two
> solutions will behave differently with
>
> EDITOR='foo; bar'
>
> That is, system("$editor $message") will actually invoke the shell,
> whereas system(split(/ /, $editor), $message) will _just_ split on
> whitespace. We should do whatever is consistent with the rest of the git
> commands (off the top of my head, I don't know).
A quick look at the proposed solution to the similar problem with git
commit, using code now in git tag, it seems it uses a split like
solution, though taking " and ' quoting into consideration. On the top
of my head I can't come up with any other commands using $EDITOR. I'll
try to find some time the next couple of days to make a reasonable
equivalent solution here.
Thanks,
Gustaf
[-- Attachment #2: hendeby.vcf --]
[-- Type: text/x-vcard, Size: 378 bytes --]
begin:vcard
fn:Gustaf Hendeby
n:Hendeby;Gustaf
org;quoted-printable:Link=C3=B6ping University;Department of Electrical Engineering
adr;quoted-printable:;;;Link=C3=B6ping;;SE-581 83;Sweden
email;internet:hendeby@isy.liu.se
title:PhD Student
tel;work:+46 (0)13 282226
tel;fax:+46 (0)13 282622
x-mozilla-html:FALSE
url:http://www.control.isy.liu.se/~hendeby
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
2007-12-21 21:07 ` Gustaf Hendeby
@ 2007-12-21 21:17 ` Junio C Hamano
0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2007-12-21 21:17 UTC (permalink / raw)
To: Gustaf Hendeby; +Cc: Jeff King, luciano, git, gitster
Gustaf Hendeby <hendeby@isy.liu.se> writes:
> On 2007-12-21 20:23, Jeff King wrote:
>
>> I am fine with using the shell. Though keep in mind that the two
>> solutions will behave differently with
>>
>> EDITOR='foo; bar'
>>
>> That is, system("$editor $message") will actually invoke the shell,
>> whereas system(split(/ /, $editor), $message) will _just_ split on
>> whitespace. We should do whatever is consistent with the rest of the git
>> commands (off the top of my head, I don't know).
Personally, I think EDITOR='foo; bar' is a user shooting his
foot off which we do not care about.
> A quick look at the proposed solution to the similar problem with git
> commit, using code now in git tag, it seems it uses a split like
> solution, though taking " and ' quoting into consideration.
I think the easiest to read and compatible way is:
system('sh', '-c', '$0 $@', $editor, $filename)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
@ 2007-12-21 21:37 Gustaf Hendeby
0 siblings, 0 replies; 8+ messages in thread
From: Gustaf Hendeby @ 2007-12-21 21:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: luciano, git
Sorry Junio for the double, but I didn't mean to cut the CCs on this one.
On 2007-12-21 18:02, Junio C Hamano wrote:
> Gustaf Hendeby <hendeby@isy.liu.se> writes:
>
>> Junio, even if this is technically not a bug fix, it would be nice to
>> get this fix into the 1.5.4 so that the usage of $EDITOR becomes more
>> consistent throughout git.
>
> I can buy that, but at least a single line comment in front of that
> system() explaining why this is safe to do so would be beneficial. I
> suspect that somebody would propose moving $compse_filename inside
> $GIT_DIR, now people realized $compose_filename is currently "./.msg.$$",
> and $GIT_DIR could be anything. Quotemeta would probably be better as the
> code you are touching won't be affected by a future change to the value of
> that constant defined far away in the source.
Moving that file makes sense, I'll have a look at that, and do that as
well when I fix this patch. After a first look at it though, I was
surprised to learn that git send-email actually wont work outside a
repository. Ok, I can't really see any workflow where git send-email is
called from outside a git repository, but at the same time I don't see
why is should not be possible. Are there any special reason for this?
Thanks,
Gustaf
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-12-21 21:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-21 21:37 [PATCH v2] Make git send-email accept $EDITOR with arguments Gustaf Hendeby
-- strict thread matches above, loose matches on Subject: below --
2007-12-20 20:32 [PATCH] " Luciano Rocha
2007-12-21 11:36 ` [PATCH v2] " Gustaf Hendeby
2007-12-21 13:34 ` Jeff King
2007-12-21 15:23 ` Gustaf Hendeby
2007-12-21 19:23 ` Jeff King
2007-12-21 21:07 ` Gustaf Hendeby
2007-12-21 21:17 ` Junio C Hamano
2007-12-21 17:02 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).