summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris. Webster <chris@webstech.net>2018-10-31 14:58:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-09 03:18:44 (GMT)
commit6804ba3a58ff2999533af28ca5af3901e30fd1f2 (patch)
treebb9cefd463f6a3daec88476a30bdc9b6a357f376
parent8104ec994ea3849a968b4667d072fedd1e688642 (diff)
downloadgit-6804ba3a58ff2999533af28ca5af3901e30fd1f2.zip
git-6804ba3a58ff2999533af28ca5af3901e30fd1f2.tar.gz
git-6804ba3a58ff2999533af28ca5af3901e30fd1f2.tar.bz2
diff-highlight: use correct /dev/null for UNIX and Windows
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>
-rw-r--r--contrib/diff-highlight/DiffHighlight.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/contrib/diff-highlight/DiffHighlight.pm b/contrib/diff-highlight/DiffHighlight.pm
index 5367545..7440aa1 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;
}