Re: [PATCH 1/1] Use correct /dev/null for UNIX and Windows
- From
Chris Webster <chris@webstech.net>
- Date
- Oct 31, 2018, 05:41 UTC
- Message-ID
- <CAGT1KpWC_+=u7fCzQJsU8d_gSQzE5rsx46cTXogvaRPHZ1iiHw@mail.gmail.com>
- In-Reply-To
- <CAGT1KpWoGD0xgTrC-+X1WqY_M=2arYbs4ZX6Nnj-zHK6mgu+nw@mail.gmail.com>
Resending in text mode.
On Tue, Oct 30, 2018 at 10:20 PM Chris Webster <chris@webstech.net> wrote:
Show 22 quoted lines
> > On Tue, Oct 30, 2018 at 9:54 PM Junio C Hamano <gitster@pobox.com> wrote: >> >> "chris via GitGitGadget" <gitgitgadget@gmail.com> writes: >> >> > From: chris <chris@webstech.net> >> > >> > Use File::Spec->devnull() for output redirection to avoid messages >> > when Windows version of Perl is first in path. The message 'The >> >> Dscho, "Windows version of Perl is first in path" somehow feels >> contradicting with what one of the topics I saw from you were trying >> to enforce (or, at least, "set as the supported configuration"). >> >> I am guessing that the Perl you are building and shipping with Git >> for Windows would yield what the shell that ends up running the >> scriptlet `git config --get-color $key` prefers when asked for >> File::Spec->devnull(), and nothing will break with this patch even >> if that is "/dev/null", but I thought I'd double check. >> >> Thanks. >>
This problem originally showed up in the https://github.com/so-fancy/diff-so-fancy project, which has a copy of DiffHighlight.pm. That project allows diffsofancy (perl) to be run from the command line without requiring the bash environment ((well , sort of) including the associated perl).
Show 33 quoted lines
>
>> > system cannot find the path specified.' is displayed each time git is
>> > run to get colors.
>> >
>> > Signed-off-by: Chris. Webster <chris@webstech.net>
>> > ---
>> > contrib/diff-highlight/DiffHighlight.pm | 7 ++++++-
>> > 1 file changed, 6 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/contrib/diff-highlight/DiffHighlight.pm b/contrib/diff-highlight/DiffHighlight.pm
>> > index 536754583..7440aa1c4 100644
>> > --- a/contrib/diff-highlight/DiffHighlight.pm
>> > +++ b/contrib/diff-highlight/DiffHighlight.pm
>> > @@ -4,6 +4,11 @@ use 5.008;
>> > use warnings FATAL => 'all';
>> > use strict;
>> >
>> > +# Use the correct value for both UNIX and Windows (/dev/null vs nul)
>> > +use File::Spec;
>> > +
>> > +my $NULL = File::Spec->devnull();
>> > +
>> > # Highlight by reversing foreground and background. You could do
>> > # other things like bold or underline if you prefer.
>> > my @OLD_HIGHLIGHT = (
>> > @@ -134,7 +139,7 @@ sub highlight_stdin {
>> > # fallback, which means we will work even if git can't be run.
>> > sub color_config {
>> > my ($key, $default) = @_;
>> > - my $s = `git config --get-color $key 2>/dev/null`;
>> > + my $s = `git config --get-color $key 2>$NULL`;
>> > return length($s) ? $s : $default;
>> > }