# [PATCH] send-email: use catfile() to concatenate files

5 messages from 2010-09-14 to 2010-09-14. Participants: Ævar Arnfjörð Bjarmason, Junio C Hamano, Jakub Narebski.
Thread: https://gitlist.dev/t/25102

## Ævar Arnfjörð Bjarmason, 2010-09-14 19:02

Subject: [PATCH] send-email: use catfile() to concatenate files
Message-ID: <1284490944-16964-1-git-send-email-avarab@gmail.com>
URL: https://gitlist.dev/e/1284490944-16964-1-git-send-email-avarab%40gmail.com

```
Change send-email to use Perl's catfile() function instead of
"$dir/$file". If send-email is given a $dir that ends with a / we'll
end up printing a double slashed path like "dir//mtfnpy.patch".

This doesn't cause any problems since Perl's IO layer will handle it,
but it looks ugly.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 git-send-email.perl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 6dab3bf..7f702e3 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -24,6 +24,7 @@ use Text::ParseWords;
 use Data::Dumper;
 use Term::ANSIColor;
 use File::Temp qw/ tempdir tempfile /;
+use File::Spec::Functions qw(catfile);
 use Error qw(:try);
 use Git;
 
@@ -511,7 +512,7 @@ while (defined(my $f = shift @ARGV)) {
 		opendir(DH,$f)
 			or die "Failed to opendir $f: $!";
 
-		push @files, grep { -f $_ } map { +$f . "/" . $_ }
+		push @files, grep { -f $_ } map { catfile($f, $_) }
 				sort readdir(DH);
 		closedir(DH);
 	} elsif ((-f $f or -p $f) and !check_file_rev_conflict($f)) {
-- 
1.7.3.rc1.234.g8dc15

```

## Junio C Hamano, 2010-09-14 19:26

Subject: Re: [PATCH] send-email: use catfile() to concatenate files
Message-ID: <7v7hio86tz.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7hio86tz.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1284490944-16964-1-git-send-email-avarab@gmail.com>

```
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> Change send-email to use Perl's catfile() function instead of
> "$dir/$file". If send-email is given a $dir that ends with a / we'll
> end up printing a double slashed path like "dir//mtfnpy.patch".
>
> This doesn't cause any problems since Perl's IO layer will handle it,
> but it looks ugly.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>

If you mentioned in the proposed log message that File::Spec::Functions
have been with us since Perl 5.6.1, it would have saved me (and others)
some time worrying about the portability issues.

>  git-send-email.perl |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 6dab3bf..7f702e3 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -24,6 +24,7 @@ use Text::ParseWords;
>  use Data::Dumper;
>  use Term::ANSIColor;
>  use File::Temp qw/ tempdir tempfile /;
> +use File::Spec::Functions qw(catfile);
>  use Error qw(:try);
>  use Git;
>  
> @@ -511,7 +512,7 @@ while (defined(my $f = shift @ARGV)) {
>  		opendir(DH,$f)
>  			or die "Failed to opendir $f: $!";
>  
> -		push @files, grep { -f $_ } map { +$f . "/" . $_ }
> +		push @files, grep { -f $_ } map { catfile($f, $_) }
>  				sort readdir(DH);
>  		closedir(DH);
>  	} elsif ((-f $f or -p $f) and !check_file_rev_conflict($f)) {
> -- 
> 1.7.3.rc1.234.g8dc15

```

## Ævar Arnfjörð Bjarmason, 2010-09-14 19:55

Subject: Re: [PATCH] send-email: use catfile() to concatenate files
Message-ID: <AANLkTim7y3qUqQ4TN4w9+5qwR-uLmCP=dTKnMUSnqUrP@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTim7y3qUqQ4TN4w9%2B5qwR-uLmCP%3DdTKnMUSnqUrP%40mail.gmail.com
In-Reply-To: <7v7hio86tz.fsf@alter.siamese.dyndns.org>

