In order to make git work on an ancient Linux (Mandrake 7.0) we need to make the perl scripts work with verion 5.005_03. The changes include: - comment out the "use warnings" pragma - open has only two arguments; eg. `open FH, "<$file"` rather than `open FH, '<', $file` - replace "our" with "my" in the declaration of global (package) variables. - replace the use of some indirect file-handles with regular file-handles. Note that only those perl scripts which are exercised by the test suite or that I have called directly have been modified. Signed-off-by: Ramsay Allan Jones <ramsay@xxxxxxxxxxxxxxxxxxx> --- Documentation/build-docdep.perl | 2 +- git-annotate.perl | 25 ++++++++++++------------- git-clone.sh | 6 +++--- git-mv.perl | 4 ++-- git-send-email.perl | 27 +++++++++++++-------------- git-shortlog.perl | 2 +- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Documentation/build-docdep.perl b/Documentation/build-docdep.perl index 489389c..cd40f56 100755 --- a/Documentation/build-docdep.perl +++ b/Documentation/build-docdep.perl @@ -4,7 +4,7 @@ my %include = (); my %included = (); for my $text (<*.txt>) { - open I, '<', $text || die "cannot read: $text"; + open I, "<$text" || die "cannot read: $text"; while (<I>) { if (/^include::/) { chomp; diff --git a/git-annotate.perl b/git-annotate.perl index a6a7a48..629f480 100755 --- a/git-annotate.perl +++ b/git-annotate.perl @@ -6,7 +6,7 @@ # # This file is licensed under the GPL v2, or a later version # at the discretion of Linus Torvalds. -use warnings; +#use warnings; use strict; use Getopt::Long; use POSIX qw(strftime gmtime); @@ -29,7 +29,7 @@ sub usage() { exit(1); } -our ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1); +my ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1); my $rc = GetOptions( "long|l" => \$longrev, "time|t" => \$rawtime, @@ -52,12 +52,12 @@ my @stack = ( }, ); -our @filelines = (); +my @filelines = (); if (defined $starting_rev) { @filelines = git_cat_file($starting_rev, $filename); } else { - open(F,"<",$filename) + open(F,"<$filename") or die "Failed to open filename: $!"; while(<F>) { @@ -68,9 +68,9 @@ if (defined $starting_rev) { } -our %revs; -our @revqueue; -our $head; +my %revs; +my @revqueue; +my $head; my $revsprocessed = 0; while (my $bound = pop @stack) { @@ -436,14 +436,13 @@ sub format_date { # Copied from git-send-email.perl - We need a Git.pm module.. sub gitvar { my ($var) = @_; - my $fh; - my $pid = open($fh, '-|'); + my $pid = open(FH, '-|'); die "$!" unless defined $pid; if (!$pid) { exec('git-var', $var) or die "$!"; } - my ($val) = <$fh>; - close $fh or die "$!"; + my ($val) = <FH>; + close FH or die "$!"; chomp($val); return $val; } @@ -471,7 +470,7 @@ sub open_pipe_activestate { sub open_pipe_normal { my (@execlist) = @_; - my $pid = open my $kid, "-|"; + my $pid = open KID, "-|"; defined $pid or die "Cannot fork: $!"; unless ($pid) { @@ -479,7 +478,7 @@ sub open_pipe_normal { die "Cannot exec @execlist: $!"; } - return $kid; + return *KID; } package Git::ActiveStatePipe; diff --git a/git-clone.sh b/git-clone.sh index 47bd8e7..430c892 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -71,17 +71,17 @@ sub store { my ($sha1, $name, $top) = @_; $name = "$git_dir/refs/$top/$name"; mkpath(dirname($name)); - open O, ">", "$name"; + open O, ">$name"; print O "$sha1\n"; close O; } -open FH, "<", "$git_dir/CLONE_HEAD"; +open FH, "<$git_dir/CLONE_HEAD"; while (<FH>) { my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/; next if ($name =~ /\^\173/); if ($name eq "HEAD") { - open O, ">", "$git_dir/REMOTE_HEAD"; + open O, ">$git_dir/REMOTE_HEAD"; print O "$sha1\n"; close O; next; diff --git a/git-mv.perl b/git-mv.perl index 75aa8fe..7aceeb8 100755 --- a/git-mv.perl +++ b/git-mv.perl @@ -7,7 +7,7 @@ # This file is licensed under the GPL v2 # at the discretion of Linus Torvalds. -use warnings; +#use warnings; use strict; use Getopt::Std; @@ -19,7 +19,7 @@ EOT exit(1); } -our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v); +my ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v); getopts("hnfkv") || usage; usage() if $opt_h; @ARGV >= 1 or usage; diff --git a/git-send-email.perl b/git-send-email.perl index c5d9e73..e670f28 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -17,7 +17,7 @@ # and second line is the subject of t # use strict; -use warnings; +#use warnings; use Term::ReadLine; use Getopt::Long; use Data::Dumper; @@ -83,14 +83,13 @@ # Now, let's fill any that aren't set in sub gitvar { my ($var) = @_; - my $fh; - my $pid = open($fh, '-|'); + my $pid = open(FH, '-|'); die "$!" unless defined $pid; if (!$pid) { exec('git-var', $var) or die "$!"; } - my ($val) = <$fh>; - close $fh or die "$!"; + my ($val) = <FH>; + close FH or die "$!"; chomp($val); return $val; } @@ -134,7 +133,7 @@ my %parse_alias = ( if (@alias_files && defined $parse_alias{$aliasfiletype}) { foreach my $file (@alias_files) { - open my $fh, '<', $file or die "opening $file: $!\n"; + open my $fh, "<$file" or die "opening $file: $!\n"; $parse_alias{$aliasfiletype}->($fh); close $fh; } @@ -209,7 +208,7 @@ if (!$smtp_server) { if ($compose) { # Note that this does not need to be secure, but we will make a small # effort to have it be unique - open(C,">",$compose_filename) + open(C,">$compose_filename") or die "Failed to open for writing $compose_filename: $!"; print C "From $from # This line is ignored.\n"; printf C "Subject: %s\n\n", $initial_subject; @@ -226,10 +225,10 @@ EOT $editor = 'vi' unless defined $editor; system($editor, $compose_filename); - open(C2,">",$compose_filename . ".final") + open(C2,">$compose_filename" . ".final") or die "Failed to open $compose_filename.final : " . $!; - open(C,"<",$compose_filename) + open(C,"<$compose_filename") or die "Failed to open $compose_filename : " . $!; while(<C>) { @@ -322,7 +321,7 @@ EOT } # Variables we set as part of the loop over files -our ($message_id, $cc, %mail, $subject, $reply_to, $references, $message); +my ($message_id, $cc, %mail, $subject, $reply_to, $references, $message); sub extract_valid_address { my $address = shift; @@ -396,15 +395,15 @@ X-Mailer: git-send-email $gitversion } if ($smtp_server =~ m#^/#) { - my $pid = open my $sm, '|-'; + my $pid = open SM, '|-'; defined $pid or die $!; if (!$pid) { exec($smtp_server,'-i', map { extract_valid_address($_) } @recipients) or die $!; } - print $sm "$header\n$message"; - close $sm or die $?; + print SM "$header\n$message"; + close SM or die $?; } else { require Net::SMTP; $smtp ||= Net::SMTP->new( $smtp_server ); @@ -440,7 +439,7 @@ make_message_id(); $subject = $initial_subject; foreach my $t (@files) { - open(F,"<",$t) or die "can't open file $t"; + open(F,"<$t") or die "can't open file $t"; my $author_not_sender = undef; @cc = @initial_cc; diff --git a/git-shortlog.perl b/git-shortlog.perl index 0b14f83..57604dd 100755 --- a/git-shortlog.perl +++ b/git-shortlog.perl @@ -128,7 +128,7 @@ sub setup_mailmap { read_mailmap(\*DATA, \%mailmap); if (-f '.mailmap') { my $fh = undef; - open $fh, '<', '.mailmap'; + open $fh, '<.mailmap'; read_mailmap($fh, \%mailmap); close $fh; } -- 1.4.1
From b94dcac94f70cc677d4d26aaab47a3e9eecccba2 Mon Sep 17 00:00:00 2001 From: Ramsay Allan Jones <ramsay@xxxxxxxxxxxxxxxxxxx> Date: Sun, 30 Jul 2006 23:13:14 +0100 Subject: [PATCH 10/10] Fix perl scripts to work with version 5.005_03. In order to make git work on an ancient Linux (Mandrake 7.0) we need to make the perl scripts work with verion 5.005_03. The changes include: - comment out the "use warnings" pragma - open has only two arguments; eg. `open FH, "<$file"` rather than `open FH, '<', $file` - replace "our" with "my" in the declaration of global (package) variables. - replace the use of some indirect file-handles with regular file-handles. Note that only those perl scripts which are exercised by the test suite or that I have called directly have been modified. Signed-off-by: Ramsay Allan Jones <ramsay@xxxxxxxxxxxxxxxxxxx> --- Documentation/build-docdep.perl | 2 +- git-annotate.perl | 25 ++++++++++++------------- git-clone.sh | 6 +++--- git-mv.perl | 4 ++-- git-send-email.perl | 27 +++++++++++++-------------- git-shortlog.perl | 2 +- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Documentation/build-docdep.perl b/Documentation/build-docdep.perl index 489389c..cd40f56 100755 --- a/Documentation/build-docdep.perl +++ b/Documentation/build-docdep.perl @@ -4,7 +4,7 @@ my %include = (); my %included = (); for my $text (<*.txt>) { - open I, '<', $text || die "cannot read: $text"; + open I, "<$text" || die "cannot read: $text"; while (<I>) { if (/^include::/) { chomp; diff --git a/git-annotate.perl b/git-annotate.perl index a6a7a48..629f480 100755 --- a/git-annotate.perl +++ b/git-annotate.perl @@ -6,7 +6,7 @@ # # This file is licensed under the GPL v2, or a later version # at the discretion of Linus Torvalds. -use warnings; +#use warnings; use strict; use Getopt::Long; use POSIX qw(strftime gmtime); @@ -29,7 +29,7 @@ sub usage() { exit(1); } -our ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1); +my ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1); my $rc = GetOptions( "long|l" => \$longrev, "time|t" => \$rawtime, @@ -52,12 +52,12 @@ my @stack = ( }, ); -our @filelines = (); +my @filelines = (); if (defined $starting_rev) { @filelines = git_cat_file($starting_rev, $filename); } else { - open(F,"<",$filename) + open(F,"<$filename") or die "Failed to open filename: $!"; while(<F>) { @@ -68,9 +68,9 @@ if (defined $starting_rev) { } -our %revs; -our @revqueue; -our $head; +my %revs; +my @revqueue; +my $head; my $revsprocessed = 0; while (my $bound = pop @stack) { @@ -436,14 +436,13 @@ sub format_date { # Copied from git-send-email.perl - We need a Git.pm module.. sub gitvar { my ($var) = @_; - my $fh; - my $pid = open($fh, '-|'); + my $pid = open(FH, '-|'); die "$!" unless defined $pid; if (!$pid) { exec('git-var', $var) or die "$!"; } - my ($val) = <$fh>; - close $fh or die "$!"; + my ($val) = <FH>; + close FH or die "$!"; chomp($val); return $val; } @@ -471,7 +470,7 @@ sub open_pipe_activestate { sub open_pipe_normal { my (@execlist) = @_; - my $pid = open my $kid, "-|"; + my $pid = open KID, "-|"; defined $pid or die "Cannot fork: $!"; unless ($pid) { @@ -479,7 +478,7 @@ sub open_pipe_normal { die "Cannot exec @execlist: $!"; } - return $kid; + return *KID; } package Git::ActiveStatePipe; diff --git a/git-clone.sh b/git-clone.sh index 47bd8e7..430c892 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -71,17 +71,17 @@ sub store { my ($sha1, $name, $top) = @_; $name = "$git_dir/refs/$top/$name"; mkpath(dirname($name)); - open O, ">", "$name"; + open O, ">$name"; print O "$sha1\n"; close O; } -open FH, "<", "$git_dir/CLONE_HEAD"; +open FH, "<$git_dir/CLONE_HEAD"; while (<FH>) { my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/; next if ($name =~ /\^\173/); if ($name eq "HEAD") { - open O, ">", "$git_dir/REMOTE_HEAD"; + open O, ">$git_dir/REMOTE_HEAD"; print O "$sha1\n"; close O; next; diff --git a/git-mv.perl b/git-mv.perl index 75aa8fe..7aceeb8 100755 --- a/git-mv.perl +++ b/git-mv.perl @@ -7,7 +7,7 @@ # This file is licensed under the GPL v2 # at the discretion of Linus Torvalds. -use warnings; +#use warnings; use strict; use Getopt::Std; @@ -19,7 +19,7 @@ EOT exit(1); } -our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v); +my ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v); getopts("hnfkv") || usage; usage() if $opt_h; @ARGV >= 1 or usage; diff --git a/git-send-email.perl b/git-send-email.perl index c5d9e73..e670f28 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -17,7 +17,7 @@ # and second line is the subject of t # use strict; -use warnings; +#use warnings; use Term::ReadLine; use Getopt::Long; use Data::Dumper; @@ -83,14 +83,13 @@ # Now, let's fill any that aren't set in sub gitvar { my ($var) = @_; - my $fh; - my $pid = open($fh, '-|'); + my $pid = open(FH, '-|'); die "$!" unless defined $pid; if (!$pid) { exec('git-var', $var) or die "$!"; } - my ($val) = <$fh>; - close $fh or die "$!"; + my ($val) = <FH>; + close FH or die "$!"; chomp($val); return $val; } @@ -134,7 +133,7 @@ my %parse_alias = ( if (@alias_files && defined $parse_alias{$aliasfiletype}) { foreach my $file (@alias_files) { - open my $fh, '<', $file or die "opening $file: $!\n"; + open my $fh, "<$file" or die "opening $file: $!\n"; $parse_alias{$aliasfiletype}->($fh); close $fh; } @@ -209,7 +208,7 @@ if (!$smtp_server) { if ($compose) { # Note that this does not need to be secure, but we will make a small # effort to have it be unique - open(C,">",$compose_filename) + open(C,">$compose_filename") or die "Failed to open for writing $compose_filename: $!"; print C "From $from # This line is ignored.\n"; printf C "Subject: %s\n\n", $initial_subject; @@ -226,10 +225,10 @@ EOT $editor = 'vi' unless defined $editor; system($editor, $compose_filename); - open(C2,">",$compose_filename . ".final") + open(C2,">$compose_filename" . ".final") or die "Failed to open $compose_filename.final : " . $!; - open(C,"<",$compose_filename) + open(C,"<$compose_filename") or die "Failed to open $compose_filename : " . $!; while(<C>) { @@ -322,7 +321,7 @@ EOT } # Variables we set as part of the loop over files -our ($message_id, $cc, %mail, $subject, $reply_to, $references, $message); +my ($message_id, $cc, %mail, $subject, $reply_to, $references, $message); sub extract_valid_address { my $address = shift; @@ -396,15 +395,15 @@ X-Mailer: git-send-email $gitversion } if ($smtp_server =~ m#^/#) { - my $pid = open my $sm, '|-'; + my $pid = open SM, '|-'; defined $pid or die $!; if (!$pid) { exec($smtp_server,'-i', map { extract_valid_address($_) } @recipients) or die $!; } - print $sm "$header\n$message"; - close $sm or die $?; + print SM "$header\n$message"; + close SM or die $?; } else { require Net::SMTP; $smtp ||= Net::SMTP->new( $smtp_server ); @@ -440,7 +439,7 @@ make_message_id(); $subject = $initial_subject; foreach my $t (@files) { - open(F,"<",$t) or die "can't open file $t"; + open(F,"<$t") or die "can't open file $t"; my $author_not_sender = undef; @cc = @initial_cc; diff --git a/git-shortlog.perl b/git-shortlog.perl index 0b14f83..57604dd 100755 --- a/git-shortlog.perl +++ b/git-shortlog.perl @@ -128,7 +128,7 @@ sub setup_mailmap { read_mailmap(\*DATA, \%mailmap); if (-f '.mailmap') { my $fh = undef; - open $fh, '<', '.mailmap'; + open $fh, '<.mailmap'; read_mailmap($fh, \%mailmap); close $fh; } -- 1.4.1