| 1 | 5 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | package Git::Wrapper; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | #ABSTRACT: Wrap git(7) command-line interface | ||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | $Git::Wrapper::VERSION = '0.047_090'; # TRIAL | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | $Git::Wrapper::VERSION = '0.047090';our $DEBUG=0; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # Prevent ANSI color with extreme prejudice | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # https://github.com/genehack/Git-Wrapper/issues/13 | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | delete $ENV{GIT_PAGER_IN_USE}; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use File::chdir; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use IPC::Open3 qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use Sort::Versions; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use Symbol; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | use Git::Wrapper::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use Git::Wrapper::File::RawModification; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | use Git::Wrapper::Log; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use Git::Wrapper::Statuses; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # three calling conventions | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # 1: my $gw = Git::Wrapper->new( $dir ) | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # 2: my $gw = Git::Wrapper->new( $dir , %options ) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # 3: my $gw = Git::Wrapper->new({ dir => $dir , %options }); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 7 | my $args; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | ▶ | if ( scalar @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | ▶ | if ( ref $arg eq 'HASH' ) { $args = $arg } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | elsif ( blessed $arg ) { $args = { dir => "$arg" } } # my objects, let me | |||||||||||||||||||||||||||||||||||||||||
| 41 | # show you them. | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | elsif ( ! ref $arg ) { $args = { dir => $arg } } | |||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | else { die "Single arg must be hashref, scalar, or stringify-able object" } | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | my( $dir , %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | $dir = "$dir" if blessed $dir; # we can stringify it for you wholesale | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | $args = { dir => $dir , %opts } | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | my $self = bless $args => $class; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | die "usage: $class->new(\$dir)" unless $self->dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 44 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 44 | (my $meth = our $AUTOLOAD) =~ s/.+:://; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 44 | ▶ | return if $meth eq 'DESTROY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 39 | $meth =~ tr/_/-/; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 39 | return $self->RUN($meth, @_); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub ERR { shift->{err} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ERR: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub OUT { shift->{out} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
OUT: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub AUTOPRINT { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOPRINT: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $self->{autoprint} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $self->{autoprint}; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | sub RUN { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 94 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RUN: called CC=14 SCAR=29.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 94 | delete $self->{err}; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 94 | delete $self->{out}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 94 | my $cmd = shift; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 94 | my( $parts , $stdin ) = _parse_args( $cmd , @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 94 | my @cmd = ( $self->git , @$parts ); | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 94 | my( @out , @err ); | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 94 | ▶ | local $CWD = $self->dir unless $cmd eq 'clone'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 94 | my ($wtr, $rdr, $err); | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 94 | local *TEMP; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 94 | ▶ | if ($^O eq 'MSWin32' && defined $stdin) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$^O eq "MSWin32" and defined $stdin
MC/DC0%0/2
$^O eq "MSWin32" and defined $stdin
$^O eq "MSWin32"
defined $stdin
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= defined $stdin
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $file = File::Temp->new; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $file->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $file->print($stdin); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $file->seek(0,0); | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | open TEMP, '<&=', $file; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $wtr = '<&TEMP'; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | undef $stdin; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 94 | $err = Symbol::gensym; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 94 | ▶ | print STDERR join(' ',@cmd),"\n" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | # Prevent commands from running interactively | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 94 | local $ENV{GIT_EDITOR} = ' '; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 94 | my $pid = IPC::Open3::open3($wtr, $rdr, $err, @cmd); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 94 | ▶ | print $wtr $stdin | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | if defined $stdin; | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 94 | close $wtr; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 94 | chomp(@out = <$rdr>); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 94 | chomp(@err = <$err>); | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 94 | waitpid $pid, 0; | |||||||||||||||||||||||||||||||||||||||||
| 126 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 94 | ▶ | print "status: $?\n" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | # In earlier gits (1.5, 1.6, I'm not sure when it changed), "git status" | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # would exit 1 if there was nothing to commit, or in other cases. This is | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # basically insane, and has been fixed, but if we don't require git 1.7, we | ||||||||||||||||||||||||||||||||||||||||||
| 133 | # should cope with it. -- rjbs, 2012-03-31 | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 94 | ▶ | my $stupid_status = $cmd eq 'status' && @out && ! @err; | ||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$cmd eq 'status' && @out && !@err
$cmd eq "status" and @out
MC/DC66%2/3
$cmd eq 'status' && @out && !@err
$cmd eq "status"
@out
!@err
Truth table75%3/4
A and B && not(C)
A= $cmd eq "status"B= @outC= !@err
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 94 | ▶ | if ($? && ! $stupid_status) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$? and not $stupid_status
MC/DC50%1/2
$? and not $stupid_status
$?
not $stupid_status
Truth table66%2/3
A and not(B)
A= $?B= not $stupid_status
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | die Git::Wrapper::Exception->new( | |||||||||||||||||||||||||||||||||||||||||
| 138 | output => \@out, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | error => \@err, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | status => $? >> 8, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 93 | $self->{err} = \@err; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 93 | $self->{out} = \@out; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 93 | ▶ | if( $self->{autoprint} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | print $_, "\n" for @out; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | warn $_, "\n" for @err; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 93 | return @out; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | sub branch { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
branch: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | ▶ | my $opt = ref $_[0] eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | $opt->{no_color} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | return $self->RUN(branch => $opt,@_); | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 99 | ▶ | sub dir { shift->{dir} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | sub git { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 94 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
git: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 94 | ▶ | return $self->{git_binary} if defined $self->{git_binary}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 93 | ▶ | return ( defined $ENV{GIT_WRAPPER_GIT} ) ? $ENV{GIT_WRAPPER_GIT} : 'git'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | sub has_git_in_path { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | require IPC::Cmd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_git_in_path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | IPC::Cmd::can_run('git'); | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | sub log { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: called CC=20 SCAR=30.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 12 | ▶ | if ( grep /format=/, @_ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | die Git::Wrapper::Exception->new( | |||||||||||||||||||||||||||||||||||||||||
| 185 | error => [qw/--format not allowed. Use the RUN() method if you with to use a custom log format./], | ||||||||||||||||||||||||||||||||||||||||||
| 186 | output => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | status => 255 , | ||||||||||||||||||||||||||||||||||||||||||
| 188 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 11 | ▶ | my $opt = ref $_[0] eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 11 | $opt->{no_color} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 11 | $opt->{pretty} = 'medium'; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 11 | $opt->{no_abbrev} = 1; # https://github.com/genehack/Git-Wrapper/issues/67 | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 11 | ▶ | $opt->{no_abbrev_commit} = 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | if $self->supports_log_no_abbrev_commit; | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 11 | ▶ | $opt->{no_expand_tabs} = 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | if $self->supports_log_no_expand_tabs; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 11 | ▶ | my $raw = defined $opt->{raw} && $opt->{raw}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $opt->{'raw'} && $opt->{'raw'}
MC/DC50%1/2
defined $opt->{'raw'} && $opt->{'raw'}
defined $opt->{'raw'}
$opt->{'raw'}
Truth table66%2/3
A && B
A= defined $opt->{'raw'}B= $opt->{'raw'}
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 11 | my @out = $self->RUN(log => $opt, @_); | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 11 | my @logs; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 11 | ▶ | while (my $line = shift @out) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 14 | ▶ | die "unhandled: $line" unless $line =~ /^commit (\S+)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 13 | my $current = Git::Wrapper::Log->new($1); | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 13 | $line = shift @out; # next line; | |||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 13 | ▶ | while ($line =~ /^(\S+):\s+(.+)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 26 | $current->attr->{lc $1} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 26 | $line = shift @out; # next line; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 13 | ▶ | die "no blank line separating head from message" if $line; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 13 | ▶ | my ( $initial_indent ) = $out[0] =~ /^(\s*)/ if @out; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 13 | my $message = ''; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 13 | ▶ | while ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@out and not $out[0] =~ /^commit (\S+)/ and length($line = shift @out)
@out and not $out[0] =~ /^commit (\S+)/
MC/DC100%3/3
@out and not $out[0] =~ /^commit (\S+)/ and length($line = shift @out)
@out
not $out[0] =~ /^commit (\S+)/
length($line = shift @out)
Truth table100%4/4
A and not(B) and C
A= @outB= not $out[0] =~ /^commit (\S+)/C= length($line = shift @out)
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | @out | ||||||||||||||||||||||||||||||||||||||||||
| 225 | and $out[0] !~ /^commit (\S+)/ | ||||||||||||||||||||||||||||||||||||||||||
| 226 | and length($line = shift @out) | ||||||||||||||||||||||||||||||||||||||||||
| 227 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 20 | $line =~ s/^$initial_indent//; # strip just the indenting added by git | |||||||||||||||||||||||||||||||||||||||||
| 229 | 20 | $message .= "$line\n"; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 13 | $current->message($message); | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 13 | ▶ | if ($raw) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 3 | my @modifications; | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | # example outputs: | ||||||||||||||||||||||||||||||||||||||||||
| 238 | # regular: | ||||||||||||||||||||||||||||||||||||||||||
| 239 | # :000000 100644 0000000000000000000000000000000000000000 ce013625030ba8dba906f756967f9e9ca394464a A foo/bar | ||||||||||||||||||||||||||||||||||||||||||
| 240 | # with score value after file type (see https://github.com/genehack/Git-Wrapper/issues/70): | ||||||||||||||||||||||||||||||||||||||||||
| 241 | # :100644 100644 c659037... c659037... R100 foo bar | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 3 | ▶ | while(@out and $out[0] =~ m/^\:(\d{6}) (\d{6}) (\w{40}) (\w{40}) (\w{1}[0-9]*)\t(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@out and $out[0] =~ /^\:(\d{6}) (\d{6}) (\w{40}) (\w{40}) (\w{1}[0-9]*)\t(.*)$/
MC/DC50%1/2
@out and $out[0] =~ /^\:(\d{6}) (\d{6}) (\w{40}) (\w{40}) (\w{1}[0-9]*)\t(.*)$/
@out
$out[0] =~ /^\:(\d{6}) (\d{6}) (\w{40}) (\w{40}) (\w{1}[0-9]*)\t(.*)$/
Truth table66%2/3
A and B
A= @outB= $out[0] =~ /^\:(\d{6}) (\d{6}) (\w{40}) (\w{40}) (\w{1}[0-9]*)\t(.*)$/
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 3 | push @modifications, Git::Wrapper::File::RawModification->new($6,$5,$1,$2,$3,$4); | |||||||||||||||||||||||||||||||||||||||||
| 244 | 3 | shift @out; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 3 | ▶ | $current->modifications(@modifications) if @modifications; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 13 | push @logs, $current; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 13 | ▶ | last unless @out; # handle running out of log | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | shift @out unless $out[0] =~ /^commit/; # blank line at end of entry, except merge commits; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 10 | return @logs; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 5 | my %STATUS_CONFLICTS = map { $_ => 1 } qw<DD AU UD UA DU AA UU>; | |||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | sub status { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=11 SCAR=26.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | return $self->RUN('status' , @_ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | unless $self->supports_status_porcelain; | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | ▶ | my $opt = ref $_[0] eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | $opt->{$_} = 1 for qw<porcelain>; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | my @out = $self->RUN(status => $opt, @_); | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | my $statuses = Git::Wrapper::Statuses->new; | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | return $statuses if !@out; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | for (@out) { | |||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | my ($x, $y, $from, $to) = $_ =~ /\A(.)(.) (.*?)(?: -> (.*))?\z/; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | if ($STATUS_CONFLICTS{"$x$y"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $statuses->add('conflict', "$x$y", $from, $to); | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | ▶ | elsif ($x eq '?' && $y eq '?') { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$x eq "?" and $y eq "?"
MC/DC0%0/2
$x eq "?" and $y eq "?"
$x eq "?"
$y eq "?"
Truth table33%1/3
A and B
A= $x eq "?"B= $y eq "?"
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $statuses->add('unknown', '?', $from, $to); | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | ▶ | $statuses->add('changed', $y, $from, $to) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | if $y ne ' '; | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | $statuses->add('indexed', $x, $from, $to) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | if $x ne ' '; | ||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | return $statuses; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | sub supports_hash_object_filters { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supports_hash_object_filters: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | # The '--no-filters' option to 'git-hash-object' was added in version 1.6.1 | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | ▶ | return 0 if ( versioncmp( $self->version , '1.6.1' ) == -1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | sub supports_log_no_abbrev_commit { | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supports_log_no_abbrev_commit: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | # The '--no-abbrev-commit' option to 'git log' was added in version 1.7.6 | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 12 | ▶ | return ( versioncmp( $self->version , '1.7.6' ) == -1 ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | sub supports_log_no_expand_tabs { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 11 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supports_log_no_expand_tabs: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | # The '--no-expand-tabs' option to git log was added in version 2.9.0 | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 11 | ▶ | return 0 if ( versioncmp( $self->version , '2.9' ) == -1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 11 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | sub supports_log_raw_dates { | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supports_log_raw_dates: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | # The '--date=raw' option to 'git log' was added in version 1.6.2 | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | ▶ | return 0 if ( versioncmp( $self->version , '1.6.2' ) == -1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | sub supports_status_porcelain { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supports_status_porcelain: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | # The '--porcelain' option to git status was added in version 1.7.0 | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 4 | ▶ | return 0 if ( versioncmp( $self->version , '1.7' ) == -1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | sub version { | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 37 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 37 | my ($version) = $self->RUN('version'); | |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 37 | $version =~ s/^git version //; | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 37 | return $version; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | sub _message_tempfile { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | my ( $message ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message_tempfile: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $tmp = File::Temp->new( UNLINK => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $tmp->print( $message ); | |||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | return ( "file", '"'.$tmp->filename.'"' ); | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | sub _opt_and_val { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 109 | ▶ | my( $name , $val ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_opt_and_val: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 109 | $name =~ tr/_/-/; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 109 | ▶ | my $opt = length($name) == 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | ? "-$name" | ||||||||||||||||||||||||||||||||||||||||||
| 358 | : "--$name" | ||||||||||||||||||||||||||||||||||||||||||
| 359 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | return | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 109 | ▶ | $val eq '1' ? ($opt) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | : length($name) == 1 ? ($opt, $val) | ||||||||||||||||||||||||||||||||||||||||||
| 364 | : "$opt=$val"; | ||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | sub _parse_args { | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 107 | ▶ | my $cmd = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_args: called CC=11 SCAR=24.4
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 107 | ▶ | die "initial argument must not be a reference\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | if ref $cmd; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 107 | my( $stdin , @pre_cmd , @post_cmd ); | |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 107 | foreach ( @_ ) { | |||||||||||||||||||||||||||||||||||||||||
| 375 | 106 | ▶ | if ( ref $_ eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | $stdin = delete $_->{-STDIN} | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 46 | ▶ | if exists $_->{-STDIN}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 46 | for my $name ( sort keys %$_ ) { | |||||||||||||||||||||||||||||||||||||||||
| 380 | 109 | my $val = delete $_->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 109 | ▶ | next if $val eq '0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 109 | ▶ | if ( $name =~ s/^-// ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 10 | push @pre_cmd , _opt_and_val( $name , $val ); | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 99 | ▶ | ( $name, $val ) = _message_tempfile( $val ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | if _win32_multiline_commit_msg( $cmd, $name, $val ); | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 99 | push @post_cmd , _opt_and_val( $name , $val ); | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | elsif ( blessed $_ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 2 | push @post_cmd , "$_"; # here be anteaters | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | elsif ( ref $_ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | die "Git::Wrapper command arguments must be plain scalars, hashrefs, " | |||||||||||||||||||||||||||||||||||||||||
| 399 | . "or stringify-able objects.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 58 | else { push @post_cmd , $_; } | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 107 | return( [ @pre_cmd , $cmd , @post_cmd ] , $stdin ); | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | sub _win32_multiline_commit_msg { | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 99 | ▶ | my ( $cmd, $name, $val ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_win32_multiline_commit_msg: called CC=6 SCAR=32.6
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 99 | ▶ | return 0 if $^O ne "MSWin32"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | return 0 if $cmd ne "commit"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | return 0 if $name ne "m" and $name ne "message"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name ne "m" and $name ne "message"
MC/DC0%0/2
$name ne "m" and $name ne "message"
$name ne "m"
$name ne "message"
Truth table0%0/3
A and B
A= $name ne "m"B= $name ne "message"
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | return 0 if $val !~ /\n/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | __END__ | ||||||||||||||||||||||||||||||||||||||||||