diff-highlight: use correct /dev/null for UNIX and Windows
authorChris. Webster <chris@webstech.net>
Wed, 31 Oct 2018 14:58:00 +0000 (23:58 +0900)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 May 2019 03:18:44 +0000 (12:18 +0900)
Use File::Spec->devnull() for output redirection to avoid messages
when Windows version of Perl is first in path. The message 'The
system cannot find the path specified.' is displayed each time git is
run to get colors.

Signed-off-by: Chris. Webster <chris@webstech.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/diff-highlight/DiffHighlight.pm
index 536754583b59945e984ad487b6e524e5d1de7056..7440aa1c4638103c952c225f2c9b77d8c9451b08 100644 (file)
@@ -4,6 +4,11 @@ package DiffHighlight;
 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;
 }