mirror of
https://github.com/git/git.git
synced 2024-11-19 10:23:59 +01:00
d48b284183
Formalize our dependency on perl 5.8, bumped from 5.6.[12]. We already used the three-arg form of open() which was introduced in 5.6.1, but t/t9700/test.pl explicitly depended on 5.6.2. However git-add--interactive.pl has been failing on the 5.6 line since it was introduced in v1.5.0-rc0~12^2~2 back in 2006 due to this open syntax: sub run_cmd_pipe { my $fh = undef; open($fh, '-|', @_) or die; return <$fh>; } Which when executed dies on "Can't use an undefined value as filehandle reference". Several of our tests also fail on 5.6 (even more when compiled with NO_PERL_MAKEMAKER=1): t2016-checkout-patch.sh t3904-stash-patch.sh t3701-add-interactive.sh t7105-reset-patch.sh t7501-commit.sh t9700-perl-git.sh Our code is bitrotting on 5.6 with no-one interested in fixing it, and pinning us to such an ancient release of Perl is keeping us from using useful features introduced in the 5.8 release. The 5.6 series is now over 10 years old, and the 5.6.2 maintenance release almost 7. 5.8 on the other hand is more than 8 years old. All the modern Unix-like operating systems have now upgraded to it or a later version, and 5.8 packages are available for old IRIX, AIX Solaris and Tru64 systems. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Tor Arntsen <tor@spacetec.no> Acked-by: Randal L. Schwartz <merlyn@stonehenge.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
118 lines
2.6 KiB
Perl
Executable File
118 lines
2.6 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
# Copyright (c) 2009, 2010 David Aguilar
|
|
#
|
|
# This is a wrapper around the GIT_EXTERNAL_DIFF-compatible
|
|
# git-difftool--helper script.
|
|
#
|
|
# This script exports GIT_EXTERNAL_DIFF and GIT_PAGER for use by git.
|
|
# GIT_DIFFTOOL_NO_PROMPT, GIT_DIFFTOOL_PROMPT, and GIT_DIFF_TOOL
|
|
# are exported for use by git-difftool--helper.
|
|
#
|
|
# Any arguments that are unknown to this script are forwarded to 'git diff'.
|
|
|
|
use 5.008;
|
|
use strict;
|
|
use warnings;
|
|
use Cwd qw(abs_path);
|
|
use File::Basename qw(dirname);
|
|
|
|
require Git;
|
|
|
|
my $DIR = abs_path(dirname($0));
|
|
|
|
|
|
sub usage
|
|
{
|
|
print << 'USAGE';
|
|
usage: git difftool [-t|--tool=<tool>] [-x|--extcmd=<cmd>]
|
|
[-y|--no-prompt] [-g|--gui]
|
|
['git diff' options]
|
|
USAGE
|
|
exit 1;
|
|
}
|
|
|
|
sub setup_environment
|
|
{
|
|
$ENV{PATH} = "$DIR:$ENV{PATH}";
|
|
$ENV{GIT_PAGER} = '';
|
|
$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
|
|
}
|
|
|
|
sub exe
|
|
{
|
|
my $exe = shift;
|
|
if ($^O eq 'MSWin32' || $^O eq 'msys') {
|
|
return "$exe.exe";
|
|
}
|
|
return $exe;
|
|
}
|
|
|
|
sub generate_command
|
|
{
|
|
my @command = (exe('git'), 'diff');
|
|
my $skip_next = 0;
|
|
my $idx = -1;
|
|
for my $arg (@ARGV) {
|
|
$idx++;
|
|
if ($skip_next) {
|
|
$skip_next = 0;
|
|
next;
|
|
}
|
|
if ($arg eq '-t' || $arg eq '--tool') {
|
|
usage() if $#ARGV <= $idx;
|
|
$ENV{GIT_DIFF_TOOL} = $ARGV[$idx + 1];
|
|
$skip_next = 1;
|
|
next;
|
|
}
|
|
if ($arg =~ /^--tool=/) {
|
|
$ENV{GIT_DIFF_TOOL} = substr($arg, 7);
|
|
next;
|
|
}
|
|
if ($arg eq '-x' || $arg eq '--extcmd') {
|
|
usage() if $#ARGV <= $idx;
|
|
$ENV{GIT_DIFFTOOL_EXTCMD} = $ARGV[$idx + 1];
|
|
$skip_next = 1;
|
|
next;
|
|
}
|
|
if ($arg =~ /^--extcmd=/) {
|
|
$ENV{GIT_DIFFTOOL_EXTCMD} = substr($arg, 9);
|
|
next;
|
|
}
|
|
if ($arg eq '-g' || $arg eq '--gui') {
|
|
eval {
|
|
my $tool = Git::command_oneline('config',
|
|
'diff.guitool');
|
|
if (length($tool)) {
|
|
$ENV{GIT_DIFF_TOOL} = $tool;
|
|
}
|
|
};
|
|
next;
|
|
}
|
|
if ($arg eq '-y' || $arg eq '--no-prompt') {
|
|
$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
|
|
delete $ENV{GIT_DIFFTOOL_PROMPT};
|
|
next;
|
|
}
|
|
if ($arg eq '--prompt') {
|
|
$ENV{GIT_DIFFTOOL_PROMPT} = 'true';
|
|
delete $ENV{GIT_DIFFTOOL_NO_PROMPT};
|
|
next;
|
|
}
|
|
if ($arg eq '-h' || $arg eq '--help') {
|
|
usage();
|
|
}
|
|
push @command, $arg;
|
|
}
|
|
return @command
|
|
}
|
|
|
|
setup_environment();
|
|
|
|
# ActiveState Perl for Win32 does not implement POSIX semantics of
|
|
# exec* system call. It just spawns the given executable and finishes
|
|
# the starting program, exiting with code 0.
|
|
# system will at least catch the errors returned by git diff,
|
|
# allowing the caller of git difftool better handling of failures.
|
|
my $rc = system(generate_command());
|
|
exit($rc | ($rc >> 8));
|