```
On Tue, Sep 14, 2010 at 19:26, Junio C Hamano <gitster@pobox.com> wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> Change send-email to use Perl's catfile() function instead of
>> "$dir/$file". If send-email is given a $dir that ends with a / we'll
>> end up printing a double slashed path like "dir//mtfnpy.patch".
>>
>> This doesn't cause any problems since Perl's IO layer will handle it,
>> but it looks ugly.
>>
>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>
> If you mentioned in the proposed log message that File::Spec::Functions
> have been with us since Perl 5.6.1, it would have saved me (and others)
> some time worrying about the portability issues.

I thought you might trust me to write portable code by default :)

Anyway, I forgot to mention it. But one can use the corelist(1)
program to see when what modules appeared in perl core:

    $ corelist File::Spec::Functions
    File::Spec::Functions was first released with perl 5.00504

```

## Jakub Narebski, 2010-09-14 20:35

Subject: Re: [PATCH] send-email: use catfile() to concatenate files
Message-ID: <m3iq28kqs4.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3iq28kqs4.fsf%40localhost.localdomain
In-Reply-To: <AANLkTim7y3qUqQ4TN4w9+5qwR-uLmCP=dTKnMUSnqUrP@mail.gmail.com>

```
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> On Tue, Sep 14, 2010 at 19:26, Junio C Hamano <gitster@pobox.com> wrote:
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>
>>> Change send-email to use Perl's catfile() function instead of
>>> "$dir/$file". If send-email is given a $dir that ends with a / we'll
>>> end up printing a double slashed path like "dir//mtfnpy.patch".
>>>
>>> This doesn't cause any problems since Perl's IO layer will handle it,
>>> but it looks ugly.
>>>
>>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>>
>> If you mentioned in the proposed log message that File::Spec::Functions
>> have been with us since Perl 5.6.1, it would have saved me (and others)
>> some time worrying about the portability issues.
> 
> I thought you might trust me to write portable code by default :)
> 
> Anyway, I forgot to mention it. But one can use the corelist(1)
> program to see when what modules appeared in perl core:
> 
>     $ corelist File::Spec::Functions
>     File::Spec::Functions was first released with perl 5.00504

Also using File::Spec / File::Spec::Functions makes code more portable
(with respect to things such as different directory separators, and
volume portion of pathname) than using "$dir/$file".

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Ævar Arnfjörð Bjarmason, 2010-09-14 20:42

Subject: Re: [PATCH] send-email: use catfile() to concatenate files
Message-ID: <AANLkTikEe_KNmXUmTtVSRjKy4QbhAmSJ9jXz2y0dO9Em@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikEe_KNmXUmTtVSRjKy4QbhAmSJ9jXz2y0dO9Em%40mail.gmail.com
In-Reply-To: <m3iq28kqs4.fsf@localhost.localdomain>

```
On Tue, Sep 14, 2010 at 20:35, Jakub Narebski <jnareb@gmail.com> wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>> On Tue, Sep 14, 2010 at 19:26, Junio C Hamano <gitster@pobox.com> wrote:
>>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>>
>>>> Change send-email to use Perl's catfile() function instead of
>>>> "$dir/$file". If send-email is given a $dir that ends with a / we'll
>>>> end up printing a double slashed path like "dir//mtfnpy.patch".
>>>>
>>>> This doesn't cause any problems since Perl's IO layer will handle it,
>>>> but it looks ugly.
>>>>
>>>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>>>
>>> If you mentioned in the proposed log message that File::Spec::Functions
>>> have been with us since Perl 5.6.1, it would have saved me (and others)
>>> some time worrying about the portability issues.
>>
>> I thought you might trust me to write portable code by default :)
>>
>> Anyway, I forgot to mention it. But one can use the corelist(1)
>> program to see when what modules appeared in perl core:
>>
>>     $ corelist File::Spec::Functions
>>     File::Spec::Functions was first released with perl 5.00504
>
> Also using File::Spec / File::Spec::Functions makes code more portable
> (with respect to things such as different directory separators, and
> volume portion of pathname) than using "$dir/$file".

Right, but perl mitigates that to some extent by converting Unix paths
on-the-fly
to whatever the native platform uses. But of course that falls down in
cases like Win32
volume labels.

```
