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

Re* [PATCH] send-email: recognize absolute path on Windows

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 15, 2014, 16:57 UTC
Message-ID
<xmqq61maledq.fsf_-_@gitster.dls.corp.google.com>
In-Reply-To
<CABPQNSafmC-7zNJZJSZm598pF37_xUMUopgZ3c=ttL_wRDYsfQ@mail.gmail.com>
Erik Faye-Lund <kusmabite@gmail.com> writes:
Show 15 quoted lines
>>> Here's a patch that we've been running with a variation of in
>>> Git for Windows for a while. That version wasn't quite palatable,
>>> as it recognized DOS drive-prefixes on all platforms.
>>
>> Did you consider patching msysgit's lib/perl5/5.8.8/File/Spec.pm by
>> inserting a line "msys => 'Win32'," near the top of the file; it is the
>> hash table that decides which path "style" is selected depending on $^O.
>> Then File::Spec->file_name_is_absolute($path) could be used without a wrapper.
>
> I did not, but that works, and is IMO much nicer. Thanks for the idea!
> ...
>> There's another instance in the non-$quiet code path around line 1275 that
>> needs the same treatment.
>
> Good catch, thanks!
Thanks, both.  I'd expect another round then?
-- >8 --
From: Erik Faye-Lund <kusmabite@googlemail.com>

On Windows, absolute paths might start with a DOS drive prefix, which these checks fail to recognize.

Use file_name_is_absolute from File::Spec::Functions for portability. The Perl module msysgit has been shipping needs to be updated for this patch to work, though.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Helepd-by: Johannes Sixt <j6t@kdbg.org>
---
 git-send-email.perl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index fdb0029..eda3917 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -25,7 +25,7 @@
 use Data::Dumper;
 use Term::ANSIColor;
 use File::Temp qw/ tempdir tempfile /;
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile file_name_is_absolute);
 use Error qw(:try);
 use Git;
 
@@ -1197,7 +1197,7 @@ sub send_message {
 
 	if ($dry_run) {
 		# We don't want to send the email.
-	} elsif ($smtp_server =~ m#^/#) {
+	} elsif (file_name_is_absolute($smtp_server)) {
 		my $pid = open my $sm, '|-';
 		defined $pid or die $!;
 		if (!$pid) {
@@ -1271,7 +1271,7 @@ sub send_message {
 		printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
 	} else {
 		print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
-		if ($smtp_server !~ m#^/#) {
+		if (file_name_is_absolute($smtp_server)) {
 			print "Server: $smtp_server\n";
 			print "MAIL FROM:<$raw_from>\n";
 			foreach my $entry (@recipients) {
-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Previous: Erik Faye-LundNext: Junio C Hamano
Message 4 of 8 in “send-email: recognize absolute path on Windows”
  1. send-email: recognize absolute path on WindowsErik Faye-Lund, Apr 15, 2014
  2. Johannes SixtApr 15, 2014
  3. Erik Faye-LundApr 15, 2014
  4. Re* [PATCH] send-email: recognize absolute path on WindowsJunio C Hamano, Apr 15, 2014
  5. Junio C HamanoApr 15, 2014
  6. Erik Faye-LundApr 15, 2014
  7. Junio C HamanoApr 15, 2014
  8. Erik Faye-LundApr 15, 2014

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.