| 1 | # Copyright © 2008 Raphaël Hertzog <hertzog@debian.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright © 2008-2010, 2012-2015 Guillem Jover <guillem@debian.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | Dpkg::Source::Patch - represent a patch file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | This module provides a class to handle patch files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | B<Note>: This is a private module, its API can change at any time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | package Dpkg::Source::Patch 0.01; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | ▶ | use POSIX qw(:errno_h :sys_wait_h); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 6 | ▶ | use File::stat (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 6 | ▶ | use File::Path qw(make_path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | use File::Compare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | ▶ | use Fcntl qw(:mode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | ▶ | use Time::HiRes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | use Dpkg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | ▶ | use Dpkg::Gettext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | use Dpkg::ErrorHandling; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | ▶ | use Dpkg::IPC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | ▶ | use Dpkg::Source::Functions qw(fs_time); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | ▶ | use parent qw(Dpkg::Compression::FileHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # Create the file on open. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->ensure_open('w'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | *$self->{errors} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | *$self->{empty} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($opts{old} and $opts{new} and $opts{filename}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$opts{"old"} and $opts{"new"} and $opts{"filename"}
$opts{"old"} and $opts{"new"}
MC/DC0%0/3
$opts{"old"} and $opts{"new"} and $opts{"filename"}
$opts{"old"}
$opts{"new"}
$opts{"filename"}
Truth table0%0/4
A and B and C
A= $opts{"old"}B= $opts{"new"}C= $opts{"filename"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $opts{old} = '/dev/null' unless -e $opts{old}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $opts{new} = '/dev/null' unless -e $opts{new}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (-d $opts{old} and -d $opts{new}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
-d $opts{"old"} and -d $opts{"new"}
MC/DC0%0/2
-d $opts{"old"} and -d $opts{"new"}
-d $opts{"old"}
-d $opts{"new"}
Truth table0%0/3
A and B
A= -d $opts{"old"}B= -d $opts{"new"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->add_diff_directory($opts{old}, $opts{new}, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ▶ | } elsif (-f $opts{old} and -f $opts{new}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
-f $opts{"old"} and -f $opts{"new"}
MC/DC0%0/2
-f $opts{"old"} and -f $opts{"new"}
-f $opts{"old"}
-f $opts{"new"}
Truth table0%0/3
A and B
A= -f $opts{"old"}B= -f $opts{"new"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->add_diff_file($opts{old}, $opts{new}, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $self->_fail_not_same_type($opts{old}, $opts{new}, $opts{filename}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $self->finish() unless $opts{no_finish}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub set_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_header: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($self, $header) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | *$self->{header} = $header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub get_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_header: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (ref *$self->{header} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | return *$self->{header}->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return *$self->{header}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub _gen_hires_diff_label($filename) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen_hires_diff_label: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # XXX: Make do without File::stat::stat as otherwise we need to use the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # undocumented File::stat::populate() function with Time::HiRes::stat(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $mtime = (Time::HiRes::stat($filename))[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $t = POSIX::strftime('%Y-%m-%d %H:%M:%S', gmtime $mtime); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return sprintf "\t%s.%09d +0000", $t, ($mtime - int $mtime) * 1_000_000_000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub add_diff_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_diff_file: not called CC=24 SCAR=64.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ($self, $old, $new, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $opts{include_timestamp} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"include_timestamp"} //= 0
MC/DC0%0/1
$opts{"include_timestamp"} //= 0
$opts{"include_timestamp"}
Truth table0%0/2
A
A= $opts{"include_timestamp"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $handle_binary = $opts{handle_binary_func} // sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my ($self, $old, $new, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $file = $opts{filename}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->_fail_with_msg($file, g_('binary file contents changed')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"handle_binary_func"} // sub {
my($self, $old, $new, %opts) = @_;
my $file = $opts{"filename"};
$self->_fail_with_msg($file, g_("binary file contents changed"));
}
MC/DC0%0/2
$opts{"handle_binary_func"} // sub {
my($self, $old, $new, %opts) = @_;
my $file = $opts{"filename"};
$self->_fail_with_msg($file, g_("binary file contents changed"));
}
$opts{"handle_binary_func"}
sub {
my($self, $old, $new, %opts) = @_;
my $file = $opts{"filename"};
$self->_fail_with_msg($file, g_("binary file contents changed"));
}
Truth table0%0/3
A // B
A= $opts{"handle_binary_func"}B= sub {
my($self, $old, $new, %opts) = @_;
my $file = $opts{"filename"};
$self->_fail_with_msg($file, g_("binary file contents changed"));
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # Optimization to avoid forking diff if unnecessary. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | return 1 if compare($old, $new, 4096) == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Default diff options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my @options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($opts{options}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | push @options, @{$opts{options}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | push @options, '-p'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # Add labels. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($opts{label_old} and $opts{label_new}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"label_old"} and $opts{"label_new"}
MC/DC0%0/2
$opts{"label_old"} and $opts{"label_new"}
$opts{"label_old"}
$opts{"label_new"}
Truth table0%0/3
A and B
A= $opts{"label_old"}B= $opts{"label_new"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ($opts{include_timestamp}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $opts{label_old} .= _gen_hires_diff_label($old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $opts{label_new} .= _gen_hires_diff_label($new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # Space in filenames need special treatment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $opts{label_old} .= "\t" if $opts{label_old} =~ / /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $opts{label_new} .= "\t" if $opts{label_new} =~ / /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | push @options, '-L', $opts{label_old}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | '-L', $opts{label_new}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # Generate diff. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $diffgen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $diff_pid = spawn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | exec => [ 'diff', '-u', @options, '--', $old, $new ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | env => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | LC_ALL => 'C', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | TZ => 'UTC0' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | to_pipe => \$diffgen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # Check diff and write it in patch file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $difflinefound = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $binary = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | while (<$diffgen>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $binary = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $handle_binary->($self, $old, $new, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } elsif (m/^[-+\@ ]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $difflinefound++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } elsif (m/^\\ /) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | warning(g_('file %s has no final newline (either ' . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 'original or modified version)'), $new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | error(g_("unknown line from diff -u on %s: '%s'"), $new, $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if (*$self->{empty} and defined(*$self->{header})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
*$self->{"empty"} and defined *$self->{"header"}
MC/DC0%0/2
*$self->{"empty"} and defined *$self->{"header"}
*$self->{"empty"}
defined *$self->{"header"}
Truth table0%0/3
A and B
A= *$self->{"empty"}B= defined *$self->{"header"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $self->print($self->get_header()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | or syserr(g_('cannot write')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | *$self->{empty} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | print { $self } $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | or syserr(g_('cannot write')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | close($diffgen) or syserr(g_('cannot close diff pipe')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | wait_child($diff_pid, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | no_check => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | cmdline => "diff -u @options -- $old $new", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # Verify diff process ended successfully. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # Exit code of diff: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # 0 => no difference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # 1 => diff ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # 2 => error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # Ignore error if binary content detected. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $exit = WEXITSTATUS($?); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | unless (WIFEXITED($?) && ($exit == 0 || $exit == 1 || $binary)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
WIFEXITED($?) and $exit == 0 || $exit == 1 || $binary
$exit == 0 or $exit == 1 or $binary
$exit == 0 or $exit == 1
MC/DC0%0/4
WIFEXITED($?) and $exit == 0 || $exit == 1 || $binary
WIFEXITED($?)
$exit == 0
$exit == 1
$binary
Truth table0%0/5
A and B or C or D
A= WIFEXITED($?)B= $exit == 0C= $exit == 1D= $binary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | subprocerr(g_('diff on %s'), $new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | return ($exit == 0 || $exit == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$exit == 0 || $exit == 1
MC/DC0%0/2
$exit == 0 || $exit == 1
$exit == 0
$exit == 1
Truth table0%0/3
A || B
A= $exit == 0B= $exit == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | sub add_diff_directory { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_diff_directory: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($self, $old, $new, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # TODO: make this function more configurable: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # - Offer to disable some checks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | my $basedir = $opts{basedirname} || basename($new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{'basedirname'} || basename($new)
MC/DC0%0/2
$opts{'basedirname'} || basename($new)
$opts{'basedirname'}
basename($new)
Truth table0%0/3
A || B
A= $opts{'basedirname'}B= basename($new)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $diff_ignore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($opts{diff_ignore_func}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $diff_ignore = $opts{diff_ignore_func}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } elsif ($opts{diff_ignore_regex}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | $diff_ignore = sub { return $_[0] =~ /$opts{diff_ignore_regex}/o }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $diff_ignore = sub { return 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my @diff_files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | my %files_in_new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | my $add_new = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=24 SCAR=64.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $fn = (length > length($new)) ? substr($_, length($new) + 1) : '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return if $diff_ignore->($fn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $files_in_new{$fn} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $new_st = File::stat::lstat("$new/$fn") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | or syserr(g_('cannot stat file %s'), "$new/$fn"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $mode = S_IMODE($new_st->mode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $size = $new_st->size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if (-l $new_st) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | unless (-l "$old/$fn") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $n = readlink("$new/$fn"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | unless (defined $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | syserr(g_('cannot read symbolic link %s'), "$new/$fn"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $n2 = readlink("$old/$fn"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | unless (defined $n2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | syserr(g_('cannot read symbolic link %s'), "$old/$fn"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | unless ($n eq $n2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } elsif (-f $new_st) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $old_file = "$old/$fn"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if (not lstat("$old/$fn")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($! != ENOENT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | syserr(g_('cannot stat file %s'), "$old/$fn"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $old_file = '/dev/null'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } elsif (not -f _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $label_old = "$basedir.orig/$fn"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ($opts{use_dev_null}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | $label_old = $old_file if $old_file eq '/dev/null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | push @diff_files, [$fn, $mode, $size, $old_file, "$new/$fn", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | $label_old, "$basedir/$fn"]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } elsif (-p $new_st) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | unless (-p "$old/$fn") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ▶ | } elsif (-b $new_st || -c $new_st || -S $new_st) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
-b $new_st or -c $new_st or -S $new_st
-b $new_st or -c $new_st
MC/DC0%0/3
-b $new_st or -c $new_st or -S $new_st
-b $new_st
-c $new_st
-S $new_st
Truth table0%0/4
A or B or C
A= -b $new_stB= -c $new_stC= -S $new_st
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $self->_fail_with_msg("$new/$fn", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | g_('device or socket is not allowed')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } elsif (-d $new_st) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if (not lstat("$old/$fn")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($! != ENOENT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | syserr(g_('cannot stat file %s'), "$old/$fn"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } elsif (not -d _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $self->_fail_with_msg("$new/$fn", g_('unknown file type')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my $add_old = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | my $fn = (length > length($old)) ? substr($_, length($old) + 1) : '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return if $diff_ignore->($fn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | return if $files_in_new{$fn}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | lstat("$old/$fn") or syserr(g_('cannot stat file %s'), "$old/$fn"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if (-f _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (not defined $opts{include_removal}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | warning(g_('ignoring deletion of file %s'), $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } elsif (not $opts{include_removal}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | warning(g_('ignoring deletion of file %s, use --include-removal to override'), $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | push @diff_files, [$fn, 0, 0, "$old/$fn", '/dev/null', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | "$basedir.orig/$fn", '/dev/null']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } elsif (-d _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | warning(g_('ignoring deletion of directory %s'), $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } elsif (-l _) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | warning(g_('ignoring deletion of symbolic link %s'), $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->_fail_not_same_type("$old/$fn", "$new/$fn", $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $scan_new = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | wanted => $add_new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | no_chdir => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | find($scan_new, $new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $scan_old = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | wanted => $add_old, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | no_chdir => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | find($scan_old, $old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ($opts{order_from} and -e $opts{order_from}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"order_from"} and -e $opts{"order_from"}
MC/DC0%0/2
$opts{"order_from"} and -e $opts{"order_from"}
$opts{"order_from"}
-e $opts{"order_from"}
Truth table0%0/3
A and B
A= $opts{"order_from"}B= -e $opts{"order_from"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | my $order_from = Dpkg::Source::Patch->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | filename => $opts{order_from}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $analysis = $order_from->analyze($basedir, verbose => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my %patchorder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | foreach my $fn (@{$analysis->{patchorder}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $fn =~ s{^[^/]+/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $patchorder{$fn} = $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # 'quilt refresh' sorts files as follows: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # - Any files in the existing patch come first, in the order in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # which they appear in the existing patch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # - New files follow, sorted lexicographically. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | # This seems a reasonable policy to follow, and avoids autopatches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # being shuffled when they are regenerated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | foreach my $diff_file (sort { $a->[0] cmp $b->[0] } @diff_files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $fn = $diff_file->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | $patchorder{$fn} //= $i++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$patchorder{$fn} //= $i++
MC/DC0%0/1
$patchorder{$fn} //= $i++
$patchorder{$fn}
Truth table0%0/2
A
A= $patchorder{$fn}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | @diff_files = sort { $patchorder{$a->[0]} <=> $patchorder{$b->[0]} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | @diff_files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | @diff_files = sort { $a->[0] cmp $b->[0] } @diff_files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | foreach my $diff_file (@diff_files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my ($fn, $mode, $size, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | $old_file, $new_file, $label_old, $label_new) = @$diff_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my $success = $self->add_diff_file($old_file, $new_file, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | filename => $fn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | label_old => $label_old, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | label_new => $label_new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | %opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if ($success and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$success and $old_file eq "/dev/null" and $new_file ne "/dev/null"
$success and $old_file eq "/dev/null"
MC/DC0%0/3
$success and $old_file eq "/dev/null" and $new_file ne "/dev/null"
$success
$old_file eq "/dev/null"
$new_file ne "/dev/null"
Truth table0%0/4
A and B and C
A= $successB= $old_file eq "/dev/null"C= $new_file ne "/dev/null"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | $old_file eq '/dev/null' and $new_file ne '/dev/null') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if (not $size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | warning(g_("newly created empty file '%s' will not " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 'be represented in diff'), $fn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ($mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | warning(g_("executable mode %04o of '%s' will " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 'not be represented in diff'), $mode, $fn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | unless $fn eq 'debian/rules'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ($mode & (S_ISUID | S_ISGID | S_ISVTX)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | warning(g_("special mode %04o of '%s' will not " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 'be represented in diff'), $mode, $fn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | sub finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | close($self) or syserr(g_('cannot close %s'), $self->get_filename()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | return not *$self->{errors}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub has_errors($self) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_errors: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return *$self->{errors}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | sub register_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | *$self->{errors}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | sub _fail_with_msg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail_with_msg: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my ($self, $file, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | errormsg(g_('cannot represent changes to %s: %s'), $file, $msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->register_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub _fail_not_same_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail_not_same_type: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my ($self, $old, $new, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $old_type = get_type($old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $new_type = get_type($new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | errormsg(g_('cannot represent changes to %s using GNU diff:'), $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | errormsg(g_(' new version is %s'), $new_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | errormsg(g_(' old version is %s'), $old_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | hint(g_('you can use a git formatted patch to represent these changes:')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | hint(g_(' with "git format-patch" or "git diff --no-index a/ b/"')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $self->register_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 130 | ▶ | sub _getline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getline: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 130 | my $handle = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 130 | my $line = <$handle>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 127 | ▶ | if (defined $line) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # Strip end-of-line chars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 119 | chomp($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 119 | $line =~ s/\r$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 127 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # Fetch the header filename ignoring the optional timestamp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 42 | ▶ | sub _fetch_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_filename: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 42 | my ($diff, $header) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # Strip any leading spaces. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 42 | $header =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # Is it a C-style string? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 42 | ▶ | if ($header =~ m/^"/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 10 | error(g_('diff %s patches file with C-style encoded filename'), $diff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # Tab is the official separator, it is always used when filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # contain spaces. Try it first, otherwise strip on space if there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # is no tab. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 32 | ▶ | $header =~ s/\s.*// unless $header =~ s/\t.*//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 32 | return $header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 11 | ▶ | sub _intuit_file_patched { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_intuit_file_patched: called CC=13 SCAR=32.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 11 | my ($old, $new) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 11 | ▶ | return $new unless defined $old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 3 | ▶ | return $old unless defined $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 3 | ▶ | return $new if -e $new and not -e $old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e $new and not -e $old
MC/DC0%0/2
-e $new and not -e $old
-e $new
not -e $old
Truth table33%1/3
A and not(B)
A= -e $newB= not -e $old
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | ▶ | return $old if -e $old and not -e $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e $old and not -e $new
MC/DC0%0/2
-e $old and not -e $new
-e $old
not -e $new
Truth table33%1/3
A and not(B)
A= -e $oldB= not -e $new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # We do not consider the case where both files are non-existent and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # where patch picks the one with the fewest directories to create | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # since dpkg-source will pre-create the required directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # Pre-calculate metrics used by patch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | my ($tmp_o, $tmp_n) = ($old, $new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | my ($len_o, $len_n) = (length($old), length($new)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | $tmp_o =~ tr{/\\}{/}s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | $tmp_n =~ tr{/\\}{/}s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # Count the number of / in the strings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | my $nb_comp_o = ($tmp_o =~ tr{/}{/}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | my $nb_comp_n = ($tmp_n =~ tr{/}{/}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | $tmp_o =~ s{^.*/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | $tmp_n =~ s{^.*/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | my ($blen_o, $blen_n) = (length($tmp_o), length($tmp_n)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # Decide like patch would. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | ▶ | if ($nb_comp_o != $nb_comp_n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | return ($nb_comp_o < $nb_comp_n) ? $old : $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } elsif ($blen_o != $blen_n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | return ($blen_o < $blen_n) ? $old : $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } elsif ($len_o != $len_n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | return ($len_o < $len_n) ? $old : $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | return $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # Check diff for sanity, find directories to create as a side effect. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 37 | ▶ | sub analyze { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyze: called CC=55 SCAR=55.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 37 | my ($self, $destdir, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 37 | ▶ | $opts{verbose} //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"verbose"} //= 1
MC/DC0%0/1
$opts{"verbose"} //= 1
$opts{"verbose"}
Truth table50%1/2
A
A= $opts{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 37 | my $diff = $self->get_filename(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 37 | my %filepatched; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | my %dirtocreate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 37 | my @patchorder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 37 | my $patch_header = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 37 | my $diff_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 37 | my $line = _getline($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 34 | ▶ | HUNK: while (defined $line or not eof $self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $line or not eof $self
MC/DC50%1/2
defined $line or not eof $self
defined $line
not eof $self
Truth table66%2/3
A or not(B)
A= defined $lineB= not eof $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 34 | my (%path, %fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # Skip comments leading up to the patch (if any). Although we do not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # look for an Index: pseudo-header in the comments, because we would | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # not use it anyway, as we require both ---/+++ filename headers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 34 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 79 | ▶ | if ($line =~ /^(?:--- |\+\+\+ |@@ -)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 34 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 45 | $patch_header .= "$line\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 45 | $line = _getline($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 45 | ▶ | last HUNK if not defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 34 | $diff_count++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # Read file header (---/+++ pair). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 34 | ▶ | unless ($line =~ s/^--- //) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 13 | error(g_("expected ^--- in line %d of diff '%s'"), $., $diff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 21 | $path{old} = $line = _fetch_filename($diff, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 21 | ▶ | if ($line ne '/dev/null' and $line =~ s{^[^/]*/+}{$destdir/}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line ne "/dev/null" and $line =~ s[^[^/]*/+][$destdir/]u
MC/DC50%1/2
$line ne "/dev/null" and $line =~ s[^[^/]*/+][$destdir/]u
$line ne "/dev/null"
$line =~ s[^[^/]*/+][$destdir/]u
Truth table66%2/3
A and B
A= $line ne "/dev/null"B= $line =~ s[^[^/]*/+][$destdir/]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 3 | $fn{old} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 21 | ▶ | if ($line =~ /\.dpkg-orig$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | error(g_("diff '%s' patches file with name ending in .dpkg-orig"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | $diff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 21 | $line = _getline($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 21 | ▶ | unless (defined $line) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | error(g_("diff '%s' finishes in middle of ---/+++ (line %d)"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | $diff, $.); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 21 | ▶ | unless ($line =~ s/^\+\+\+ //) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | error(g_("line after --- is not as expected in diff '%s' (line %d)"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | $diff, $.); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 21 | $path{new} = $line = _fetch_filename($diff, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 11 | ▶ | if ($line ne '/dev/null' and $line =~ s{^[^/]*/+}{$destdir/}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line ne "/dev/null" and $line =~ s[^[^/]*/+][$destdir/]u
MC/DC0%0/2
$line ne "/dev/null" and $line =~ s[^[^/]*/+][$destdir/]u
$line ne "/dev/null"
$line =~ s[^[^/]*/+][$destdir/]u
Truth table33%1/3
A and B
A= $line ne "/dev/null"B= $line =~ s[^[^/]*/+][$destdir/]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 11 | $fn{new} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 11 | ▶ | unless (defined $fn{old} or defined $fn{new}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $fn{"old"} or defined $fn{"new"}
MC/DC0%0/2
defined $fn{"old"} or defined $fn{"new"}
defined $fn{"old"}
defined $fn{"new"}
Truth table66%2/3
A or B
A= defined $fn{"old"}B= defined $fn{"new"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | error(g_("none of the filenames in ---/+++ are valid in diff '%s' (line %d)"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | $diff, $.); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # Safety checks on both filenames that patch could use. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 11 | foreach my $key ('old', 'new') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 22 | ▶ | next unless defined $fn{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 14 | ▶ | if ($path{$key} =~ m{/\.\./}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | error(g_('%s contains an insecure path: %s'), $diff, $path{$key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 14 | my $path = $fn{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 14 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 20 | ▶ | last unless $path =~ s{/+[^/]*$}{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # $destdir is assumed safe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 20 | ▶ | last if length($path) <= length($destdir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 11 | ▶ | if ($path{old} eq '/dev/null' and $path{new} eq '/dev/null') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$path{"old"} eq "/dev/null" and $path{"new"} eq "/dev/null"
MC/DC0%0/2
$path{"old"} eq "/dev/null" and $path{"new"} eq "/dev/null"
$path{"old"} eq "/dev/null"
$path{"new"} eq "/dev/null"
Truth table66%2/3
A and B
A= $path{"old"} eq "/dev/null"B= $path{"new"} eq "/dev/null"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | error(g_("original and modified files are /dev/null in diff '%s' (line %d)"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | $diff, $.); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } elsif ($path{new} eq '/dev/null') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | error(g_("file removal without proper filename in diff '%s' (line %d)"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | $diff, $. - 1) unless defined $fn{old}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | if ($opts{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | warning(g_('diff %s removes a non-existing file %s (line %d)'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | $diff, $fn{old}, $.) unless -e $fn{old}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 11 | my $fn = _intuit_file_patched($fn{old}, $fn{new}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 11 | my $dirname = $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 11 | ▶ | if ($dirname =~ s{/[^/]+$}{} and not -d $dirname) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$dirname =~ s[/[^/]+$][]u and not -d $dirname
MC/DC50%1/2
$dirname =~ s[/[^/]+$][]u and not -d $dirname
$dirname =~ s[/[^/]+$][]u
not -d $dirname
Truth table66%2/3
A and not(B)
A= $dirname =~ s[/[^/]+$][]uB= not -d $dirname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 3 | $dirtocreate{$dirname} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 11 | my $st = File::stat::stat($fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 11 | ▶ | if (defined $st) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if (not -f $st) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | error(g_("diff '%s' patches something which is not a plain file"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | $diff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if ($st->nlink > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | warning(g_("diff '%s' patches hard link %s which can have " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 'unintended consequences'), $diff, $fn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 11 | ▶ | if ($filepatched{$fn}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $filepatched{$fn}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if ($opts{fatal_dupes}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | error(g_("diff '%s' patches files multiple times; split the " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 'diff in multiple files or merge the hunks into a ' . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 'single one'), $diff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | ▶ | } elsif ($opts{verbose} and $filepatched{$fn} == 2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"verbose"} and $filepatched{$fn} == 2
MC/DC0%0/2
$opts{"verbose"} and $filepatched{$fn} == 2
$opts{"verbose"}
$filepatched{$fn} == 2
Truth table0%0/3
A and B
A= $opts{"verbose"}B= $filepatched{$fn} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | warning(g_("diff '%s' patches file %s more than once"), $diff, $fn) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 11 | $filepatched{$fn} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 11 | push @patchorder, $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # Read hunks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 11 | my $hunk = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 11 | ▶ | while (defined($line = _getline($self))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # Read hunk header (@@). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 11 | ▶ | next if $line =~ /^\\ /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 11 | ▶ | last unless $line =~ /^@@ -\d+(,(\d+))? \+\d+(,(\d+))? @\@(?: .*)?$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 8 | ▶ | my ($olines, $nlines) = ($1 ? $2 : 1, $3 ? $4 : 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # Read hunk. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 8 | ▶ | while ($olines || $nlines) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$olines or $nlines
MC/DC50%1/2
$olines or $nlines
$olines
$nlines
Truth table66%2/3
A or B
A= $olinesB= $nlines
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 8 | ▶ | unless (defined($line = _getline($self))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if (($olines == $nlines) and ($olines < 3)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$olines == $nlines and $olines < 3
MC/DC0%0/2
$olines == $nlines and $olines < 3
$olines == $nlines
$olines < 3
Truth table0%0/3
A and B
A= $olines == $nlinesB= $olines < 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | warning(g_("unexpected end of diff '%s'"), $diff) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if $opts{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | error(g_("unexpected end of diff '%s'"), $diff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 8 | ▶ | next if $line =~ /^\\ /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # Check stats. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 8 | ▶ | if ($line =~ /^ / or length $line == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$line =~ /^ /u or length $line == 0
MC/DC0%0/2
$line =~ /^ /u or length $line == 0
$line =~ /^ /u
length $line == 0
Truth table33%1/3
A or B
A= $line =~ /^ /uB= length $line == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | --$olines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | --$nlines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } elsif ($line =~ /^-/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | --$olines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } elsif ($line =~ /^\+/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 8 | --$nlines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | error(g_("expected [ +-] at start of line %d of diff '%s'"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | $., $diff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 8 | $hunk++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 11 | ▶ | unless ($hunk) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 3 | error(g_("expected ^\@\@ at line %d of diff '%s'"), $., $diff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 8 | close($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 8 | ▶ | unless ($diff_count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | warning(g_("diff '%s' does not contain any patch"), $diff) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | if $opts{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 8 | *$self->{analysis}{$destdir}{dirtocreate} = \%dirtocreate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 8 | *$self->{analysis}{$destdir}{filepatched} = \%filepatched; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 8 | *$self->{analysis}{$destdir}{patchorder} = \@patchorder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 8 | *$self->{analysis}{$destdir}{patchheader} = $patch_header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 8 | return *$self->{analysis}{$destdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 8 | ▶ | sub prepare_apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_apply: called CC=4 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 8 | my ($self, $analysis, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 8 | ▶ | if ($opts{create_dirs}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 8 | foreach my $dir (keys %{$analysis->{dirtocreate}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | eval { make_path($dir, { mode => 0o777 }) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | syserr(g_('cannot create directory %s'), $dir) if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 37 | ▶ | sub apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=16 SCAR=33.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 37 | my ($self, $destdir, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # Set default values to options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 37 | ▶ | $opts{force_timestamp} //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"force_timestamp"} //= 1
MC/DC0%0/1
$opts{"force_timestamp"} //= 1
$opts{"force_timestamp"}
Truth table50%1/2
A
A= $opts{"force_timestamp"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 37 | ▶ | $opts{remove_backup} //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"remove_backup"} //= 1
MC/DC0%0/1
$opts{"remove_backup"} //= 1
$opts{"remove_backup"}
Truth table50%1/2
A
A= $opts{"remove_backup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 37 | ▶ | $opts{create_dirs} //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"create_dirs"} //= 1
MC/DC0%0/1
$opts{"create_dirs"} //= 1
$opts{"create_dirs"}
Truth table50%1/2
A
A= $opts{"create_dirs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | $opts{options} ||= [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 37 | ▶ | '-t', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"options"} ||= ["-t", "-F", 0, "-N", "-p1", "-u", "-V", "never", "-b", "-z", ".dpkg-orig"]
MC/DC0%0/1
$opts{"options"} ||= ["-t", "-F", 0, "-N", "-p1", "-u", "-V", "never", "-b", "-z", ".dpkg-orig"]
$opts{"options"}
Truth table50%1/2
A
A= $opts{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | '-F', '0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | '-N', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | '-p1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | '-u', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | '-V', 'never', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | '-b', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | '-z', '.dpkg-orig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 37 | ▶ | $opts{add_options} //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"add_options"} //= []
MC/DC0%0/1
$opts{"add_options"} //= []
$opts{"add_options"}
Truth table50%1/2
A
A= $opts{"add_options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 37 | push @{$opts{options}}, @{$opts{add_options}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # Check the diff and create missing directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 37 | my $analysis = $self->analyze($destdir, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 8 | $self->prepare_apply($analysis, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # Apply the patch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 8 | $self->ensure_open('r'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 8 | my ($stdout, $stderr) = ('', ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | spawn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 8 | exec => [ $Dpkg::PROGPATCH, @{$opts{options}} ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | chdir => $destdir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | env => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | LC_ALL => 'C', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | PATCH_GET => '0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | delete_env => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # Ensure expected patch(1) behavior. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 'POSIXLY_CORRECT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | wait_child => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | no_check => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | from_handle => $self->get_filehandle(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | to_string => \$stdout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | error_to_string => \$stderr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 4 | ▶ | if ($?) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | print { *STDOUT } $stdout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | print { *STDERR } $stderr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | subprocerr("LC_ALL=C $Dpkg::PROGPATCH " . join(' ', @{$opts{options}}) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | ' < ' . $self->get_filename()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 4 | $self->close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # Reset the timestamp of all the patched files and remove .dpkg-orig files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 4 | my @files = keys %{$analysis->{filepatched}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 4 | my $now = $opts{timestamp}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 4 | ▶ | $now //= fs_time($files[0]) if $opts{force_timestamp} && scalar @files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$opts{"force_timestamp"} and scalar @files
$now //= fs_time($files[0])
MC/DC0%0/1
$opts{"force_timestamp"} and scalar @files
$opts{"force_timestamp"}
MC/DC0%0/2
$now //= fs_time($files[0])
$now
fs_time($files[0])
Truth table50%1/2
A
A= $opts{"force_timestamp"}
Truth table33%1/3
A //= B
A= $nowB= fs_time($files[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 4 | foreach my $fn (@files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 4 | ▶ | if ($opts{force_timestamp}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 4 | ▶ | utime($now, $now, $fn) or $! == ENOENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
utime $now, $now, $fn or $! == 2
MC/DC0%0/2
utime $now, $now, $fn or $! == 2
utime $now, $now, $fn
$! == 2
Truth table33%1/3
A or B
A= utime $now, $now, $fnB= $! == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | or syserr(g_('cannot change timestamp for %s'), $fn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 4 | ▶ | if ($opts{remove_backup}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 4 | $fn .= '.dpkg-orig'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 4 | ▶ | unlink($fn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | or syserr(g_('cannot remove patch backup file %s'), $fn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | return $analysis; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | # Verify if check will work... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | sub check_apply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_apply: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | my ($self, $destdir, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # Set default values to options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | $opts{create_dirs} //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"create_dirs"} //= 1
MC/DC0%0/1
$opts{"create_dirs"} //= 1
$opts{"create_dirs"}
Truth table0%0/2
A
A= $opts{"create_dirs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | $opts{options} ||= [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | '--dry-run', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"options"} ||= ["--dry-run", "-s", "-t", "-F", 0, "-N", "-p1", "-u", "-V", "never", "-b", "-z", ".dpkg-orig"]
MC/DC0%0/1
$opts{"options"} ||= ["--dry-run", "-s", "-t", "-F", 0, "-N", "-p1", "-u", "-V", "never", "-b", "-z", ".dpkg-orig"]
$opts{"options"}
Truth table0%0/2
A
A= $opts{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | '-s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | '-t', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | '-F', '0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | '-N', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | '-p1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | '-u', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | '-V', 'never', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | '-b', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | '-z', '.dpkg-orig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | $opts{add_options} //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"add_options"} //= []
MC/DC0%0/1
$opts{"add_options"} //= []
$opts{"add_options"}
Truth table0%0/2
A
A= $opts{"add_options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | push @{$opts{options}}, @{$opts{add_options}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # Check the diff and create missing directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my $analysis = $self->analyze($destdir, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | $self->prepare_apply($analysis, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # Apply the patch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | $self->ensure_open('r'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | my $patch_pid = spawn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | exec => [ $Dpkg::PROGPATCH, @{$opts{options}} ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | chdir => $destdir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | env => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | LC_ALL => 'C', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | PATCH_GET => '0', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | delete_env => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # Ensure expected patch(1) behavior. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 'POSIXLY_CORRECT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | from_handle => $self->get_filehandle(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | to_file => '/dev/null', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | error_to_file => '/dev/null', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | wait_child($patch_pid, no_check => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $exit = WEXITSTATUS($?); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | subprocerr("$Dpkg::PROGPATCH --dry-run") unless WIFEXITED($?); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $self->close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | return ($exit == 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # Helper functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | sub get_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_type: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | if (not lstat($file)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | return g_('nonexistent') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | if $! == ENOENT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | syserr(g_('cannot stat %s'), $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | return g_('plain file') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | if -f _ ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | return g_('directory') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | if -d _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | return sprintf(g_('symbolic link to %s'), readlink($file)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | if -l _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | return g_('block device') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | if -b _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | return g_('character device') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | if -c _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | return g_('named pipe') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | if -p _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | return g_('named socket') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | if -S _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | =head1 CHANGES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | =head2 Version 0.xx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | This is a private module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||