The generated patch was missing a line of the diff.
genpatch was also depending on the new files being listed first by 'cvs diff' (which is the case but I'm not sure there is any hard guarantee). Use 'perl -w' for more checking, fix the resulting 'undefined value' warnings. In many cases we don't just want $options{xxx} to exist, we want it to be defined. Restrict the scope of variables and remove unneeded variables.
This commit is contained in:
parent
d1dceca69f
commit
c4c271f1e4
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/perl
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# genpatch - A utility that generates patches for submission to
|
||||
# wine-patches@winehq.org
|
||||
|
@ -66,18 +66,13 @@ use Getopt::Std;
|
|||
use File::Basename;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
my $gen_date; # date the patch was generated
|
||||
my %options; # command line options
|
||||
my @modified_files; # optional list of files that were modified
|
||||
my @added_files; # added files as an array
|
||||
my $added_file; # added file being considered
|
||||
my $cvs_line; # line of output from CVS
|
||||
my $mod_files_str; # string that describes the modified files
|
||||
# Command line options
|
||||
my %options;
|
||||
|
||||
# Default the patch name to the UTC time. Use a more descriptive date for the
|
||||
# patch generation date.
|
||||
$options{n} = strftime "%Y%m%d%H%M", gmtime;
|
||||
$gen_date = strftime "%Y/%m/%d %H:%M:%S UTC", gmtime;
|
||||
my $gen_date = strftime "%Y/%m/%d %H:%M:%S UTC", gmtime;
|
||||
|
||||
unless(getopts("vn:f:c:m:a:p:", \%options))
|
||||
{
|
||||
|
@ -86,28 +81,27 @@ unless(getopts("vn:f:c:m:a:p:", \%options))
|
|||
exit 1;
|
||||
}
|
||||
|
||||
$options{p} = "patches" unless(exists $options{p});
|
||||
$options{f} = "$options{p}/$options{n}.diff" unless(exists $options{f});
|
||||
$options{p} = "patches" if (!defined $options{p});
|
||||
$options{f} = "$options{p}/$options{n}.diff" if (!defined $options{f});
|
||||
$options{p} = dirname $options{f};
|
||||
@added_files = split ' ', $options{a};
|
||||
@modified_files = split ' ', $options{m};
|
||||
$options{a} = "" if (!defined $options{a});
|
||||
my @added_files = split ' ', $options{a};
|
||||
$options{m} = "" if (!defined $options{m});
|
||||
$options{c} = "" if (!defined $options{c});
|
||||
$options{c} =~ s/\\n/\n\t/g;
|
||||
|
||||
if(-d $options{p})
|
||||
if (!-d $options{p})
|
||||
{
|
||||
if(-e $options{f})
|
||||
{
|
||||
print STDERR "$options{f} already exists. Aborting.\n";
|
||||
exit 1;
|
||||
}
|
||||
mkdir $options{p}, (0777 & ~umask)
|
||||
or die "Unable to mkdir $options{p}: $!";
|
||||
}
|
||||
else
|
||||
elsif (-e $options{f})
|
||||
{
|
||||
mkdir $options{p}, (0777 & ~umask) or
|
||||
die "Unable to mkdir $options{p}: $!";
|
||||
print STDERR "$options{f} already exists. Aborting.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
$mod_files_str = exists($options{m}) ? $options{m} : "<see cvs diff>";
|
||||
my $mod_files_str = $options{m} ? $options{m} : "<see cvs diff>";
|
||||
print "Generating $options{f}.\n" if($options{v});
|
||||
open OPT_F, ">$options{f}" or die "Unable to open $options{f} for write: $!";
|
||||
print OPT_F <<EOF;
|
||||
|
@ -119,26 +113,26 @@ AddedFiles: $options{a}
|
|||
EOF
|
||||
|
||||
print "Invoking cvs diff.\n" if($options{v});
|
||||
open CVS_IN, "cvs diff -u @modified_files|" or die "Unable to invoke cvs: $!";
|
||||
while($cvs_line = <CVS_IN>)
|
||||
open CVS_IN, "cvs diff -u $options{m} |"
|
||||
or die "Unable to invoke cvs: $!";
|
||||
while (my $cvs_line = <CVS_IN>)
|
||||
{
|
||||
chomp $cvs_line;
|
||||
if($cvs_line =~ /^\? (.*)/)
|
||||
if ($cvs_line !~ /^\? (.*)/)
|
||||
{
|
||||
push @added_files, $1 unless(exists $options{a});
|
||||
print OPT_F $cvs_line;
|
||||
}
|
||||
else
|
||||
elsif (!$options{a})
|
||||
{
|
||||
print OPT_F <CVS_IN>;
|
||||
push @added_files, chomp $1;
|
||||
}
|
||||
}
|
||||
close CVS_IN;
|
||||
|
||||
foreach $added_file (@added_files)
|
||||
foreach my $added_file (@added_files)
|
||||
{
|
||||
print "Adding $added_file as a new file.\n" if($options{v});
|
||||
open DIFF_IN, "diff -u /dev/null $added_file|" or die "Unable to " .
|
||||
"invoke diff: $!";
|
||||
open DIFF_IN, "diff -u /dev/null $added_file|"
|
||||
or die "Unable to invoke diff: $!";
|
||||
print OPT_F <DIFF_IN>;
|
||||
close DIFF_IN;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue