blib/lib/Langertha/Holmgang/Sim/Linux/Git.pm

filter: Statementstmt 66.9% 1210 / 1808 Branchbran 47.5% 568 / 1194 Conditioncond 37.4% 533 / 1423 MC/DCmcdc 12.3% 90 / 728 Subroutinesub 77.7% 84 / 108 Podpod 100% 5 / 5 totaltotal 47.2% 2490 / 5266 CC 1257 SCAR 56.2
CC
1257
Cov
52%
_g_push
1585.1
_g_branch
1190.0
_g_commit
518.8
CRAP 276.9
« blib/lib/Langertha/Holmgang/Sim/Linux/Storage.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Postgres.pm »
1 package Langertha::Holmgang::Sim::Linux::Git;
2 # ABSTRACT: git on simulated Linux hosts — working copy, index, commits, push to a Forgejo server with hooks
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $VERSION = '0.001';
13  
14  
15 2 our @GAPS;
16 2 our $CWD;
17  
18 2 my $J = JSON::MaybeXS->new( canonical => 1, utf8 => 1 );
19 158 ▶sub _clone { my $j = JSON::MaybeXS->new( canonical => 1 ); return $j->decode( $j->encode( $_[0] ) ) }
Subroutine _clone: called CC=1 SCAR=0.0
20  
21 2 my @DAY = qw( Thu Fri Sat Sun Mon Tue Wed );
22  
23 # --- Repos, Baeume, Commits ------------------------------------------------------------
24  
25 145 ▶sub _repo_at {
Subroutine _repo_at: called CC=8 SCAR=21.3
26 145 my ( $dev, $path ) = @_;
27 145 ▶ my $rs = ( $dev->{git} || {} )->{repos} || {};
Condition100%4/4
($$dev{'git'} || {})->{'repos'} || {}
l!l
1414
$$dev{'git'} || {}
l!l
1414
MC/DC100%1/1
($$dev{'git'} || {})->{'repos'} || {}
$$dev{'git'}
Truth table100%2/2
A
A= $$dev{'git'}
Aresult
11
00
28 145 ▶ return () unless defined $path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 0 145 145
29 145 ▶ $path =~ s{/+\z}{} unless $path eq '/';
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "/" 145 0 145
30 0 for my $root ( sort { length $b <=> length $a } keys %$rs ) {
31 141 ▶ return ( $root, $rs->{$root} ) if $path eq $root || index( $path, "$root/" ) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $path eq $root or index($path, "$root/") == 0 140 1 141
Condition66%2/3
$path eq $root or index($path, "$root/") == 0
l!l&&r!l&&!r
14001
MC/DC50%1/2
$path eq $root or index($path, "$root/") == 0
$path eq $root index($path, "$root/") == 0
Truth table66%2/3
A or B
A= $path eq $rootB= index($path, "$root/") == 0
ABresult
1X1
011
000
32 }
33 5 return ();
34 }
35  
36 254 ▶sub _text { my ($e) = @_; return ref $e eq 'HASH' ? $e->{content} // '' : $e }
Subroutine _text: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
ref $e eq 'HASH' ? : 0 254 254
Condition0%0/2
$$e{"content"} // ""
l!l
00
MC/DC0%0/1
$$e{"content"} // ""
$$e{"content"}
Truth table0%0/2
A
A= $$e{"content"}
Aresult
11
00
37  
38 # Arbeitsbaum: Dateien des Geraets unter dem Repo (relativ)
39 55 ▶sub _work {
Subroutine _work: called CC=7 SCAR=20.8
40 55 my ( $dev, $root ) = @_;
41 55 my %w;
42 55 ▶ for my $p ( keys %{ $dev->{files} || {} } ) {
Condition50%1/2
$$dev{'files'} || {}
l!l
550
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
43 254 ▶ next unless index( $p, "$root/" ) == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($p, "$root/") == 0 0 254 254
44 254 my $rel = substr( $p, length($root) + 1 );
45 254 ▶ next if $rel =~ m{\A\.git(?:/|\z)};
Branch: 1 branch
BranchTrueFalseTotal
if $rel =~ m[\A\.git(?:/|\z)] 0 254 254
46 254 my $e = $dev->{files}{$p};
47 254 ▶ next if ref $e eq 'HASH' && defined $e->{link};
Branch: 1 branch
BranchTrueFalseTotal
if ref $e eq "HASH" and defined $$e{"link"} 0 254 254
Condition33%1/3
ref $e eq "HASH" and defined $$e{"link"}
!ll&&!rl&&r
25400
MC/DC0%0/2
ref $e eq "HASH" and defined $$e{"link"}
ref $e eq "HASH" defined $$e{"link"}
Truth table33%1/3
A and B
A= ref $e eq "HASH"B= defined $$e{"link"}
ABresult
0X0
100
111
48 254 $w{$rel} = _text($e);
49 }
50 55 return \%w;
51 }
52  
53 18 ▶sub _set_work {
Subroutine _set_work: called CC=5 SCAR=16.2
54 18 my ( $dev, $root, $old, $new ) = @_;
55 18 ▶ for my $rel ( keys %$old ) { delete $dev->{files}{"$root/$rel"} unless exists $new->{$rel} }
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$new{$rel} 2 73 75
56 18 for my $rel ( keys %$new ) {
57 81 my $p = "$root/$rel";
58 81 my $e = $dev->{files}{$p};
59 0 ▶ if ( ref $e eq 'HASH' ) { $e->{content} = $new->{$rel} } else { $dev->{files}{$p} = $new->{$rel} }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e eq 'HASH') { } 0 81 81
60 }
61 18 return;
62 }
63  
64 39 ▶sub _ignore_res {
Subroutine _ignore_res: called CC=7 SCAR=21.1
65 39 my ($tree) = @_;
66 39 my @re;
67 39 ▶ for my $l ( split /\n/, $tree->{'.gitignore'} // '' ) {
Condition50%1/2
$$tree{".gitignore"} // ""
l!l
390
MC/DC0%0/1
$$tree{".gitignore"} // ""
$$tree{".gitignore"}
Truth table50%1/2
A
A= $$tree{".gitignore"}
Aresult
11
00
68 41 $l =~ s/\s+\z//;
69 41 ▶ next if $l eq '' || $l =~ /\A#/;
Branch: 1 branch
BranchTrueFalseTotal
if $l eq "" or $l =~ /\A#/ 0 41 41
Condition33%1/3
$l eq "" or $l =~ /\A#/
l!l&&r!l&&!r
0041
MC/DC0%0/2
$l eq "" or $l =~ /\A#/
$l eq "" $l =~ /\A#/
Truth table33%1/3
A or B
A= $l eq ""B= $l =~ /\A#/
ABresult
1X1
011
000
70 41 my $anch = $l =~ s{\A/}{};
71 41 my $dir = $l =~ s{/\z}{};
72 41 ( my $re = quotemeta $l ) =~ s/\\\*\\\*/.*/g;
73 41 $re =~ s/\\\*/[^\/]*/g;
74 41 $re =~ s/\\\?/[^\/]/g;
75 41 ▶ push @re, $anch || $l =~ m{/} ? qr{\A$re(?:/|\z)} : qr{(?:\A|/)$re(?:/|\z)};
Branch: 1 branch
BranchTrueFalseTotal
$anch || $l =~ m[/] ? : 0 41 41
Condition33%1/3
$anch or $l =~ m[/]
l!l&&r!l&&!r
0041
MC/DC0%0/2
$anch or $l =~ m[/]
$anch $l =~ m[/]
Truth table33%1/3
A or B
A= $anchB= $l =~ m[/]
ABresult
1X1
011
000
76 }
77 39 return @re;
78 }
79  
80 14 ▶sub _ignored { my ( $res, $rel ) = @_; return scalar grep { $rel =~ $_ } @$res }
Subroutine _ignored: called CC=1 SCAR=0.0
81  
82 13 ▶sub _cid {
Subroutine _cid: called CC=1 SCAR=0.0
83 13 my ($c) = @_;
84 13 return Digest::SHA::sha1_hex( $J->encode( [ $c->{parents}, $c->{message}, $c->{author}, $c->{date}, $c->{tree} ] ) );
85 }
86  
87 133 ▶sub _head { my ($r) = @_; return defined $r->{branch} ? ( $r->{refs}{heads} || {} )->{ $r->{branch} } : $r->{detached} }
Subroutine _head: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
defined $$r{'branch'} ? : 133 0 133
Condition50%1/2
$$r{'refs'}{'heads'} || {}
l!l
1330
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table50%1/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
88  
89 131 ▶sub _tree { my ( $r, $id ) = @_; return defined $id && $r->{commits}{$id} ? $r->{commits}{$id}{tree} : {} }
Subroutine _tree: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
defined $id && $$r{'commits'}{$id} ? : 131 0 131
Condition33%1/3
defined $id and $$r{"commits"}{$id}
!ll&&!rl&&r
00131
MC/DC0%0/2
defined $id and $$r{"commits"}{$id}
defined $id $$r{"commits"}{$id}
Truth table33%1/3
A and B
A= defined $idB= $$r{"commits"}{$id}
ABresult
0X0
100
111
90  
91 56 ▶sub _index { my ($r) = @_; return $r->{index} // _clone( _tree( $r, _head($r) ) ) }
Subroutine _index: called CC=2 SCAR=7.1
Condition66%2/3
$$r{"index"} // _clone(_tree($r, _head($r)))
l!l&&r!l&&!r
9470
MC/DC0%0/2
$$r{"index"} // _clone(_tree($r, _head($r)))
$$r{"index"} _clone(_tree($r, _head($r)))
Truth table66%2/3
A // B
A= $$r{"index"}B= _clone(_tree($r, _head($r)))
ABresult
1X1
011
000
92  
93 37 ▶sub _ancestors {
Subroutine _ancestors: called CC=5 SCAR=16.3
94 37 my ( $r, $id ) = @_;
95 37 my %s;
96 37 my @q = grep {defined} ($id);
97 37 ▶ while (@q) {
Branch: 1 branch
BranchTrueFalseTotal
if (@q) 107 37 144
98 107 my $x = shift @q;
99 107 ▶ next if $s{$x}++;
Branch: 1 branch
BranchTrueFalseTotal
if $s{$x}++ 0 107 107
100 107 ▶ push @q, @{ ( $r->{commits}{$x} || {} )->{parents} || [] };
Condition50%2/4
($$r{'commits'}{$x} || {})->{'parents'} || []
l!l
1070
$$r{'commits'}{$x} || {}
l!l
1070
MC/DC0%0/1
($$r{'commits'}{$x} || {})->{'parents'} || []
$$r{'commits'}{$x}
Truth table50%1/2
A
A= $$r{'commits'}{$x}
Aresult
11
00
101 }
102 37 return \%s;
103 }
104  
105 # Commits von $from (ausschliesslich) bis $to, aelteste zuerst (nur erste Eltern)
106 45 ▶sub _range {
Subroutine _range: called CC=7 SCAR=19.6
107 45 my ( $r, $from, $to ) = @_;
108 45 ▶ my $ex = defined $from ? _ancestors( $r, $from ) : {};
Branch: 1 branch
BranchTrueFalseTotal
defined $from ? : 11 34 45
109 45 my @l;
110 my %seen;
111 45 my @q = grep {defined} ($to);
112 45 ▶ while (@q) {
Branch: 1 branch
BranchTrueFalseTotal
if (@q) 125 45 170
113 125 my $x = shift @q;
114 125 ▶ next if $seen{$x}++ || $ex->{$x};
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$x}++ or $$ex{$x} 11 114 125
Condition66%2/3
$seen{$x}++ or $$ex{$x}
l!l&&r!l&&!r
011114
MC/DC50%1/2
$seen{$x}++ or $$ex{$x}
$seen{$x}++ $$ex{$x}
Truth table66%2/3
A or B
A= $seen{$x}++B= $$ex{$x}
ABresult
1X1
011
000
115 114 push @l, $x;
116 114 ▶ push @q, @{ ( $r->{commits}{$x} || {} )->{parents} || [] };
Condition50%2/4
($$r{'commits'}{$x} || {})->{'parents'} || []
l!l
1140
$$r{'commits'}{$x} || {}
l!l
1140
MC/DC0%0/1
($$r{'commits'}{$x} || {})->{'parents'} || []
$$r{'commits'}{$x}
Truth table50%1/2
A
A= $$r{'commits'}{$x}
Aresult
11
00
117 }
118 45 return sort { _order( $r, $a, $b ) } @l;
119 }
120  
121 # aelter zuerst: nach Datum, dann nach Reihenfolge des Anlegens
122 94 ▶sub _order {
Subroutine _order: called CC=7 SCAR=28.3
123 94 my ( $r, $x, $y ) = @_;
124 94 my ( $p, $q ) = ( $r->{commits}{$x}, $r->{commits}{$y} );
125 94 ▶ return ( $p->{date} // 0 ) <=> ( $q->{date} // 0 ) || ( $p->{seq} // 0 ) <=> ( $q->{seq} // 0 ) || $x cmp $y;
Condition28%4/14
($$p{'date'} // 0) <=> ($$q{'date'} // 0) || ($$p{'seq'} // 0) <=> ($$q{'seq'} // 0) || $x cmp $y
l!l&&r!l&&!r
9400
($$p{"date"} // 0) <=> ($$q{"date"} // 0) or ($$p{"seq"} // 0) <=> ($$q{"seq"} // 0)
l!l&&r!l&&!r
9400
$$p{"date"} // 0
l!l
940
$$q{"date"} // 0
l!l
940
$$p{"seq"} // 0
l!l
00
$$q{"seq"} // 0
l!l
00
MC/DC0%0/3
($$p{'date'} // 0) <=> ($$q{'date'} // 0) || ($$p{'seq'} // 0) <=> ($$q{'seq'} // 0) || $x cmp $y
$$p{"date"} $$p{"seq"} $x cmp $y
MC/DC0%0/1
$$q{"date"} // 0
$$q{"date"}
MC/DC0%0/1
$$q{"seq"} // 0
$$q{"seq"}
Truth table25%1/4
A or B || C
A= $$p{"date"}B= $$p{"seq"}C= $x cmp $y
ABCresult
1XX1
01X1
0011
0000
Truth table50%1/2
A
A= $$q{"date"}
Aresult
11
00
Truth table0%0/2
A
A= $$q{"seq"}
Aresult
11
00
126 }
127  
128 # neueste zuerst (eigene Funktion: in den Befehlen ist $a das Argument-Array)
129 4 ▶sub _newest_first { my ( $r, @ids ) = @_; return reverse sort { _order( $r, $a, $b ) } @ids }
Subroutine _newest_first: called CC=1 SCAR=0.0
130  
131 8 ▶sub _who {
Subroutine _who: called CC=7 SCAR=19.6
132 8 my ( $dev, $r ) = @_;
133 8 ▶ my %c = ( %{ ( $dev->{git} || {} )->{config} || {} }, %{ $r->{config} || {} } );
Condition83%5/6
($$dev{'git'} || {})->{'config'} || {}
l!l
71
$$dev{'git'} || {}
l!l
71
$$r{'config'} || {}
l!l
08
MC/DC100%1/1
($$dev{'git'} || {})->{'config'} || {}
$$dev{'git'}
MC/DC0%0/1
$$r{'config'} || {}
$$r{'config'}
Truth table100%2/2
A
A= $$dev{'git'}
Aresult
11
00
Truth table50%1/2
A
A= $$r{'config'}
Aresult
11
00
134 8 ▶ my $host = $dev->{hostname} // 'localhost';
Condition50%1/2
$$dev{"hostname"} // "localhost"
l!l
80
MC/DC0%0/1
$$dev{"hostname"} // "localhost"
$$dev{"hostname"}
Truth table50%1/2
A
A= $$dev{"hostname"}
Aresult
11
00
135 8 ▶ return ( $c{'user.name'} // 'root' ) . ' <' . ( $c{'user.email'} // "root\@$host" ) . '>';
Condition100%4/4
$c{"user.name"} // "root"
l!l
71
$c{"user.email"} // "root\@$host"
l!l
71
MC/DC100%1/1
$c{"user.name"} // "root"
$c{"user.name"}
MC/DC100%1/1
$c{"user.email"} // "root\@$host"
$c{"user.email"}
Truth table100%2/2
A
A= $c{"user.name"}
Aresult
11
00
Truth table100%2/2
A
A= $c{"user.email"}
Aresult
11
00
136 }
137  
138 7 ▶sub _date {
Subroutine _date: called CC=1 SCAR=0.0
139 7 my ($dev) = @_;
140 7 my $n = ++$dev->{git}{_clock};
141 7 my $t = 1792832400 + 60 * $n; # 2026-10-24 09:00 UTC, je Commit eine Minute
142 7 return $t;
143 }
144  
145 3 ▶sub _date_text {
Subroutine _date_text: called CC=1 SCAR=0.0
146 3 my ($t) = @_;
147 3 my @g = gmtime( $t + 7200 );
148 3 my @mon = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
149 3 return sprintf '%s %s %d %02d:%02d:%02d %d +0200', $DAY[ int( ( $t + 7200 ) / 86400 ) % 7 ], $mon[ $g[4] ], $g[3], @g[ 2, 1, 0 ], $g[5] + 1900;
150 }
151  
152 10 ▶sub _mk_commit {
Subroutine _mk_commit: called CC=2 SCAR=7.0
153 10 my ( $dev, $r, %c ) = @_;
154 10 ▶ $c{date} //= _date($dev);
Condition66%2/3
$c{"date"} //= _date($dev)
l!l&&r!l&&!r
370
MC/DC0%0/2
$c{"date"} //= _date($dev)
$c{"date"} _date($dev)
Truth table66%2/3
A //= B
A= $c{"date"}B= _date($dev)
ABresult
1X1
011
000
155 10 my $id = _cid( \%c );
156 10 $c{seq} = ++$dev->{git}{_seq};
157 10 $r->{commits}{$id} = \%c;
158 10 return $id;
159 }
160  
161 24 ▶sub _subject { my ($m) = @_; my ($s) = split /\n/, $m // ''; return $s // '' }
Subroutine _subject: called CC=3 SCAR=11.7
Condition50%2/4
$m // ""
l!l
240
$s // ""
l!l
240
MC/DC0%0/1
$m // ""
$m
MC/DC0%0/1
$s // ""
$s
Truth table50%1/2
A
A= $m
Aresult
11
00
Truth table50%1/2
A
A= $s
Aresult
11
00
162  
163 60 ▶sub _short { return substr( $_[0] // '', 0, 7 ) }
Subroutine _short: called CC=2 SCAR=7.6
Condition50%1/2
$_[0] // ""
l!l
600
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
164  
165 # Revision -> Commit-ID oder undef
166 30 ▶sub _rev {
Subroutine _rev: called CC=30 SCAR=45.3
167 30 my ( $r, $spec ) = @_;
168 30 ▶ return undef unless defined $spec;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $spec 0 30 30
169 30 my ( $base, $ops ) = $spec =~ /\A(.*?)((?:[~^]\d*)*)\z/;
170 30 ▶ $base = 'HEAD' if $base eq '' || $base eq '@';
Branch: 1 branch
BranchTrueFalseTotal
if $base eq "" or $base eq "\@" 0 30 30
Condition33%1/3
$base eq "" or $base eq "\@"
l!l&&r!l&&!r
0030
MC/DC0%0/2
$base eq "" or $base eq "\@"
$base eq "" $base eq "\@"
Truth table33%1/3
A or B
A= $base eq ""B= $base eq "\@"
ABresult
1X1
011
000
171 30 my $id;
172 30 ▶ if ( $base eq 'HEAD' ) { $id = _head($r) }
Branch: 7 branches
BranchTrueFalseTotal
if ($base eq 'HEAD') { } 12 18 30
elsif ($base =~ /\A(.+)\@\{u(?:pstream)?\}\z/ or $base eq '@{u}') { } 0 18 18
elsif (exists(($$r{'refs'}{'heads'} || {})->{$base})) { } 10 8 18
elsif (exists(($$r{'refs'}{'remotes'} || {})->{$base})) { } 4 4 8
elsif ($base =~ m[\Aremotes/(.+)\z] and exists(($$r{'refs'}{'remotes'} || {})->{$1})) { } 0 4 4
elsif (exists(($$r{'refs'}{'tags'} || {})->{$base})) { } 1 3 4
elsif ($base =~ /\A[0-9a-f]{4,40}\z/) { } 3 0 3
173 0 ▶ elsif ( $base =~ /\A(.+)\@\{u(?:pstream)?\}\z/ || $base eq '@{u}' ) { my $b = $1 // $r->{branch}; $id = ( $r->{refs}{remotes} || {} )->{"origin/$b"} }
Condition12%1/8
$base =~ /\A(.+)\@\{u(?:pstream)?\}\z/ or $base eq "\@{u}"
l!l&&r!l&&!r
0018
$1 // $$r{"branch"}
l!l&&r!l&&!r
000
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/2
$base =~ /\A(.+)\@\{u(?:pstream)?\}\z/ or $base eq "\@{u}"
$base =~ /\A(.+)\@\{u(?:pstream)?\}\z/ $base eq "\@{u}"
MC/DC0%0/2
$1 // $$r{"branch"}
$1 $$r{"branch"}
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table33%1/3
A or B
A= $base =~ /\A(.+)\@\{u(?:pstream)?\}\z/B= $base eq "\@{u}"
ABresult
1X1
011
000
Truth table0%0/3
A // B
A= $1B= $$r{"branch"}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
174 10 ▶ elsif ( exists( ( $r->{refs}{heads} || {} )->{$base} ) ) { $id = $r->{refs}{heads}{$base} }
Condition50%1/2
$$r{'refs'}{'heads'} || {}
l!l
180
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table50%1/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
175 4 ▶ elsif ( exists( ( $r->{refs}{remotes} || {} )->{$base} ) ) { $id = $r->{refs}{remotes}{$base} }
Condition100%2/2
$$r{'refs'}{'remotes'} || {}
l!l
71
MC/DC100%1/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table100%2/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
176 0 ▶ elsif ( $base =~ m{\Aremotes/(.+)\z} && exists( ( $r->{refs}{remotes} || {} )->{$1} ) ) { $id = $r->{refs}{remotes}{$1} }
Condition20%1/5
$base =~ m[\Aremotes/(.+)\z] and exists(($$r{"refs"}{"remotes"} || {})->{$1})
!ll&&!rl&&r
400
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/2
$base =~ m[\Aremotes/(.+)\z] and exists(($$r{"refs"}{"remotes"} || {})->{$1})
$base =~ m[\Aremotes/(.+)\z] $$r{'refs'}{'remotes'}
Truth table33%1/3
A and B
A= $base =~ m[\Aremotes/(.+)\z]B= $$r{'refs'}{'remotes'}
ABresult
0X0
100
111
177 1 ▶ elsif ( exists( ( $r->{refs}{tags} || {} )->{$base} ) ) { $id = $r->{refs}{tags}{$base}{commit} }
Condition50%1/2
$$r{'refs'}{'tags'} || {}
l!l
40
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table50%1/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
178 elsif ( $base =~ /\A[0-9a-f]{4,40}\z/ ) {
179 3 ▶ my @m = grep { index( $_, $base ) == 0 } keys %{ $r->{commits} || {} };
Condition50%1/2
$$r{'commits'} || {}
l!l
30
MC/DC0%0/1
$$r{'commits'} || {}
$$r{'commits'}
Truth table50%1/2
A
A= $$r{'commits'}
Aresult
11
00
180 3 ▶ $id = $m[0] if @m == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @m == 1 3 0 3
181 }
182 30 ▶ return undef unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 30 30
183 30 ▶ while ( $ops =~ /\G([~^])(\d*)/gc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ops =~ /\G([~^])(\d*)/cg) 1 30 31
184 1 ▶ my ( $o, $n ) = ( $1, length $2 ? $2 : 1 );
Branch: 1 branch
BranchTrueFalseTotal
length $2 ? : 1 0 1
185 1 ▶ if ( $o eq '~' ) { for ( 1 .. $n ) { $id = ( $r->{commits}{$id}{parents} || [] )->[0] // return undef } }
Branch: 1 branch
BranchTrueFalseTotal
if ($o eq '~') { } 1 0 1
Condition50%2/4
($$r{"commits"}{$id}{"parents"} || [])->[0] // (return undef)
l!l
10
$$r{'commits'}{$id}{'parents'} || []
l!l
10
MC/DC0%0/1
($$r{"commits"}{$id}{"parents"} || [])->[0] // (return undef)
$$r{'commits'}{$id}{'parents'}
Truth table50%1/2
A
A= $$r{'commits'}{$id}{'parents'}
Aresult
11
00
186 0 ▶ else { $id = ( $r->{commits}{$id}{parents} || [] )->[ $n - 1 ] // return undef }
Condition0%0/4
($$r{"commits"}{$id}{"parents"} || [])->[$n - 1] // (return undef)
l!l
00
$$r{'commits'}{$id}{'parents'} || []
l!l
00
MC/DC0%0/1
($$r{"commits"}{$id}{"parents"} || [])->[$n - 1] // (return undef)
$$r{'commits'}{$id}{'parents'}
Truth table0%0/2
A
A= $$r{'commits'}{$id}{'parents'}
Aresult
11
00
187 }
188 30 return $id;
189 }
190  
191 # --- Ausgabe von Unterschieden ------------------------------------------------------------
192  
193 4 ▶sub _lines { my ($t) = @_; return () unless defined $t && length $t; return split /\n/, $t, -1 }
Subroutine _lines: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
unless defined $t and length $t 1 3 4
Condition66%2/3
defined $t and length $t
!ll&&!rl&&r
103
MC/DC50%1/2
defined $t and length $t
defined $t length $t
Truth table66%2/3
A and B
A= defined $tB= length $t
ABresult
0X0
100
111
194  
195 2 ▶sub _udiff {
Subroutine _udiff: called CC=23 SCAR=34.3
196 2 my ( $path, $old, $new ) = @_;
197 2 my @a = _lines($old);
198 2 my @b = _lines($new);
199 2 ▶ pop @a if @a && $a[-1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if @a and $a[-1] eq "" 1 1 2
Condition66%2/3
@a and $a[-1] eq ""
!ll&&!rl&&r
101
MC/DC50%1/2
@a and $a[-1] eq ""
@a $a[-1] eq ""
Truth table66%2/3
A and B
A= @aB= $a[-1] eq ""
ABresult
0X0
100
111
200 2 ▶ pop @b if @b && $b[-1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if @b and $b[-1] eq "" 2 0 2
Condition33%1/3
@b and $b[-1] eq ""
!ll&&!rl&&r
002
MC/DC0%0/2
@b and $b[-1] eq ""
@b $b[-1] eq ""
Truth table33%1/3
A and B
A= @bB= $b[-1] eq ""
ABresult
0X0
100
111
201 # LCS (kleine Dateien)
202 2 my @L = map { [ (0) x ( @b + 1 ) ] } 0 .. @a;
203 2 ▶ for my $i ( reverse 0 .. $#a ) { for my $j ( reverse 0 .. $#b ) { $L[$i][$j] = $a[$i] eq $b[$j] ? $L[ $i + 1 ][ $j + 1 ] + 1 : $L[ $i + 1 ][$j] > $L[$i][ $j + 1 ] ? $L[ $i + 1 ][$j] : $L[$i][ $j + 1 ] } }
Branch: 2 branches
BranchTrueFalseTotal
$a[$i] eq $b[$j] ? : 0 1 1
$L[$i + 1][$j] > $L[$i][$j + 1] ? : 0 1 1
204 2 my ( $i, $j, @o ) = ( 0, 0 );
205 2 ▶ while ( $i < @a || $j < @b ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @a or $j < @b) 3 2 5
Condition100%3/3
$i < @a or $j < @b
l!l&&r!l&&!r
122
MC/DC100%2/2
$i < @a or $j < @b
$i < @a $j < @b
Truth table100%3/3
A or B
A= $i < @aB= $j < @b
ABresult
1X1
011
000
206 0 ▶ if ( $i < @a && $j < @b && $a[$i] eq $b[$j] ) { push @o, " $a[$i]"; $i++; $j++ }
Branch: 2 branches
BranchTrueFalseTotal
if ($i < @a and $j < @b and $a[$i] eq $b[$j]) { } 0 3 3
elsif ($j < @b and $i >= @a || $L[$i][$j + 1] > $L[$i + 1][$j]) { } 2 1 3
Condition66%4/6
$i < @a and $j < @b and $a[$i] eq $b[$j]
!ll&&!rl&&r
210
$i < @a and $j < @b
!ll&&!rl&&r
201
MC/DC0%0/3
$i < @a and $j < @b and $a[$i] eq $b[$j]
$i < @a $j < @b $a[$i] eq $b[$j]
Truth table50%2/4
A and B and C
A= $i < @aB= $j < @bC= $a[$i] eq $b[$j]
ABCresult
0XX0
10X0
1100
1111
207 2 ▶ elsif ( $j < @b && ( $i >= @a || $L[$i][ $j + 1 ] > $L[ $i + 1 ][$j] ) ) { push @o, "+$b[$j]"; $j++ }
Condition66%4/6
$j < @b and $i >= @a || $L[$i][$j + 1] > $L[$i + 1][$j]
!ll&&!rl&&r
012
$i >= @a or $L[$i][$j + 1] > $L[$i + 1][$j]
l!l&&r!l&&!r
201
MC/DC33%1/3
$j < @b and $i >= @a || $L[$i][$j + 1] > $L[$i + 1][$j]
$j < @b $i >= @a $L[$i][$j + 1] > $L[$i + 1][$j]
Truth table50%2/4
A and B or C
A= $j < @bB= $i >= @aC= $L[$i][$j + 1] > $L[$i + 1][$j]
ABCresult
0XX0
1000
11X1
1011
208 1 else { push @o, "-$a[$i]"; $i++ }
209 }
210 2 ▶ my @h = ( "diff --git a/$path b/$path", ( !defined $old ? 'new file mode 100644' : !defined $new ? 'deleted file mode 100644' : () ),
Branch: 6 branches
BranchTrueFalseTotal
!defined($old) ? : 1 1 2
!defined($new) ? : 0 1 1
defined $old ? : 1 1 2
defined $new ? : 2 0 2
@a ? : 1 1 2
@b ? : 2 0 2
211 '--- ' . ( defined $old ? "a/$path" : '/dev/null' ), '+++ ' . ( defined $new ? "b/$path" : '/dev/null' ), sprintf( '@@ -%d,%d +%d,%d @@', @a ? 1 : 0, scalar @a, @b ? 1 : 0, scalar @b ) );
212 2 return join "\n", @h, @o;
213 }
214  
215 9 ▶sub _diff_trees {
Subroutine _diff_trees: called CC=13 SCAR=26.4
216 9 my ( $x, $y, $mode ) = @_;
217 9 my @p = sort { $a cmp $b } keys %{ { %$x, %$y } };
218 9 ▶ my @ch = grep { ( $x->{$_} // "\0none" ) ne ( $y->{$_} // "\0none" ) } @p;
Condition75%3/4
$$x{$_} // "\0none"
l!l
382
$$y{$_} // "\0none"
l!l
400
MC/DC100%1/1
$$x{$_} // "\0none"
$$x{$_}
MC/DC0%0/1
$$y{$_} // "\0none"
$$y{$_}
Truth table100%2/2
A
A= $$x{$_}
Aresult
11
00
Truth table50%1/2
A
A= $$y{$_}
Aresult
11
00
219 9 ▶ return join( "\n", @ch ) if ( $mode // '' ) eq 'name-only';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode // "") eq "name-only" 7 2 9
Condition100%2/2
$mode // ""
l!l
81
MC/DC100%1/1
$mode // ""
$mode
Truth table100%2/2
A
A= $mode
Aresult
11
00
220 2 ▶ if ( ( $mode // '' ) eq 'stat' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($mode // "") eq "stat") 1 1 2
Condition100%2/2
$mode // ""
l!l
11
MC/DC100%1/1
$mode // ""
$mode
Truth table100%2/2
A
A= $mode
Aresult
11
00
221 1 ▶ return '' unless @ch;
Branch: 1 branch
BranchTrueFalseTotal
unless @ch 0 1 1
222 1 my ( $ins, $del ) = ( 0, 0 );
223 1 my @l = map { my $d = _udiff( $_, $x->{$_}, $y->{$_} ); my $pl = () = $d =~ /^\+(?!\+\+ )/mg; my $mi = () = $d =~ /^-(?!-- )/mg; $ins += $pl; $del += $mi;
224 1 sprintf( ' %-30s | %3d %s', $_, $pl + $mi, ( '+' x $pl ) . ( '-' x $mi ) ) } @ch;
225 1 ▶ return join "\n", @l, sprintf( ' %d file%s changed', scalar @ch, @ch == 1 ? '' : 's' )
Branch: 5 branches
BranchTrueFalseTotal
@ch == 1 ? : 1 0 1
$ins ? : 1 0 1
$ins == 1 ? : 1 0 1
$del ? : 0 1 1
$del == 1 ? : 0 0 0
226 . ( $ins ? sprintf( ', %d insertion%s(+)', $ins, $ins == 1 ? '' : 's' ) : '' ) . ( $del ? sprintf( ', %d deletion%s(-)', $del, $del == 1 ? '' : 's' ) : '' );
227 }
228 1 return join "\n", map { _udiff( $_, $x->{$_}, $y->{$_} ) } @ch;
229 }
230  
231 # --- Kommandozeile ----------------------------------------------------------------------------
232  
233  
234 75 ▶sub git {
Subroutine git: called CC=33 SCAR=43.9
Pod documented
235 75 my ( $dev, $av, $ctx, $cwd ) = @_;
236 75 my @a = @$av;
237 75 my $dir = $cwd;
238 75 ▶ while ( @a && $a[0] =~ /\A-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a and $a[0] =~ /\A-/) 4 75 79
Condition66%2/3
@a and $a[0] =~ /\A-/
!ll&&!rl&&r
0754
MC/DC50%1/2
@a and $a[0] =~ /\A-/
@a $a[0] =~ /\A-/
Truth table66%2/3
A and B
A= @aB= $a[0] =~ /\A-/
ABresult
0X0
100
111
239 4 my $x = shift @a;
240 4 ▶ if ( $x eq '-C' ) { my $d = shift @a // ''; $dir = $d =~ m{\A/} ? $d : ( $dir // '/root' ) . "/$d" }
Branch: 5 branches
BranchTrueFalseTotal
if ($x eq '-C') { } 4 0 4
elsif ($x eq '-c') { } 0 0 0
elsif ($x eq '--no-pager' or $x eq '-P') { } 0 0 0
elsif ($x eq '--version') { } 0 0 0
$d =~ m[\A/] ? : 4 0 4
Condition25%1/4
shift @a // ""
l!l
40
$dir // "/root"
l!l
00
MC/DC0%0/1
shift @a // ""
shift @a
MC/DC0%0/1
$dir // "/root"
$dir
Truth table50%1/2
A
A= shift @a
Aresult
11
00
Truth table0%0/2
A
A= $dir
Aresult
11
00
241 0 elsif ( $x eq '-c' ) { shift @a }
242 ▶ elsif ( $x eq '--no-pager' || $x eq '-P' ) { }
Condition0%0/3
$x eq "--no-pager" or $x eq "-P"
l!l&&r!l&&!r
000
MC/DC0%0/2
$x eq "--no-pager" or $x eq "-P"
$x eq "--no-pager" $x eq "-P"
Truth table0%0/3
A or B
A= $x eq "--no-pager"B= $x eq "-P"
ABresult
1X1
011
000
243 0 elsif ( $x eq '--version' ) { return ( 'git version 2.39.5', 1 ) }
244 0 else { return ( "unknown option: $x\nusage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]", 0 ) }
245 }
246 75 ▶ my $verb = shift(@a) // return ( "usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n <command> [<args>]", 0 );
Condition50%1/2
shift @a // (return "usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n <command> [<args>]", 0)
l!l
750
MC/DC0%0/1
shift @a // (return "usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n <command> [<args>]", 0)
shift @a
Truth table50%1/2
A
A= shift @a
Aresult
11
00
247 75 ▶ $verb = 'status' if $verb eq 'st';
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "st" 0 75 75
248 0 ▶ if ( $verb eq 'config' && grep { $_ eq '--global' } @a ) { return _config( $dev, undef, \@a ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "config" and grep {$_ eq "--global";} @a) 0 75 75
Condition66%2/3
$verb eq "config" and grep {$_ eq "--global";} @a
!ll&&!rl&&r
7410
MC/DC0%0/2
$verb eq "config" and grep {$_ eq "--global";} @a
$verb eq "config" grep {$_ eq "--global";} @a
Truth table66%2/3
A and B
A= $verb eq "config"B= grep {$_ eq "--global";} @a
ABresult
0X0
100
111
249 75 ▶ return ( 'git version 2.39.5', 1 ) if $verb eq 'version';
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "version" 0 75 75
250 75 ▶ my ( $root, $r ) = _repo_at( $dev, $dir // '/root' );
Condition100%2/2
$dir // "/root"
l!l
741
MC/DC100%1/1
$dir // "/root"
$dir
Truth table100%2/2
A
A= $dir
Aresult
11
00
251 75 ▶ if ( !$r && ( my ( $bp, $key ) = _bare_at( $dev, $dir // '/root' ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $r and () = _bare_at($dev, $dir // "/root")) 4 71 75
Condition100%5/5
not $r and () = _bare_at($dev, $dir // "/root")
!ll&&!rl&&r
7014
$dir // "/root"
l!l
41
MC/DC100%2/2
not $r and () = _bare_at($dev, $dir // "/root")
not $r () = _bare_at($dev, $dir // "/root")
MC/DC100%1/1
$dir // "/root"
$dir
Truth table100%3/3
not(A) and B
A= not $rB= () = _bare_at($dev, $dir // "/root")
ABresult
0X0
100
111
Truth table100%2/2
A
A= $dir
Aresult
11
00
252 # Bare-Repo auf dem Server: lesen, Tags und Zweige setzen; kein Arbeitsbaum
253 4 ▶ return ( 'fatal: this operation must be run in a work tree', 0 ) if $verb =~ /\A(?:status|add|rm|mv|restore|commit|checkout|switch|reset|pull|merge|rebase|cherry-pick|revert|stash|diff|clean)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $verb =~ /\A(?:status|add|rm|mv|restore|commit|checkout|switch|reset|pull|merge|rebase|cherry-pick|revert|stash|diff|clean)\z/ 1 3 4
254 3 ( my $sub = "_g_$verb" ) =~ s/-/_/g;
255 my $f = $verb =~ /\A(?:log|show|tag|branch|rev-parse|describe|config|update-ref|ls-tree|for-each-ref|show-ref|cat-file|ls-remote|count-objects|rev-list|merge-base|fsck)\z/ && __PACKAGE__->can($sub)
256 0 ▶ or do { push @GAPS, "git $verb (bare)"; return ( '', 0 ) };
Branch: 1 branch
BranchTrueFalseTotal
my $f = $verb =~ /\A(?:log|show|tag|branch|rev-parse|describe|config|update-ref|ls-tree|for-each-ref|show-ref|cat-file|ls-remote|count-objects|rev-list|merge-base|fsck)\z/ && __PACKAGE__->can($sub) or do { push @Langertha::Holmgang::Sim::Linux::Git::GAPS, "git $verb (bare)"; return "", 0 } 3 0 3
Condition33%1/3
$verb =~ /\A(?:log|show|tag|branch|rev-parse|describe|config|update-ref|ls-tree|for-each-ref|show-ref|cat-file|ls-remote|count-objects|rev-list|merge-base|fsck)\z/ && __PACKAGE__->can($sub)
!ll&&!rl&&r
003
MC/DC0%0/2
$verb =~ /\A(?:log|show|tag|branch|rev-parse|describe|config|update-ref|ls-tree|for-each-ref|show-ref|cat-file|ls-remote|count-objects|rev-list|merge-base|fsck)\z/ && __PACKAGE__->can($sub)
$verb =~ /\A(?:log|show|tag|branch|rev-parse|describe|config|update-ref|ls-tree|for-each-ref|show-ref|cat-file|ls-remote|count-objects|rev-list|merge-base|fsck)\z/ __PACKAGE__->can($sub)
Truth table33%1/3
A && B
A= $verb =~ /\A(?:log|show|tag|branch|rev-parse|describe|config|update-ref|ls-tree|for-each-ref|show-ref|cat-file|ls-remote|count-objects|rev-list|merge-base|fsck)\z/B= __PACKAGE__->can($sub)
ABresult
0X0
100
111
257 3 my $copy = _clone($dev);
258 3 my $s = $copy->{forgejo}{repos}{$key};
259 3 local $s->{branch} = 'main';
260 3 local $CWD = $dir;
261 3 my ( $out, $ok ) = $f->( $copy, $bp, $s, \@a, $ctx );
262 3 delete $s->{branch};
263 3 ▶ if ($ok) { view($s); %$dev = %$copy }
Branch: 1 branch
BranchTrueFalseTotal
if ($ok) 3 0 3
264 3 ▶ return ( $out // '', $ok );
Condition50%1/2
$out // ""
l!l
30
MC/DC0%0/1
$out // ""
$out
Truth table50%1/2
A
A= $out
Aresult
11
00
265 }
266 71 ▶ unless ($r) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r) 1 70 71
267 1 ▶ return ( "fatal: not a git repository (or any of the parent directories): .git", 0 ) unless $verb =~ /\A(?:clone|init|help)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $verb =~ /\A(?:clone|init|help)\z/ 1 0 1
268 0 push @GAPS, "git $verb";
269 0 return ( '', 0 );
270 }
271 70 ( my $sub = "_g_$verb" ) =~ s/-/_/g;
272 70 ▶ my $f = $verb =~ /\A[a-z-]+\z/ && __PACKAGE__->can($sub);
Condition33%1/3
$verb =~ /\A[a-z-]+\z/ && __PACKAGE__->can($sub)
!ll&&!rl&&r
0070
MC/DC0%0/2
$verb =~ /\A[a-z-]+\z/ && __PACKAGE__->can($sub)
$verb =~ /\A[a-z-]+\z/ __PACKAGE__->can($sub)
Truth table33%1/3
A && B
A= $verb =~ /\A[a-z-]+\z/B= __PACKAGE__->can($sub)
ABresult
0X0
100
111
273 70 ▶ unless ($f) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($f) 0 70 70
274 0 ▶ return ( "git: '$verb' is not a git command. See 'git --help'.", 0 ) unless $verb =~ /\A(?:stash|cherry-pick|revert|bisect|blame|reflog|worktree|submodule|clean|gc|fsck|am|apply|format-patch|grep|describe|shortlog|notes|archive|bundle|clone|init|filter-branch|filter-repo|lfs|range-diff|show-ref|cat-file|symbolic-ref|update-ref|for-each-ref|merge-base|whatchanged|sparse-checkout|mergetool|difftool|gui|help|commit-tree|hash-object|ls-tree|rev-list)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $verb =~ /\A(?:stash|cherry-pick|revert|bisect|blame|reflog|worktree|submodule|clean|gc|fsck|am|apply|format-patch|grep|describe|shortlog|notes|archive|bundle|clone|init|filter-branch|filter-repo|lfs|range-diff|show-ref|cat-file|symbolic-ref|update-ref|for-each-ref|merge-base|whatchanged|sparse-checkout|mergetool|difftool|gui|help|commit-tree|hash-object|ls-tree|rev-list)\z/ 0 0 0
275 0 push @GAPS, "git $verb";
276 0 return ( '', 0 );
277 }
278 # gescheiterte Aenderungen hinterlassen nichts
279 70 my $copy = _clone($dev);
280 70 my ( $croot, $cr ) = _repo_at( $copy, $root );
281 70 local $CWD = $dir;
282 70 my ( $out, $ok, $keep ) = $f->( $copy, $croot, $cr, \@a, $ctx );
283 70 ▶ if ( $ok || $keep ) { %$dev = %$copy }
Branch: 1 branch
BranchTrueFalseTotal
if ($ok or $keep) 68 2 70
Condition100%3/3
$ok or $keep
l!l&&r!l&&!r
6172
MC/DC100%2/2
$ok or $keep
$ok $keep
Truth table100%3/3
A or B
A= $okB= $keep
ABresult
1X1
011
000
284 70 ▶ return ( $out // '', $ok );
Condition50%1/2
$out // ""
l!l
700
MC/DC0%0/1
$out // ""
$out
Truth table50%1/2
A
A= $out
Aresult
11
00
285 }
286  
287 1 ▶sub _config {
Subroutine _config: called CC=31 SCAR=59.3
288 1 my ( $dev, $r, $a ) = @_;
289 1 my $global = !$r;
290 1 my @x = grep { !/\A--(?:global|local)\z/ } @$a;
291 1 ▶ my $c = $global ? ( $dev->{git}{config} ||= {} ) : ( $r->{config} ||= {} );
Branch: 1 branch
BranchTrueFalseTotal
$global ? : 0 1 1
Condition25%1/4
$$dev{"git"}{"config"} ||= {}
l!l
00
$$r{"config"} ||= {}
l!l
01
MC/DC0%0/1
$$dev{"git"}{"config"} ||= {}
$$dev{"git"}{"config"}
MC/DC0%0/1
$$r{"config"} ||= {}
$$r{"config"}
Truth table0%0/2
A
A= $$dev{"git"}{"config"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"config"}
Aresult
11
00
292 1 ▶ if ( grep { $_ eq '--list' || $_ eq '-l' } @x ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "--list" or $_ eq "-l";} @x) 0 1 1
Condition33%1/3
$_ eq '--list' || $_ eq '-l'
l!l&&r!l&&!r
002
MC/DC0%0/2
$_ eq '--list' || $_ eq '-l'
$_ eq '--list' $_ eq '-l'
Truth table33%1/3
A || B
A= $_ eq '--list'B= $_ eq '-l'
ABresult
1X1
011
000
293 0 ▶ my %all = $global ? %$c : ( %{ ( $dev->{git} || {} )->{config} || {} }, 'core.repositoryformatversion' => 0, 'core.bare' => 'false', %$c,
Condition0%0/4
($$dev{'git'} || {})->{'config'} || {}
l!l
00
$$dev{'git'} || {}
l!l
00
MC/DC0%0/1
($$dev{'git'} || {})->{'config'} || {}
$$dev{'git'}
Truth table0%0/2
A
A= $$dev{'git'}
Aresult
11
00
294 0 ▶ map { ( "remote.$_.url" => $r->{remotes}{$_}{url}, "remote.$_.fetch" => "+refs/heads/*:refs/remotes/$_/*" ) } sort keys %{ $r->{remotes} || {} } );
Branch: 1 branch
BranchTrueFalseTotal
$global ? : 0 0 0
Condition0%0/2
$$r{'remotes'} || {}
l!l
00
MC/DC0%0/1
$$r{'remotes'} || {}
$$r{'remotes'}
Truth table0%0/2
A
A= $$r{'remotes'}
Aresult
11
00
295 0 return ( join( "\n", map {"$_=$all{$_}"} sort keys %all ), 1 );
296 }
297 0 ▶ if ( ( $x[0] // '' ) eq '--unset' ) { my $k = $x[1] // return ( 'error: wrong number of arguments', 0 ); return ( '', 0 ) unless exists $c->{$k}; delete $c->{$k}; return ( '', 1 ) }
Branch: 2 branches
BranchTrueFalseTotal
if (($x[0] // "") eq "--unset") 0 1 1
unless exists $$c{$k} 0 0 0
Condition25%1/4
$x[0] // ""
l!l
10
$x[1] // (return "error: wrong number of arguments", 0)
l!l
00
MC/DC0%0/1
$x[0] // ""
$x[0]
MC/DC0%0/1
$x[1] // (return "error: wrong number of arguments", 0)
$x[1]
Truth table50%1/2
A
A= $x[0]
Aresult
11
00
Truth table0%0/2
A
A= $x[1]
Aresult
11
00
298 1 ▶ my $get = ( $x[0] // '' ) eq '--get' ? shift @x : undef;
Branch: 1 branch
BranchTrueFalseTotal
($x[0] // '') eq '--get' ? : 0 1 1
Condition50%1/2
$x[0] // ""
l!l
10
MC/DC0%0/1
$x[0] // ""
$x[0]
Truth table50%1/2
A
A= $x[0]
Aresult
11
00
299 1 my ( $k, $v ) = @x;
300 1 ▶ return ( 'error: key does not contain a section: ' . ( $k // '' ), 0 ) unless defined $k && $k =~ /\./;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $k and $k =~ /\./ 0 1 1
Condition20%1/5
defined $k and $k =~ /\./
!ll&&!rl&&r
001
$k // ""
l!l
00
MC/DC0%0/2
defined $k and $k =~ /\./
defined $k $k =~ /\./
MC/DC0%0/1
$k // ""
$k
Truth table33%1/3
A and B
A= defined $kB= $k =~ /\./
ABresult
0X0
100
111
Truth table0%0/2
A
A= $k
Aresult
11
00
301 1 ▶ if ( !defined $v ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v) 0 1 1
302 0 ▶ my $val = $global ? $c->{$k} : $c->{$k} // ( ( $dev->{git} || {} )->{config} || {} )->{$k};
Branch: 1 branch
BranchTrueFalseTotal
$global ? : 0 0 0
Condition0%0/7
$$c{$k} // (($$dev{"git"} || {})->{"config"} || {})->{$k}
l!l&&r!l&&!r
000
($$dev{'git'} || {})->{'config'} || {}
l!l
00
$$dev{'git'} || {}
l!l
00
MC/DC0%0/2
$$c{$k} // (($$dev{"git"} || {})->{"config"} || {})->{$k}
$$c{$k} $$dev{'git'}
Truth table0%0/3
A // B
A= $$c{$k}B= $$dev{'git'}
ABresult
1X1
011
000
303 0 ▶ $val //= $r->{remotes}{$1}{url} if !$global && $k =~ /\Aremote\.([^.]+)\.url\z/ && $r->{remotes}{$1};
Branch: 1 branch
BranchTrueFalseTotal
if not $global and $k =~ /\Aremote\.([^.]+)\.url\z/ and $$r{"remotes"}{$1} 0 0 0
Condition0%0/9
not $global and $k =~ /\Aremote\.([^.]+)\.url\z/ and $$r{"remotes"}{$1}
!ll&&!rl&&r
000
not $global and $k =~ /\Aremote\.([^.]+)\.url\z/
!ll&&!rl&&r
000
$val //= $$r{"remotes"}{$1}{"url"}
l!l&&r!l&&!r
000
MC/DC0%0/3
not $global and $k =~ /\Aremote\.([^.]+)\.url\z/ and $$r{"remotes"}{$1}
not $global $k =~ /\Aremote\.([^.]+)\.url\z/ $$r{"remotes"}{$1}
MC/DC0%0/2
$val //= $$r{"remotes"}{$1}{"url"}
$val $$r{"remotes"}{$1}{"url"}
Truth table0%0/4
not(A) and B and C
A= not $globalB= $k =~ /\Aremote\.([^.]+)\.url\z/C= $$r{"remotes"}{$1}
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A //= B
A= $valB= $$r{"remotes"}{$1}{"url"}
ABresult
1X1
011
000
304 0 ▶ return defined $val ? ( $val, 1 ) : ( '', 0 );
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 0 0 0
305 }
306 1 ▶ if ( !$global && $k =~ /\Aremote\.([^.]+)\.url\z/ ) { # steht in .git/config beim Remote
Branch: 1 branch
BranchTrueFalseTotal
if (not $global and $k =~ /\Aremote\.([^.]+)\.url\z/) 0 1 1
Condition33%1/3
not $global and $k =~ /\Aremote\.([^.]+)\.url\z/
!ll&&!rl&&r
010
MC/DC0%0/2
not $global and $k =~ /\Aremote\.([^.]+)\.url\z/
not $global $k =~ /\Aremote\.([^.]+)\.url\z/
Truth table33%1/3
not(A) and B
A= not $globalB= $k =~ /\Aremote\.([^.]+)\.url\z/
ABresult
0X0
100
111
307 0 $r->{remotes}{$1} = { url => $v, _resolve_remote( $dev, $v ) };
308 0 return ( '', 1 );
309 }
310 1 $c->{ lc($k) =~ s/\A(user|core|push|pull|init|commit)\.(.*)\z/$1.$2/r } = $v;
311 1 return ( '', 1 );
312 }
313  
314 1 ▶sub _g_config { my ( $dev, $root, $r, $a ) = @_; return _config( $dev, $r, $a ) }
Subroutine _g_config: called CC=1 SCAR=0.0
315  
316 2 ▶sub _g_remote {
Subroutine _g_remote: called CC=33 SCAR=50.2
317 2 my ( $dev, $root, $r, $a, $ctx ) = @_;
318 2 ▶ my $rm = $r->{remotes} || {};
Condition50%1/2
$$r{'remotes'} || {}
l!l
20
MC/DC0%0/1
$$r{'remotes'} || {}
$$r{'remotes'}
Truth table50%1/2
A
A= $$r{'remotes'}
Aresult
11
00
319 0 ▶ return ( join( "\n", map { ( "$_\t$rm->{$_}{url} (fetch)", "$_\t$rm->{$_}{url} (push)" ) } sort keys %$rm ), 1 ) if grep { $_ eq '-v' } @$a;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq "-v";} @$a 0 2 2
320 2 ▶ return ( join( "\n", sort keys %$rm ), 1 ) unless @$a;
Branch: 1 branch
BranchTrueFalseTotal
unless @$a 0 2 2
321 0 ▶ if ( $a->[0] eq 'get-url' ) { my $x = $rm->{ $a->[1] // '' } or return ( "error: No such remote '" . ( $a->[1] // '' ) . "'", 0 ); return ( $x->{url}, 1 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($$a[0] eq "get-url") 0 2 2
my $x = $$rm{$$a[1] // ""} or return q[error: No such remote '] . ($$a[1] // "") . q['], 0 0 0 0
Condition0%0/4
$$a[1] // ""
l!l
00
$$a[1] // ""
l!l
00
MC/DC0%0/1
$$a[1] // ""
$$a[1]
MC/DC0%0/1
$$a[1] // ""
$$a[1]
Truth table0%0/2
A
A= $$a[1]
Aresult
11
00
Truth table0%0/2
A
A= $$a[1]
Aresult
11
00
322 2 ▶ if ( $a->[0] eq 'set-url' || $a->[0] eq 'add' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$a[0] eq "set-url" or $$a[0] eq "add") 1 1 2
Condition66%2/3
$$a[0] eq "set-url" or $$a[0] eq "add"
l!l&&r!l&&!r
101
MC/DC50%1/2
$$a[0] eq "set-url" or $$a[0] eq "add"
$$a[0] eq "set-url" $$a[0] eq "add"
Truth table66%2/3
A or B
A= $$a[0] eq "set-url"B= $$a[0] eq "add"
ABresult
1X1
011
000
323 1 my ( undef, $name, $url ) = grep { !/\A--/ } @$a;
324 1 ▶ return ( 'usage: git remote ' . $a->[0] . ' <name> <newurl>', 0 ) unless defined $url;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $url 0 1 1
325 1 ▶ return ( "error: No such remote '$name'", 0 ) if $a->[0] eq 'set-url' && !$rm->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $$a[0] eq "set-url" and not $$rm{$name} 0 1 1
Condition33%1/3
$$a[0] eq "set-url" and not $$rm{$name}
!ll&&!rl&&r
010
MC/DC0%0/2
$$a[0] eq "set-url" and not $$rm{$name}
$$a[0] eq "set-url" not $$rm{$name}
Truth table33%1/3
A and not(B)
A= $$a[0] eq "set-url"B= not $$rm{$name}
ABresult
0X0
100
111
326 1 ▶ return ( "error: remote $name already exists.", 0 ) if $a->[0] eq 'add' && $rm->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $$a[0] eq "add" and $$rm{$name} 0 1 1
Condition33%1/3
$$a[0] eq "add" and $$rm{$name}
!ll&&!rl&&r
100
MC/DC0%0/2
$$a[0] eq "add" and $$rm{$name}
$$a[0] eq "add" $$rm{$name}
Truth table33%1/3
A and B
A= $$a[0] eq "add"B= $$rm{$name}
ABresult
0X0
100
111
327 1 $r->{remotes}{$name} = { url => $url, _resolve_remote( $dev, $url ) };
328 1 return ( '', 1 );
329 }
330 1 ▶ if ( $a->[0] eq 'remove' || $a->[0] eq 'rm' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$a[0] eq "remove" or $$a[0] eq "rm") 0 1 1
Condition33%1/3
$$a[0] eq "remove" or $$a[0] eq "rm"
l!l&&r!l&&!r
001
MC/DC0%0/2
$$a[0] eq "remove" or $$a[0] eq "rm"
$$a[0] eq "remove" $$a[0] eq "rm"
Truth table33%1/3
A or B
A= $$a[0] eq "remove"B= $$a[0] eq "rm"
ABresult
1X1
011
000
331 0 ▶ my $name = $a->[1] // '';
Condition0%0/2
$$a[1] // ""
l!l
00
MC/DC0%0/1
$$a[1] // ""
$$a[1]
Truth table0%0/2
A
A= $$a[1]
Aresult
11
00
332 0 ▶ return ( "error: No such remote: '$name'", 0 ) unless $rm->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $$rm{$name} 0 0 0
333 0 delete $r->{remotes}{$name};
334 0 ▶ delete $r->{refs}{remotes}{$_} for grep { index( $_, "$name/" ) == 0 } keys %{ $r->{refs}{remotes} || {} };
Condition0%0/2
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table0%0/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
335 0 return ( '', 1 );
336 }
337 1 ▶ if ( $a->[0] eq 'show' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$a[0] eq "show") 1 0 1
338 1 ▶ my $name = $a->[1] // 'origin';
Condition50%1/2
$$a[1] // "origin"
l!l
10
MC/DC0%0/1
$$a[1] // "origin"
$$a[1]
Truth table50%1/2
A
A= $$a[1]
Aresult
11
00
339 1 ▶ my $x = $rm->{$name} or return ( "fatal: '$name' does not appear to be a git repository\nfatal: Could not read from remote repository.", 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $x = $$rm{$name} or return "fatal: '${name}' does not appear to be a git repository\nfatal: Could not read from remote repository.", 0 1 0 1
340 1 my ( $s, $err ) = _server( $ctx, $r, $name );
341 1 ▶ return ( $err, 0 ) unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 0 1 1
342 1 ▶ my @b = sort keys %{ $s->{refs}{heads} || {} };
Condition50%1/2
$$s{'refs'}{'heads'} || {}
l!l
10
MC/DC0%0/1
$$s{'refs'}{'heads'} || {}
$$s{'refs'}{'heads'}
Truth table50%1/2
A
A= $$s{'refs'}{'heads'}
Aresult
11
00
343 1 ▶ my $loc = $r->{refs}{heads} || {};
Condition50%1/2
$$r{'refs'}{'heads'} || {}
l!l
10
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table50%1/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
344 return ( join( "\n", "* remote $name", " Fetch URL: $x->{url}", " Push URL: $x->{url}", ' HEAD branch: main', ' Remote branch' . ( @b > 1 ? 'es:' : ':' ),
345 1 ▶ ( map { " $_ " . ( exists( ( $r->{refs}{remotes} || {} )->{"$name/$_"} ) ? 'tracked' : "new (next fetch will store in remotes/$name)" ) } @b ),
Branch: 1 branch
BranchTrueFalseTotal
exists(($$r{'refs'}{'remotes'} || {})->{"$name/$_"}) ? : 1 0 1
Condition50%1/2
$$r{'refs'}{'remotes'} || {}
l!l
10
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table50%1/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
346 " Local ref configured for 'git push':",
347 1 ( map { my $l = $loc->{$_}; my $sv = $s->{refs}{heads}{$_};
348 1 ▶ " $_ pushes to $_ (" . ( !defined $sv ? 'create' : $l eq $sv ? 'up to date' : _ancestors( $r, $l )->{$sv} ? 'fast-forwardable' : 'local out of date' ) . ')' } grep { exists $loc->{$_} } @b ) ), 1 );
Branch: 4 branches
BranchTrueFalseTotal
@b > 1 ? : 0 1 1
!defined($sv) ? : 0 1 1
$l eq $sv ? : 0 1 1
_ancestors($r, $l)->{$sv} ? : 0 1 1
349 }
350 0 push @GAPS, "git remote @$a";
351 0 return ( '', 0 );
352 }
353  
354  
355 13 ▶sub virtual {
Subroutine virtual: called CC=26 SCAR=35.5
Pod documented
356 13 my ( $dev, $path ) = @_;
357 13 ▶ return undef unless defined $path && $path =~ m{\.git(?:/|\z)};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path and $path =~ m[\.git(?:/|\z)] 0 13 13
Condition33%1/3
defined $path and $path =~ m[\.git(?:/|\z)]
!ll&&!rl&&r
0013
MC/DC0%0/2
defined $path and $path =~ m[\.git(?:/|\z)]
defined $path $path =~ m[\.git(?:/|\z)]
Truth table33%1/3
A and B
A= defined $pathB= $path =~ m[\.git(?:/|\z)]
ABresult
0X0
100
111
358 13 my ( $gd, $rest, $r, $bare );
359 13 ▶ for my $root ( keys %{ ( $dev->{git} || {} )->{repos} || {} } ) {
Condition100%4/4
($$dev{'git'} || {})->{'repos'} || {}
l!l
58
$$dev{'git'} || {}
l!l
58
MC/DC100%1/1
($$dev{'git'} || {})->{'repos'} || {}
$$dev{'git'}
Truth table100%2/2
A
A= $$dev{'git'}
Aresult
11
00
360 5 ▶ next unless $path eq "$root/.git" || index( $path, "$root/.git/" ) == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "$root/.git" or index($path, "$root/.git/") == 0 0 5 5
Condition33%1/3
$path eq "$root/.git" or index($path, "$root/.git/") == 0
l!l&&r!l&&!r
050
MC/DC0%0/2
$path eq "$root/.git" or index($path, "$root/.git/") == 0
$path eq "$root/.git" index($path, "$root/.git/") == 0
Truth table33%1/3
A or B
A= $path eq "$root/.git"B= index($path, "$root/.git/") == 0
ABresult
1X1
011
000
361 5 ( $gd, $r ) = ( "$root/.git", $dev->{git}{repos}{$root} );
362 5 last;
363 }
364 13 ▶ if ( !$r ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r) 8 5 13
365 8 ▶ my ( $bp, $key ) = _bare_at( $dev, $path ) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = _bare_at($dev, $path) or return undef 8 0 8
366 8 ( $gd, $r, $bare ) = ( $bp, $dev->{forgejo}{repos}{$key}, 1 );
367 }
368 13 ( $rest = substr( $path, length $gd ) ) =~ s{\A/}{};
369 13 $rest =~ s{/\z}{};
370 13 ▶ my $heads = $r->{refs}{heads} || {};
Condition50%1/2
$$r{'refs'}{'heads'} || {}
l!l
130
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table50%1/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
371 13 ▶ my $tags = $r->{refs}{tags} || {};
Condition50%1/2
$$r{'refs'}{'tags'} || {}
l!l
130
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table50%1/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
372 13 ▶ my $rem = $r->{refs}{remotes} || {};
Condition100%2/2
$$r{'refs'}{'remotes'} || {}
l!l
58
MC/DC100%1/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table100%2/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
373 my %files = (
374 HEAD => defined $r->{branch} || $bare ? 'ref: refs/heads/' . ( $r->{branch} // 'main' ) . "\n" : ( $r->{detached} // '' ) . "\n",
375 description => "Unnamed repository; edit this file 'description' to name the repository.\n",
376 config => _git_config_text( $r, $bare ),
377 13 ( map { ( "refs/heads/$_" => "$heads->{$_}\n" ) } keys %$heads ),
378 5 ( map { ( "refs/tags/$_" => "$tags->{$_}{commit}\n" ) } keys %$tags ),
379 13 ▶ ( map { ( "refs/remotes/$_" => "$rem->{$_}\n" ) } keys %$rem ),
Branch: 1 branch
BranchTrueFalseTotal
defined $$r{'branch'} || $bare ? : 13 0 13
Condition57%4/7
defined $$r{"branch"} or $bare
l!l&&r!l&&!r
580
$$r{"branch"} // "main"
l!l
58
$$r{"detached"} // ""
l!l
00
MC/DC0%0/2
defined $$r{"branch"} or $bare
defined $$r{"branch"} $bare
MC/DC100%1/1
$$r{"branch"} // "main"
$$r{"branch"}
MC/DC0%0/1
$$r{"detached"} // ""
$$r{"detached"}
Truth table66%2/3
A or B
A= defined $$r{"branch"}B= $bare
ABresult
1X1
011
000
Truth table100%2/2
A
A= $$r{"branch"}
Aresult
11
00
Truth table0%0/2
A
A= $$r{"detached"}
Aresult
11
00
380 );
381 13 ▶ return { text => $files{$rest} } if exists $files{$rest};
Branch: 1 branch
BranchTrueFalseTotal
if exists $files{$rest} 7 6 13
382 54 ▶ my %dirs = map { $_ => 1 } ( '', 'refs', 'refs/heads', 'refs/tags', 'objects', 'info', ( $bare ? () : ( 'hooks', 'logs' ) ), ( %$rem ? 'refs/remotes' : () ),
Branch: 2 branches
BranchTrueFalseTotal
$bare ? : 6 0 6
%$rem ? : 0 6 6
383 6 map { my @p = split m{/}; map { join '/', @p[ 0 .. $_ ] } 0 .. $#p - 1 } keys %files );
384 6 ▶ return undef unless $dirs{$rest};
Branch: 1 branch
BranchTrueFalseTotal
unless $dirs{$rest} 2 4 6
385 4 my %n;
386 4 for my $p ( keys %files, keys %dirs ) {
387 43 ▶ next if $p eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $p eq "" 4 39 43
388 39 ▶ $n{$1} = 1 if ( $rest eq '' ? $p : index( $p, "$rest/" ) == 0 ? substr( $p, length($rest) + 1 ) : "\0" ) =~ m{\A([^/\0]+)};
Branch: 3 branches
BranchTrueFalseTotal
if ($rest eq "" ? $p : (index($p, "$rest/") == 0 ? substr($p, length($rest) + 1) : "\0")) =~ m[\A([^/\0]+)] 39 0 39
$rest eq '' ? : 39 0 39
index($p, "$rest/") == 0 ? : 0 0 0
389 }
390 4 return { dir => [ sort keys %n ] };
391 }
392  
393 13 ▶sub _git_config_text {
Subroutine _git_config_text: called CC=13 SCAR=27.3
394 13 my ( $r, $bare ) = @_;
395 13 ▶ my $t = "[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = " . ( $bare ? 'true' : 'false' ) . "\n" . ( $bare ? '' : "\tlogallrefupdates = true\n" );
Branch: 2 branches
BranchTrueFalseTotal
$bare ? : 8 5 13
$bare ? : 8 5 13
396 13 ▶ for my $n ( sort keys %{ $r->{remotes} || {} } ) { $t .= "[remote \"$n\"]\n\turl = $r->{remotes}{$n}{url}\n\tfetch = +refs/heads/*:refs/remotes/$n/*\n" }
Condition100%2/2
$$r{'remotes'} || {}
l!l
58
MC/DC100%1/1
$$r{'remotes'} || {}
$$r{'remotes'}
Truth table100%2/2
A
A= $$r{'remotes'}
Aresult
11
00
397 13 ▶ for my $b ( sort keys %{ $r->{refs}{heads} || {} } ) {
Condition50%1/2
$$r{'refs'}{'heads'} || {}
l!l
130
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table50%1/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
398 13 ▶ $t .= "[branch \"$b\"]\n\tremote = origin\n\tmerge = refs/heads/$b\n" if exists( ( $r->{refs}{remotes} || {} )->{"origin/$b"} );
Branch: 1 branch
BranchTrueFalseTotal
if exists(($$r{"refs"}{"remotes"} || {})->{"origin/$b"}) 5 8 13
Condition100%2/2
$$r{'refs'}{'remotes'} || {}
l!l
58
MC/DC100%1/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table100%2/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
399 }
400 13 my %sec;
401 0 ▶ for my $k ( sort keys %{ $r->{config} || {} } ) { my ( $s, $n ) = $k =~ /\A([^.]+)\.(.+)\z/ or next; push @{ $sec{$s} }, "\t$n = $r->{config}{$k}" }
Branch: 1 branch
BranchTrueFalseTotal
() = $k =~ /\A([^.]+)\.(.+)\z/ or next 0 0 0
Condition50%1/2
$$r{'config'} || {}
l!l
013
MC/DC0%0/1
$$r{'config'} || {}
$$r{'config'}
Truth table50%1/2
A
A= $$r{'config'}
Aresult
11
00
402 0 $t .= "[$_]\n" . join( "\n", @{ $sec{$_} } ) . "\n" for sort keys %sec;
403 13 return $t;
404 }
405  
406  
407 4 ▶sub api {
Subroutine api: called CC=30 SCAR=49.3
Pod documented
408 4 my ( $dev, $method, $path ) = @_;
409 4 ▶ my $fj = $dev->{forgejo} || {};
Condition50%1/2
$$dev{'forgejo'} || {}
l!l
40
MC/DC0%0/1
$$dev{'forgejo'} || {}
$$dev{'forgejo'}
Truth table50%1/2
A
A= $$dev{'forgejo'}
Aresult
11
00
410 4 my $j = JSON::MaybeXS->new( canonical => 1, utf8 => 0 );
411 4 $path =~ s/\?.*//;
412 4 ▶ return ( 405, '{"message":"method not allowed without token"}', 'json' ) if ( $method // 'GET' ) ne 'GET';
Branch: 1 branch
BranchTrueFalseTotal
if ($method // "GET") ne "GET" 0 4 4
Condition50%1/2
$method // "GET"
l!l
40
MC/DC0%0/1
$method // "GET"
$method
Truth table50%1/2
A
A= $method
Aresult
11
00
413 4 ▶ return ( 200, "<!DOCTYPE html>\n<html lang=\"de-DE\">\n<head><title>Forgejo: Code von example.com</title></head>\n<body>Forgejo</body>\n</html>", 'html' ) if $path eq '/' || $path eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $path eq "/" or $path eq "" 0 4 4
Condition33%1/3
$path eq "/" or $path eq ""
l!l&&r!l&&!r
004
MC/DC0%0/2
$path eq "/" or $path eq ""
$path eq "/" $path eq ""
Truth table33%1/3
A or B
A= $path eq "/"B= $path eq ""
ABresult
1X1
011
000
414 4 ▶ return ( 200, '{"version":"9.0.3+gitea-1.22.0"}', 'json' ) if $path eq '/api/v1/version';
Branch: 1 branch
BranchTrueFalseTotal
if $path eq "/api/v1/version" 2 2 4
415 2 ▶ return ( 200, '{"message":"pong"}', 'json' ) if $path =~ m{\A/api/(?:v1/)?healthz?\z};
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[\A/api/(?:v1/)?healthz?\z] 0 2 2
416 2 ▶ if ( my ( $o, $n, $sub ) = $path =~ m{\A/api/v1/repos/([^/]+)/([^/]+?)(?:\.git)?(?:/(.*))?\z} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $path =~ m[\A/api/v1/repos/([^/]+)/([^/]+?)(?:\.git)?(?:/(.*))?\z]) 2 0 2
417 2 ▶ my $s = ( $fj->{repos} || {} )->{"$o/$n"} or return ( 404, '{"errors":null,"message":"GetRepositoryByName","url":"' . ( $fj->{root_url} // '' ) . 'api/swagger"}', 'json' );
Branch: 1 branch
BranchTrueFalseTotal
my $s = ($$fj{"repos"} || {})->{"$o/$n"} or return 404, '{"errors":null,"message":"GetRepositoryByName","url":"' . ($$fj{"root_url"} // "") . 'api/swagger"}', "json" 2 0 2
Condition25%1/4
$$fj{'repos'} || {}
l!l
20
$$fj{"root_url"} // ""
l!l
00
MC/DC0%0/1
$$fj{'repos'} || {}
$$fj{'repos'}
MC/DC0%0/1
$$fj{"root_url"} // ""
$$fj{"root_url"}
Truth table50%1/2
A
A= $$fj{'repos'}
Aresult
11
00
Truth table0%0/2
A
A= $$fj{"root_url"}
Aresult
11
00
418 2 ▶ ( my $base = $fj->{root_url} // 'https://localhost/' ) =~ s{/*\z}{/};
Condition50%1/2
$$fj{"root_url"} // "https://localhost/"
l!l
20
MC/DC0%0/1
$$fj{"root_url"} // "https://localhost/"
$$fj{"root_url"}
Truth table50%1/2
A
A= $$fj{"root_url"}
Aresult
11
00
419 2 ( my $host = $base ) =~ s{\Ahttps?://([^/:]+).*}{$1}s;
420 2 ▶ $sub //= '';
Condition50%1/2
$sub //= ""
l!l
20
MC/DC0%0/1
$sub //= ""
$sub
Truth table50%1/2
A
A= $sub
Aresult
11
00
421 2 ▶ if ( $sub eq '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "") 0 2 2
422 0 return ( 200, $j->encode( { id => 1, name => $n, full_name => "$o/$n", owner => { login => $o }, private => JSON::MaybeXS::false(), empty => JSON::MaybeXS::false(),
423 archived => JSON::MaybeXS::false(), default_branch => 'main', html_url => "$base$o/$n", clone_url => "$base$o/$n.git", ssh_url => "git\@$host:$o/$n.git",
424 has_actions => JSON::MaybeXS::true() } ), 'json' );
425 }
426 2 ▶ if ( $sub eq 'branches' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "branches") 1 1 2
427 1 return ( 200, $j->encode( [ map { my $id = $s->{refs}{heads}{$_}; +{ name => $_, protected => exists( ( $s->{protected} || {} )->{$_} ) ? JSON::MaybeXS::true() : JSON::MaybeXS::false(),
428 1 ▶ commit => { id => $id, message => ( $s->{commits}{$id} || {} )->{message} // '' } } } sort keys %{ $s->{refs}{heads} || {} } ] ), 'json' );
Branch: 1 branch
BranchTrueFalseTotal
exists(($$s{'protected'} || {})->{$_}) ? : 1 0 1
Condition50%4/8
$$s{'protected'} || {}
l!l
10
($$s{"commits"}{$id} || {})->{"message"} // ""
l!l
10
$$s{'commits'}{$id} || {}
l!l
10
$$s{'refs'}{'heads'} || {}
l!l
10
MC/DC0%0/1
$$s{'protected'} || {}
$$s{'protected'}
MC/DC0%0/1
($$s{"commits"}{$id} || {})->{"message"} // ""
$$s{'commits'}{$id}
MC/DC0%0/1
$$s{'refs'}{'heads'} || {}
$$s{'refs'}{'heads'}
Truth table50%1/2
A
A= $$s{'protected'}
Aresult
11
00
Truth table50%1/2
A
A= $$s{'commits'}{$id}
Aresult
11
00
Truth table50%1/2
A
A= $$s{'refs'}{'heads'}
Aresult
11
00
429 }
430 1 ▶ if ( $sub eq 'tags' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "tags") 0 1 1
431 0 ▶ return ( 200, $j->encode( [ map { +{ name => $_, commit => { sha => $s->{refs}{tags}{$_}{commit} }, message => $s->{refs}{tags}{$_}{message} // '' } } sort keys %{ $s->{refs}{tags} || {} } ] ), 'json' );
Condition0%0/4
$$s{"refs"}{"tags"}{$_}{"message"} // ""
l!l
00
$$s{'refs'}{'tags'} || {}
l!l
00
MC/DC0%0/1
$$s{"refs"}{"tags"}{$_}{"message"} // ""
$$s{"refs"}{"tags"}{$_}{"message"}
MC/DC0%0/1
$$s{'refs'}{'tags'} || {}
$$s{'refs'}{'tags'}
Truth table0%0/2
A
A= $$s{"refs"}{"tags"}{$_}{"message"}
Aresult
11
00
Truth table0%0/2
A
A= $$s{'refs'}{'tags'}
Aresult
11
00
432 }
433 1 ▶ if ( $sub =~ m{\Acommits\z} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub =~ /\Acommits\z/) 0 1 1
434 0 ▶ return ( 200, $j->encode( [ map { +{ sha => $_->{id}, commit => { message => $_->{message}, author => { name => $_->{author} } } } } @{ ( ( $s->{view} || {} )->{main} || {} )->{log} || [] } ] ), 'json' );
Condition0%0/6
(($$s{'view'} || {})->{'main'} || {})->{'log'} || []
l!l
00
($$s{'view'} || {})->{'main'} || {}
l!l
00
$$s{'view'} || {}
l!l
00
MC/DC0%0/1
(($$s{'view'} || {})->{'main'} || {})->{'log'} || []
$$s{'view'}
Truth table0%0/2
A
A= $$s{'view'}
Aresult
11
00
435 }
436 1 ▶ return ( 401, '{"message":"token is required","url":"' . $base . 'api/swagger"}', 'json' ) if $sub =~ m{\A(?:branch_protections|hooks|actions|keys|collaborators|teams)};
Branch: 1 branch
BranchTrueFalseTotal
if $sub =~ /\A(?:branch_protections|hooks|actions|keys|collaborators|teams)/ 1 0 1
437 0 return ( 404, '{"errors":null,"message":"not found","url":"' . $base . 'api/swagger"}', 'json' );
438 }
439 0 ▶ return ( 401, '{"message":"token is required"}', 'json' ) if $path =~ m{\A/api/v1/(?:admin|user)\b};
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[\A/api/v1/(?:admin|user)\b] 0 0 0
440 0 return ( 404, '{"errors":null,"message":"not found"}', 'json' );
441 }
442  
443 2 ▶sub _g_cat_file {
Subroutine _g_cat_file: called CC=19 SCAR=36.9
444 2 my ( $dev, $root, $r, $a ) = @_;
445 2 my ($mode) = grep {/\A-[pts]\z/} @$a;
446 2 my ($obj) = grep { !/\A-/ } @$a;
447 2 ▶ return ( 'usage: git cat-file (-t | -s | -e | -p | <type>) <object>', 0 ) unless defined $obj;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj 0 2 2
448 2 ▶ my $type = $mode ? substr( $mode, 1 ) : 'p';
Branch: 1 branch
BranchTrueFalseTotal
$mode ? : 2 0 2
449 2 ▶ if ( $obj =~ /\A(.*?):(.+)\z/ ) { # rev:pfad -> Datei
Branch: 1 branch
BranchTrueFalseTotal
if ($obj =~ /\A(.*?):(.+)\z/) 1 1 2
450 1 ▶ my $id = _rev( $r, length $1 ? $1 : 'HEAD' ) // return ( "fatal: Not a valid object name $obj", 0 );
Branch: 1 branch
BranchTrueFalseTotal
length $1 ? : 1 0 1
Condition50%1/2
_rev($r, length $1 ? $1 : "HEAD") // (return "fatal: Not a valid object name $obj", 0)
l!l
10
MC/DC0%0/1
_rev($r, length $1 ? $1 : "HEAD") // (return "fatal: Not a valid object name $obj", 0)
_rev($r, length $1 ? $1 : "HEAD")
Truth table50%1/2
A
A= _rev($r, length $1 ? $1 : "HEAD")
Aresult
11
00
451 1 my $t = _tree( $r, $id );
452 1 ▶ return ( "fatal: path '$2' does not exist in '$1'", 0 ) unless exists $t->{$2};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$t{$2} 0 1 1
453 1 ▶ return ( 'blob', 1 ) if $type eq 't';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "t" 0 1 1
454 1 ▶ return ( length( Encode::encode( 'UTF-8', $t->{$2} ) ), 1 ) if $type eq 's';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "s" 0 1 1
455 1 return ( $t->{$2} =~ s/\n\z//r, 1 );
456 }
457 1 ▶ if ( my $tag = ( $r->{refs}{tags} || {} )->{$obj} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag = ($$r{"refs"}{"tags"} || {})->{$obj}) 0 1 1
Condition50%1/2
$$r{'refs'}{'tags'} || {}
l!l
10
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table50%1/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
458 0 ▶ if ( $tag->{annotated} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$tag{"annotated"}) 0 0 0
459 0 ▶ return ( 'tag', 1 ) if $type eq 't';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "t" 0 0 0
460 0 ▶ return ( join( "\n", "object $tag->{commit}", 'type commit', "tag $obj", 'tagger ' . ( $tag->{tagger} // '' ) . ' 1792832400 +0200', '', $tag->{message} // '' ), 1 );
Condition0%0/4
$$tag{"tagger"} // ""
l!l
00
$$tag{"message"} // ""
l!l
00
MC/DC0%0/1
$$tag{"tagger"} // ""
$$tag{"tagger"}
MC/DC0%0/1
$$tag{"message"} // ""
$$tag{"message"}
Truth table0%0/2
A
A= $$tag{"tagger"}
Aresult
11
00
Truth table0%0/2
A
A= $$tag{"message"}
Aresult
11
00
461 }
462 }
463 1 ▶ my $id = _rev( $r, $obj ) // return ( "fatal: Not a valid object name $obj", 0 );
Condition50%1/2
_rev($r, $obj) // (return "fatal: Not a valid object name $obj", 0)
l!l
10
MC/DC0%0/1
_rev($r, $obj) // (return "fatal: Not a valid object name $obj", 0)
_rev($r, $obj)
Truth table50%1/2
A
A= _rev($r, $obj)
Aresult
11
00
464 1 my $c = $r->{commits}{$id};
465 1 ▶ return ( 'commit', 1 ) if $type eq 't';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "t" 0 1 1
466 1 ▶ my $text = join "\n", 'tree ' . Digest::SHA::sha1_hex( 'tree:' . $id ), ( map {"parent $_"} @{ $c->{parents} || [] } ),
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
467 1 "author $c->{author} $c->{date} +0200", "committer $c->{author} $c->{date} +0200", '', $c->{message};
468 1 ▶ return ( length( Encode::encode( 'UTF-8', "$text\n" ) ), 1 ) if $type eq 's';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "s" 0 1 1
469 1 return ( $text, 1 );
470 }
471  
472 0 ▶sub _g_count_objects {
Subroutine _g_count_objects: not called CC=2 SCAR=17.9
473 0 my ( $dev, $root, $r ) = @_;
474 0 ▶ my $n = scalar keys %{ $r->{commits} || {} };
Condition0%0/2
$$r{'commits'} || {}
l!l
00
MC/DC0%0/1
$$r{'commits'} || {}
$$r{'commits'}
Truth table0%0/2
A
A= $$r{'commits'}
Aresult
11
00
475 0 return ( ( $n * 3 ) . ' objects, ' . ( $n * 12 ) . ' kilobytes', 1 );
476 }
477  
478 2 ▶sub _g_ls_tree {
Subroutine _g_ls_tree: called CC=20 SCAR=33.9
479 2 my ( $dev, $root, $r, $a ) = @_;
480 2 ▶ my $rec = grep { $_ eq '-r' || $_ eq '-rt' || $_ eq '-tr' } @$a;
Condition66%4/6
$_ eq '-r' || $_ eq '-rt' || $_ eq '-tr'
l!l&&r!l&&!r
103
$_ eq "-r" or $_ eq "-rt"
l!l&&r!l&&!r
103
MC/DC33%1/3
$_ eq '-r' || $_ eq '-rt' || $_ eq '-tr'
$_ eq "-r" $_ eq "-rt" $_ eq '-tr'
Truth table50%2/4
A or B || C
A= $_ eq "-r"B= $_ eq "-rt"C= $_ eq '-tr'
ABCresult
1XX1
01X1
0011
0000
481 2 ▶ my $name = grep { $_ eq '--name-only' || $_ eq '--name-status' } @$a;
Condition66%2/3
$_ eq '--name-only' || $_ eq '--name-status'
l!l&&r!l&&!r
103
MC/DC50%1/2
$_ eq '--name-only' || $_ eq '--name-status'
$_ eq '--name-only' $_ eq '--name-status'
Truth table66%2/3
A || B
A= $_ eq '--name-only'B= $_ eq '--name-status'
ABresult
1X1
011
000
482 2 my ( $rev, @paths ) = grep { !/\A-/ } @$a;
483 2 ▶ return ( 'usage: git ls-tree [<options>] <tree-ish> [<path>...]', 0 ) unless defined $rev;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rev 0 2 2
484 2 ▶ my $id = _rev( $r, $rev ) // return ( "fatal: Not a valid object name $rev", 0 );
Condition50%1/2
_rev($r, $rev) // (return "fatal: Not a valid object name $rev", 0)
l!l
20
MC/DC0%0/1
_rev($r, $rev) // (return "fatal: Not a valid object name $rev", 0)
_rev($r, $rev)
Truth table50%1/2
A
A= _rev($r, $rev)
Aresult
11
00
485 2 my $t = _tree( $r, $id );
486 2 ▶ my $blob = sub { Digest::SHA::sha1_hex( 'blob ' . length( Encode::encode( 'UTF-8', $_[0] ) ) . "\0" . Encode::encode( 'UTF-8', $_[0] ) ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
487 2 ▶ my $pre = @paths ? $paths[0] =~ s{/*\z}{/}r : '';
Branch: 1 branch
BranchTrueFalseTotal
@paths ? : 0 2 2
488 2 ▶ $pre = '' if $pre eq './';
Branch: 1 branch
BranchTrueFalseTotal
if $pre eq "./" 0 2 2
489 2 my %e;
490 2 for my $p ( sort keys %$t ) {
491 9 ▶ next if length $pre && index( $p, $pre ) != 0 && $p ne ( $pre =~ s{/\z}{}r );
Branch: 1 branch
BranchTrueFalseTotal
if length $pre and index($p, $pre) != 0 and $p ne $pre =~ s[/\z][]r 0 9 9
Condition33%2/6
length $pre and index($p, $pre) != 0 and $p ne $pre =~ s[/\z][]r
!ll&&!rl&&r
900
length $pre and index($p, $pre) != 0
!ll&&!rl&&r
900
MC/DC0%0/3
length $pre and index($p, $pre) != 0 and $p ne $pre =~ s[/\z][]r
length $pre index($p, $pre) != 0 $p ne $pre =~ s[/\z][]r
Truth table25%1/4
A and B and C
A= length $preB= index($p, $pre) != 0C= $p ne $pre =~ s[/\z][]r
ABCresult
0XX0
10X0
1100
1111
492 9 ▶ if ($rec) { $e{$p} = [ 'blob', $blob->( $t->{$p} ) ]; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($rec) 4 5 9
493 5 ▶ my $rest = length $pre && index( $p, $pre ) == 0 ? substr( $p, length $pre ) : $p;
Branch: 1 branch
BranchTrueFalseTotal
length $pre && index($p, $pre) == 0 ? : 0 5 5
Condition33%1/3
length $pre and index($p, $pre) == 0
!ll&&!rl&&r
500
MC/DC0%0/2
length $pre and index($p, $pre) == 0
length $pre index($p, $pre) == 0
Truth table33%1/3
A and B
A= length $preB= index($p, $pre) == 0
ABresult
0X0
100
111
494 5 my ($first) = split m{/}, $rest;
495 5 ▶ my $full = ( length $pre && index( $p, $pre ) == 0 ? $pre : '' ) . $first;
Branch: 1 branch
BranchTrueFalseTotal
length $pre && index($p, $pre) == 0 ? : 0 5 5
Condition33%1/3
length $pre and index($p, $pre) == 0
!ll&&!rl&&r
500
MC/DC0%0/2
length $pre and index($p, $pre) == 0
length $pre index($p, $pre) == 0
Truth table33%1/3
A and B
A= length $preB= index($p, $pre) == 0
ABresult
0X0
100
111
496 5 ▶ $e{$full} = $rest =~ m{/} ? [ 'tree', Digest::SHA::sha1_hex("tree:$id:$full") ] : [ 'blob', $blob->( $t->{$p} ) ];
Branch: 1 branch
BranchTrueFalseTotal
$rest =~ m[/] ? : 0 5 5
497 }
498 2 ▶ return ( join( "\n", map { $name ? $_ : ( $e{$_}[0] eq 'tree' ? '040000' : '100644' ) . " $e{$_}[0] $e{$_}[1]\t$_" } sort keys %e ), 1 );
Branch: 2 branches
BranchTrueFalseTotal
$name ? : 4 5 9
$e{$_}[0] eq 'tree' ? : 0 5 5
499 }
500  
501 0 ▶sub _g_show_ref {
Subroutine _g_show_ref: not called CC=10 SCAR=47.0
502 0 my ( $dev, $root, $r, $a ) = @_;
503 0 my $tagsonly = grep { $_ eq '--tags' } @$a;
504 0 ▶ my $headsonly = grep { $_ eq '--heads' || $_ eq '--branches' } @$a;
Condition0%0/3
$_ eq '--heads' || $_ eq '--branches'
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq '--heads' || $_ eq '--branches'
$_ eq '--heads' $_ eq '--branches'
Truth table0%0/3
A || B
A= $_ eq '--heads'B= $_ eq '--branches'
ABresult
1X1
011
000
505 0 my @l;
506 0 ▶ push @l, map {"$r->{refs}{heads}{$_} refs/heads/$_"} sort keys %{ $r->{refs}{heads} || {} } unless $tagsonly;
Branch: 1 branch
BranchTrueFalseTotal
unless $tagsonly 0 0 0
Condition0%0/2
$$r{'refs'}{'heads'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table0%0/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
507 0 ▶ push @l, map {"$r->{refs}{remotes}{$_} refs/remotes/$_"} sort keys %{ $r->{refs}{remotes} || {} } unless $tagsonly || $headsonly;
Branch: 1 branch
BranchTrueFalseTotal
unless $tagsonly or $headsonly 0 0 0
Condition0%0/5
$tagsonly or $headsonly
l!l&&r!l&&!r
000
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/2
$tagsonly or $headsonly
$tagsonly $headsonly
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table0%0/3
A or B
A= $tagsonlyB= $headsonly
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
508 0 ▶ push @l, map {"$r->{refs}{tags}{$_}{commit} refs/tags/$_"} sort keys %{ $r->{refs}{tags} || {} } unless $headsonly;
Branch: 1 branch
BranchTrueFalseTotal
unless $headsonly 0 0 0
Condition0%0/2
$$r{'refs'}{'tags'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table0%0/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
509 0 ▶ return ( join( "\n", @l ), @l ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
@l ? : 0 0 0
510 }
511  
512 0 ▶sub _g_for_each_ref {
Subroutine _g_for_each_ref: not called CC=2 SCAR=17.9
513 0 my ( $dev, $root, $r, $a ) = @_;
514 0 my ($pat) = grep { !/\A-/ } @$a;
515 0 my @l = map { my ( $id, $ref ) = split / /; "$id commit\t$ref" } split /\n/, ( _g_show_ref( $dev, $root, $r, [] ) )[0];
516 0 ▶ @l = grep { ( split /\t/ )[1] =~ m{\A\Q$pat\E} } @l if defined $pat;
Branch: 1 branch
BranchTrueFalseTotal
if defined $pat 0 0 0
517 0 return ( join( "\n", @l ), 1 );
518 }
519  
520 # Pfad in einem Bare-Repo des Servers (forgejo-repositories/<owner>/<name>.git) -> ( pfad, schluessel )
521 13 ▶sub _bare_at {
Subroutine _bare_at: called CC=6 SCAR=18.5
522 13 my ( $dev, $path ) = @_;
523 13 ▶ my $rs = ( $dev->{forgejo} || {} )->{repos} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $rs = ($$dev{"forgejo"} || {})->{"repos"} or return () 12 1 13
Condition100%2/2
$$dev{'forgejo'} || {}
l!l
121
MC/DC100%1/1
$$dev{'forgejo'} || {}
$$dev{'forgejo'}
Truth table100%2/2
A
A= $$dev{'forgejo'}
Aresult
11
00
524 12 ▶ my ( $base, $o, $n ) = ( $path // '' ) =~ m{\A(.*/forgejo-repositories)/([^/]+)/([^/]+?)\.git(?:/.*)?\z} or return ();
Branch: 1 branch
BranchTrueFalseTotal
() = ($path // "") =~ m[\A(.*/forgejo-repositories)/([^/]+)/([^/]+?)\.git(?:/.*)?\z] or return () 12 0 12
Condition50%1/2
$path // ""
l!l
120
MC/DC0%0/1
$path // ""
$path
Truth table50%1/2
A
A= $path
Aresult
11
00
525 12 ▶ return $rs->{"$o/$n"} ? ( "$base/$o/$n.git", "$o/$n" ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$$rs{"$o/$n"} ? : 12 0 12
526 }
527  
528 0 ▶sub _g_update_ref {
Subroutine _g_update_ref: not called CC=9 SCAR=45.0
529 0 my ( $dev, $root, $r, $a ) = @_;
530 0 my @p = grep { !/\A-/ } @$a;
531 0 ▶ if ( grep { $_ eq '-d' } @$a ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "-d";} @$a) 0 0 0
532 0 my ($ref) = @p;
533 0 ▶ ( my $n = $ref // '' ) =~ s{\Arefs/(heads|tags)/}{};
Condition0%0/2
$ref // ""
l!l
00
MC/DC0%0/1
$ref // ""
$ref
Truth table0%0/2
A
A= $ref
Aresult
11
00
534 0 ▶ my $kind = $1 // 'heads';
Condition0%0/2
$1 // "heads"
l!l
00
MC/DC0%0/1
$1 // "heads"
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
535 0 ▶ return ( "error: cannot lock ref '$ref': unable to resolve reference '$ref'", 0 ) unless exists $r->{refs}{$kind}{$n};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$r{"refs"}{$kind}{$n} 0 0 0
536 0 delete $r->{refs}{$kind}{$n};
537 0 return ( '', 1 );
538 }
539 0 my ( $ref, $new ) = @p;
540 0 ▶ return ( 'usage: git update-ref [<options>] <refname> <new-val> [<old-val>]', 0 ) unless defined $new;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $new 0 0 0
541 0 ▶ my $id = _rev( $r, $new ) // return ( "fatal: $new: not a valid SHA1", 0 );
Condition0%0/2
_rev($r, $new) // (return "fatal: ${new}: not a valid SHA1", 0)
l!l
00
MC/DC0%0/1
_rev($r, $new) // (return "fatal: ${new}: not a valid SHA1", 0)
_rev($r, $new)
Truth table0%0/2
A
A= _rev($r, $new)
Aresult
11
00
542 0 ▶ ( my $n = $ref ) =~ s{\Arefs/(heads|tags)/}{} or return ( "fatal: update_ref failed for ref '$ref': refusing to update ref with bad name '$ref'", 0 );
Branch: 1 branch
BranchTrueFalseTotal
(my $n = $ref) =~ s[\Arefs/(heads|tags)/][] or return "fatal: update_ref failed for ref '${ref}': refusing to update ref with bad name '${ref}'", 0 0 0 0
543 0 ▶ if ( $1 eq 'tags' ) { $r->{refs}{tags}{$n} = { commit => $id } } else { $r->{refs}{heads}{$n} = $id }
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq 'tags') { } 0 0 0
544 0 return ( '', 1 );
545 }
546  
547 # URL eines Remotes -> Server (host) und Repo (Pfad) ueber die bekannten Namen des Geraets
548 1 ▶sub _resolve_remote {
Subroutine _resolve_remote: called CC=6 SCAR=21.6
549 1 my ( $dev, $url ) = @_;
550 1 my ( $h, $path );
551 0 ▶ if ( $url =~ m{\Ahttps?://([^/:]+)(?::\d+)?/(.+?)(?:\.git)?/?\z} ) { ( $h, $path ) = ( $1, $2 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($url =~ m[\Ahttps?://([^/:]+)(?::\d+)?/(.+?)(?:\.git)?/?\z]) { } 0 1 1
elsif ($url =~ m[\A(?:ssh://)?(?:[^\@/]+@)?([^:/]+)(?::\d+)?[:/](.+?)(?:\.git)?/?\z]) { } 1 0 1
552 1 elsif ( $url =~ m{\A(?:ssh://)?(?:[^@/]+@)?([^:/]+)(?::\d+)?[:/](.+?)(?:\.git)?/?\z} ) { ( $h, $path ) = ( $1, $2 ) }
553 0 else { return () }
554 1 ▶ my $hosts = ( $dev->{git} || {} )->{hosts} || {}; # Name -> Geraet (z. B. git.example.com -> git1)
Condition50%2/4
($$dev{'git'} || {})->{'hosts'} || {}
l!l
10
$$dev{'git'} || {}
l!l
10
MC/DC0%0/1
($$dev{'git'} || {})->{'hosts'} || {}
$$dev{'git'}
Truth table50%1/2
A
A= $$dev{'git'}
Aresult
11
00
555 1 ▶ return ( host => $hosts->{$h} // $h, repo => $path );
Condition33%1/3
$$hosts{$h} // $h
l!l&&r!l&&!r
100
MC/DC0%0/2
$$hosts{$h} // $h
$$hosts{$h} $h
Truth table33%1/3
A // B
A= $$hosts{$h}B= $h
ABresult
1X1
011
000
556 }
557  
558 0 ▶sub _g_rev_parse {
Subroutine _g_rev_parse: not called CC=14 SCAR=53.5
559 0 my ( $dev, $root, $r, $a ) = @_;
560 0 my @out;
561 0 my $abbrev = 0;
562 0 for my $x (@$a) {
563 0 ▶ if ( $x eq '--abbrev-ref' ) { $abbrev = 1; next }
Branch: 4 branches
BranchTrueFalseTotal
if ($x eq '--abbrev-ref') { } 0 0 0
elsif ($x eq '--show-toplevel') { } 0 0 0
elsif ($x eq '--short') { } 0 0 0
elsif ($x eq '--git-dir') { } 0 0 0
564 0 elsif ( $x eq '--show-toplevel' ) { push @out, $root; next }
565 0 elsif ( $x eq '--short' ) { $abbrev = 2; next }
566 0 elsif ( $x eq '--git-dir' ) { push @out, "$root/.git"; next }
567 0 ▶ if ( $abbrev == 1 && $x eq 'HEAD' ) { push @out, $r->{branch} // 'HEAD'; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($abbrev == 1 and $x eq "HEAD") 0 0 0
Condition0%0/5
$abbrev == 1 and $x eq "HEAD"
!ll&&!rl&&r
000
$$r{"branch"} // "HEAD"
l!l
00
MC/DC0%0/2
$abbrev == 1 and $x eq "HEAD"
$abbrev == 1 $x eq "HEAD"
MC/DC0%0/1
$$r{"branch"} // "HEAD"
$$r{"branch"}
Truth table0%0/3
A and B
A= $abbrev == 1B= $x eq "HEAD"
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
568 0 ▶ if ( $abbrev == 1 && $x =~ /\@\{u/ ) { push @out, "origin/" . ( $r->{branch} // '' ); next }
Branch: 1 branch
BranchTrueFalseTotal
if ($abbrev == 1 and $x =~ /\@\{u/) 0 0 0
Condition0%0/5
$abbrev == 1 and $x =~ /\@\{u/
!ll&&!rl&&r
000
$$r{"branch"} // ""
l!l
00
MC/DC0%0/2
$abbrev == 1 and $x =~ /\@\{u/
$abbrev == 1 $x =~ /\@\{u/
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
Truth table0%0/3
A and B
A= $abbrev == 1B= $x =~ /\@\{u/
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
569 0 ▶ my $id = _rev( $r, $x ) // return ( "fatal: ambiguous argument '$x': unknown revision or path not in the working tree.", 0 );
Condition0%0/2
_rev($r, $x) // (return "fatal: ambiguous argument '${x}': unknown revision or path not in the working tree.", 0)
l!l
00
MC/DC0%0/1
_rev($r, $x) // (return "fatal: ambiguous argument '${x}': unknown revision or path not in the working tree.", 0)
_rev($r, $x)
Truth table0%0/2
A
A= _rev($r, $x)
Aresult
11
00
570 0 ▶ push @out, $abbrev == 2 ? _short($id) : $id;
Branch: 1 branch
BranchTrueFalseTotal
$abbrev == 2 ? : 0 0 0
571 }
572 0 return ( join( "\n", @out ), 1 );
573 }
574  
575 5 ▶sub _tracking {
Subroutine _tracking: called CC=4 SCAR=14.2
576 5 my ($r) = @_;
577 5 ▶ my $b = $r->{branch} // return ();
Condition50%1/2
$$r{"branch"} // (return ())
l!l
50
MC/DC0%0/1
$$r{"branch"} // (return ())
$$r{"branch"}
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
578 5 ▶ my $up = ( $r->{refs}{remotes} || {} )->{"origin/$b"};
Condition50%1/2
$$r{'refs'}{'remotes'} || {}
l!l
50
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table50%1/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
579 5 ▶ return () unless defined $up;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $up 0 5 5
580 5 my $h = _head($r);
581 5 my $ahead = () = _range( $r, $up, $h );
582 5 my $behind = () = _range( $r, $h, $up );
583 5 return ( "origin/$b", $ahead, $behind );
584 }
585  
586 30 ▶sub _changes {
Subroutine _changes: called CC=14 SCAR=28.8
587 30 my ( $dev, $root, $r ) = @_;
588 30 my $head = _tree( $r, _head($r) );
589 30 my $idx = _index($r);
590 30 my $w = _work( $dev, $root );
591 30 my @ig = _ignore_res($w);
592 30 my ( @staged, @unstaged, @untracked );
593 30 for my $p ( sort keys %{ { %$head, %$idx } } ) {
594 127 ▶ next if ( $head->{$p} // "\0" ) eq ( $idx->{$p} // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($$head{$p} // "\0") eq ($$idx{$p} // "\0") 127 0 127
Condition50%2/4
$$head{$p} // "\0"
l!l
1270
$$idx{$p} // "\0"
l!l
1270
MC/DC0%0/1
$$head{$p} // "\0"
$$head{$p}
MC/DC0%0/1
$$idx{$p} // "\0"
$$idx{$p}
Truth table50%1/2
A
A= $$head{$p}
Aresult
11
00
Truth table50%1/2
A
A= $$idx{$p}
Aresult
11
00
595 0 ▶ push @staged, [ !exists $head->{$p} ? 'new file' : !exists $idx->{$p} ? 'deleted' : 'modified', $p ];
Branch: 2 branches
BranchTrueFalseTotal
!exists($$head{$p}) ? : 0 0 0
!exists($$idx{$p}) ? : 0 0 0
596 }
597 30 for my $p ( sort keys %$idx ) {
598 127 ▶ next if ( $w->{$p} // "\0" ) eq $idx->{$p};
Branch: 1 branch
BranchTrueFalseTotal
if ($$w{$p} // "\0") eq $$idx{$p} 120 7 127
Condition50%1/2
$$w{$p} // "\0"
l!l
1270
MC/DC0%0/1
$$w{$p} // "\0"
$$w{$p}
Truth table50%1/2
A
A= $$w{$p}
Aresult
11
00
599 7 ▶ push @unstaged, [ exists $w->{$p} ? 'modified' : 'deleted', $p ];
Branch: 1 branch
BranchTrueFalseTotal
exists $$w{$p} ? : 7 0 7
600 }
601 30 ▶ for my $p ( sort keys %$w ) { push @untracked, $p unless exists $idx->{$p} || _ignored( \@ig, $p ) }
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$idx{$p} or _ignored(\@ig, $p) 9 130 139
Condition100%3/3
exists $$idx{$p} or _ignored(\@ig, $p)
l!l&&r!l&&!r
12739
MC/DC100%2/2
exists $$idx{$p} or _ignored(\@ig, $p)
exists $$idx{$p} _ignored(\@ig, $p)
Truth table100%3/3
A or B
A= exists $$idx{$p}B= _ignored(\@ig, $p)
ABresult
1X1
011
000
602 30 return ( \@staged, \@unstaged, \@untracked );
603 }
604  
605 5 ▶sub _g_status {
Subroutine _g_status: called CC=32 SCAR=43.9
606 5 my ( $dev, $root, $r, $a ) = @_;
607 5 my ( $st, $un, $ut ) = _changes( $dev, $root, $r );
608 5 ▶ if ( grep { /\A(?:-s|--short|--porcelain(?:=v1)?|-sb)\z/ } @$a ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/\A(?:-s|--short|--porcelain(?:=v1)?|-sb)\z/;} @$a) 2 3 5
609 2 my %m;
610 2 $m{ $_->[1] }[0] = substr( uc $_->[0], 0, 1 ) =~ s/N/A/r for @$st;
611 2 $m{ $_->[1] }[1] = substr( uc $_->[0], 0, 1 ) for @$un;
612 2 my @tr = _tracking($r);
613 2 ▶ my $ab = @tr && ( $tr[1] || $tr[2] ) ? ' [' . join( ', ', ( $tr[1] ? "ahead $tr[1]" : () ), ( $tr[2] ? "behind $tr[2]" : () ) ) . ']' : '';
Branch: 3 branches
BranchTrueFalseTotal
@tr && ($tr[1] || $tr[2]) ? : 0 2 2
$tr[1] ? : 0 0 0
$tr[2] ? : 0 0 0
Condition33%2/6
@tr and $tr[1] || $tr[2]
!ll&&!rl&&r
020
$tr[1] or $tr[2]
l!l&&r!l&&!r
002
MC/DC0%0/3
@tr and $tr[1] || $tr[2]
@tr $tr[1] $tr[2]
Truth table25%1/4
A and B or C
A= @trB= $tr[1]C= $tr[2]
ABCresult
0XX0
1000
11X1
1011
614 2 ▶ my @l = ( ( grep { /\A-\w*b/ || $_ eq '--branch' } @$a ) ? '## ' . ( $r->{branch} // 'HEAD (no branch)' ) . ( @tr ? "...$tr[0]$ab" : '' ) : () );
Branch: 2 branches
BranchTrueFalseTotal
grep({/\A-\w*b/ or $_ eq '--branch';} @$a) ? : 0 2 2
@tr ? : 0 0 0
Condition20%1/5
/\A-\w*b/ || $_ eq '--branch'
l!l&&r!l&&!r
002
$$r{"branch"} // "HEAD (no branch)"
l!l
00
MC/DC0%0/2
/\A-\w*b/ || $_ eq '--branch'
/\A-\w*b/ $_ eq '--branch'
MC/DC0%0/1
$$r{"branch"} // "HEAD (no branch)"
$$r{"branch"}
Truth table33%1/3
A || B
A= /\A-\w*b/B= $_ eq '--branch'
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
615 2 ▶ push @l, map { ( $m{$_}[0] // ' ' ) . ( $m{$_}[1] // ' ' ) . " $_" } sort keys %m;
Condition50%2/4
$m{$_}[0] // " "
l!l
01
$m{$_}[1] // " "
l!l
10
MC/DC0%0/1
$m{$_}[0] // " "
$m{$_}[0]
MC/DC0%0/1
$m{$_}[1] // " "
$m{$_}[1]
Truth table50%1/2
A
A= $m{$_}[0]
Aresult
11
00
Truth table50%1/2
A
A= $m{$_}[1]
Aresult
11
00
616 2 push @l, map {"?? $_"} @$ut;
617 2 return ( join( "\n", @l ), 1 );
618 }
619 3 ▶ my @l = defined $r->{branch} ? ("On branch $r->{branch}") : ( 'HEAD detached at ' . _short( $r->{detached} ) );
Branch: 1 branch
BranchTrueFalseTotal
defined $$r{'branch'} ? : 3 0 3
620 3 ▶ if ( my ( $up, $ah, $be ) = _tracking($r) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = _tracking($r)) 3 0 3
621 3 ▶ push @l, $ah && $be ? ( "Your branch and '$up' have diverged,", "and have $ah and $be different commits each, respectively.", ' (use "git pull" to merge the remote branch into yours)' )
Branch: 5 branches
BranchTrueFalseTotal
$ah && $be ? : 0 3 3
$ah ? : 1 2 3
$ah > 1 ? : 0 1 1
$be ? : 0 2 2
$be > 1 ? : 0 0 0
Condition66%2/3
$ah and $be
!ll&&!rl&&r
210
MC/DC0%0/2
$ah and $be
$ah $be
Truth table66%2/3
A and B
A= $ahB= $be
ABresult
0X0
100
111
622 : $ah ? ( "Your branch is ahead of '$up' by $ah commit" . ( $ah > 1 ? 's' : '' ) . '.', ' (use "git push" to publish your local commits)' )
623 : $be ? ( "Your branch is behind '$up' by $be commit" . ( $be > 1 ? 's' : '' ) . ', and can be fast-forwarded.', ' (use "git pull" to update your local branch)' )
624 : ("Your branch is up to date with '$up'.");
625 }
626 0 ▶ push @l, '', 'Changes to be committed:', ' (use "git restore --staged <file>..." to unstage)', map( { sprintf "\t%-12s%s", "$_->[0]:", $_->[1] } @$st ) if @$st;
Branch: 1 branch
BranchTrueFalseTotal
if @$st 0 3 3
627 push @l, '', 'Changes not staged for commit:', ' (use "git add <file>..." to update what will be committed)', ' (use "git restore <file>..." to discard changes in working directory)',
628 3 ▶ map( { sprintf "\t%-12s%s", "$_->[0]:", $_->[1] } @$un ) if @$un;
Branch: 1 branch
BranchTrueFalseTotal
if @$un 1 2 3
629 3 ▶ push @l, '', 'Untracked files:', ' (use "git add <file>..." to include in what will be committed)', map( {"\t$_"} @$ut ) if @$ut;
Branch: 1 branch
BranchTrueFalseTotal
if @$ut 2 1 3
630 3 ▶ push @l, '', !@$st && !@$un ? ( @$ut ? 'nothing added to commit but untracked files present (use "git add" to track)' : 'nothing to commit, working tree clean' )
Branch: 4 branches
BranchTrueFalseTotal
unless @$st and @$un 3 0 3
!(@$st || @$un) ? : 2 1 3
@$ut ? : 1 1 2
!@$st ? : 1 0 1
Condition50%3/6
@$st and @$un
!ll&&!rl&&r
300
@$st || @$un
l!l&&r!l&&!r
012
MC/DC0%0/2
@$st and @$un
@$st @$un
MC/DC50%1/2
@$st || @$un
@$st @$un
Truth table33%1/3
A and B
A= @$stB= @$un
ABresult
0X0
100
111
Truth table66%2/3
A || B
A= @$stB= @$un
ABresult
1X1
011
000
631 : !@$st ? 'no changes added to commit (use "git add" and/or "git commit -a")' : () if !@$st || !@$un;
632 3 return ( join( "\n", @l ), 1 );
633 }
634  
635 # Pfadangaben (relativ zum Arbeitsverzeichnis) -> relative Pfade im Repo
636 6 ▶sub _paths {
Subroutine _paths: called CC=8 SCAR=25.2
637 6 my ( $root, $cwd, @p ) = @_;
638 6 my @r;
639 6 for my $x (@p) {
640 6 ▶ my $abs = $x =~ m{\A/} ? $x : ( $cwd // $root ) . "/$x";
Branch: 1 branch
BranchTrueFalseTotal
$x =~ m[\A/] ? : 6 0 6
Condition0%0/3
$cwd // $root
l!l&&r!l&&!r
000
MC/DC0%0/2
$cwd // $root
$cwd $root
Truth table0%0/3
A // B
A= $cwdB= $root
ABresult
1X1
011
000
641 6 ▶ 1 while $abs =~ s{/\./}{/} || $abs =~ s{/[^/]+/\.\.(?:/|\z)}{/};
Branch: 1 branch
BranchTrueFalseTotal
$abs =~ s[/\./][/] || $abs =~ s[/[^/]+/\.\.(?:/|\z)][/] and do { '???' } 0 6 6
Condition33%1/3
$abs =~ s[/\./][/] or $abs =~ s[/[^/]+/\.\.(?:/|\z)][/]
l!l&&r!l&&!r
006
MC/DC0%0/2
$abs =~ s[/\./][/] or $abs =~ s[/[^/]+/\.\.(?:/|\z)][/]
$abs =~ s[/\./][/] $abs =~ s[/[^/]+/\.\.(?:/|\z)][/]
Truth table33%1/3
A or B
A= $abs =~ s[/\./][/]B= $abs =~ s[/[^/]+/\.\.(?:/|\z)][/]
ABresult
1X1
011
000
642 6 $abs =~ s{/\.?\z}{};
643 6 ▶ push @r, $abs eq $root ? '' : index( $abs, "$root/" ) == 0 ? substr( $abs, length($root) + 1 ) : undef;
Branch: 2 branches
BranchTrueFalseTotal
$abs eq $root ? : 0 6 6
index($abs, "$root/") == 0 ? : 6 0 6
644 }
645 6 return @r;
646 }
647  
648 5 ▶sub _match_paths {
Subroutine _match_paths: called CC=4 SCAR=14.5
649 5 my ( $tree, $pat ) = @_;
650 5 ▶ return grep { $pat eq '' || $_ eq $pat || index( $_, "$pat/" ) == 0 || _glob_match( $pat, $_ ) } sort keys %$tree;
Condition66%6/9
$pat eq '' || $_ eq $pat || index($_, "$pat/") == 0 || _glob_match($pat, $_)
l!l&&r!l&&!r
5023
$pat eq "" or $_ eq $pat or index($_, "$pat/") == 0
l!l&&r!l&&!r
5023
$pat eq "" or $_ eq $pat
l!l&&r!l&&!r
0523
MC/DC25%1/4
$pat eq '' || $_ eq $pat || index($_, "$pat/") == 0 || _glob_match($pat, $_)
$pat eq "" $_ eq $pat index($_, "$pat/") == 0 _glob_match($pat, $_)
Truth table40%2/5
A or B or C || D
A= $pat eq ""B= $_ eq $patC= index($_, "$pat/") == 0D= _glob_match($pat, $_)
ABCDresult
1XXX1
01XX1
001X1
00011
00000
651 }
652  
653 0 ▶sub _glob_match { my ( $g, $p ) = @_; return 0 unless $g =~ /[*?]/; ( my $re = quotemeta $g ) =~ s/\\\*/.*/g; $re =~ s/\\\?/./g; return $p =~ /\A$re\z/ ? 1 : 0 }
Subroutine _glob_match: called CC=3 SCAR=17.3
Branch: 2 branches
BranchTrueFalseTotal
unless $g =~ /[*?]/ 23 0 23
$p =~ /\A$re\z/ ? : 0 0 0
654  
655 3 ▶sub _g_add {
Subroutine _g_add: called CC=18 SCAR=38.3
656 3 my ( $dev, $root, $r, $a ) = @_;
657 3 my @o = grep {/\A-/} @$a;
658 3 my @p = grep { !/\A-/ } @$a;
659 0 ▶ return ( "Nothing specified, nothing added.\nhint: Maybe you wanted to say 'git add .'?", 0 ) unless @p || grep { /\A(?:-A|--all|-u|--update)\z/ } @o;
Branch: 1 branch
BranchTrueFalseTotal
unless @p or grep {/\A(?:-A|--all|-u|--update)\z/;} @o 0 3 3
Condition33%1/3
@p or grep {/\A(?:-A|--all|-u|--update)\z/;} @o
l!l&&r!l&&!r
300
MC/DC0%0/2
@p or grep {/\A(?:-A|--all|-u|--update)\z/;} @o
@p grep {/\A(?:-A|--all|-u|--update)\z/;} @o
Truth table33%1/3
A or B
A= @pB= grep {/\A(?:-A|--all|-u|--update)\z/;} @o
ABresult
1X1
011
000
660 0 ▶ return do { push @GAPS, 'git add -p'; ( '', 0 ) } if grep { /\A(?:-p|--patch|-i|--interactive)\z/ } @o;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/\A(?:-p|--patch|-i|--interactive)\z/;} @o 0 3 3
661 3 my $w = _work( $dev, $root );
662 3 my $idx = _index($r);
663 3 my @ig = _ignore_res($w);
664 0 my $all = grep { /\A(?:-A|--all)\z/ } @o;
665 0 my $upd = grep { /\A(?:-u|--update)\z/ } @o;
666 0 my $force = grep { /\A(?:-f|--force)\z/ } @o;
667 3 ▶ @p = ('') if !@p;
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 3 3
668 3 for my $pat ( _paths( $root, $CWD, @p ) ) {
669 3 ▶ return ( "fatal: pathspec outside repository", 0 ) unless defined $pat;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pat 0 3 3
670 3 my @hit = _match_paths( { %$w, %$idx }, $pat );
671 3 ▶ return ( "fatal: pathspec '$pat' did not match any files", 0 ) unless @hit || $pat eq '';
Branch: 1 branch
BranchTrueFalseTotal
unless @hit or $pat eq "" 0 3 3
Condition33%1/3
@hit or $pat eq ""
l!l&&r!l&&!r
300
MC/DC0%0/2
@hit or $pat eq ""
@hit $pat eq ""
Truth table33%1/3
A or B
A= @hitB= $pat eq ""
ABresult
1X1
011
000
672 3 for my $f (@hit) {
673 3 ▶ next if $upd && !exists $idx->{$f};
Branch: 1 branch
BranchTrueFalseTotal
if $upd and not exists $$idx{$f} 0 3 3
Condition33%1/3
$upd and not exists $$idx{$f}
!ll&&!rl&&r
300
MC/DC0%0/2
$upd and not exists $$idx{$f}
$upd not exists $$idx{$f}
Truth table33%1/3
A and not(B)
A= $updB= not exists $$idx{$f}
ABresult
0X0
100
111
674 3 ▶ if ( exists $w->{$f} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $$w{$f}) { } 3 0 3
elsif (exists $$idx{$f}) { } 0 0 0
675 3 ▶ if ( !exists $idx->{$f} && _ignored( \@ig, $f ) && !$force ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $$idx{$f} and _ignored(\@ig, $f) and not $force) 0 3 3
Condition50%3/6
not exists $$idx{$f} and _ignored(\@ig, $f) and not $force
!ll&&!rl&&r
300
not exists $$idx{$f} and _ignored(\@ig, $f)
!ll&&!rl&&r
210
MC/DC0%0/3
not exists $$idx{$f} and _ignored(\@ig, $f) and not $force
not exists $$idx{$f} _ignored(\@ig, $f) not $force
Truth table50%2/4
not(A) and B and not(C)
A= not exists $$idx{$f}B= _ignored(\@ig, $f)C= not $force
ABCresult
0XX0
10X0
1100
1111
676 0 ▶ return ( "The following paths are ignored by one of your .gitignore files:\n$f\nhint: Use -f if you really want to add them.", 0 ) if $pat eq $f;
Branch: 1 branch
BranchTrueFalseTotal
if $pat eq $f 0 0 0
677 0 next;
678 }
679 3 $idx->{$f} = $w->{$f};
680 }
681 0 elsif ( exists $idx->{$f} ) { delete $idx->{$f} }
682 }
683 }
684 3 $r->{index} = $idx;
685 3 return ( '', 1 );
686 }
687  
688 1 ▶sub _g_rm {
Subroutine _g_rm: called CC=11 SCAR=26.8
689 1 my ( $dev, $root, $r, $a ) = @_;
690 1 my $cached = grep { $_ eq '--cached' } @$a;
691 1 my $rec = grep { /\A-r|\A-rf\z|\A-fr\z/ } @$a;
692 1 my $idx = _index($r);
693 1 my @p = grep { !/\A-/ } @$a;
694 1 my @out;
695 1 for my $pat ( _paths( $root, $CWD, @p ) ) {
696 1 ▶ my @hit = grep { exists $idx->{$_} } _match_paths( $idx, $pat // "\0" );
Condition50%1/2
$pat // "\0"
l!l
10
MC/DC0%0/1
$pat // "\0"
$pat
Truth table50%1/2
A
A= $pat
Aresult
11
00
697 1 ▶ return ( "fatal: pathspec '" . ( $pat // '' ) . "' did not match any files", 0 ) unless @hit;
Branch: 1 branch
BranchTrueFalseTotal
unless @hit 0 1 1
Condition0%0/2
$pat // ""
l!l
00
MC/DC0%0/1
$pat // ""
$pat
Truth table0%0/2
A
A= $pat
Aresult
11
00
698 1 ▶ return ( "fatal: not removing '$pat' recursively without -r", 0 ) if !$rec && ( @hit > 1 || $hit[0] ne $pat ) && !_glob_match( $pat, $hit[0] );
Branch: 1 branch
BranchTrueFalseTotal
if not $rec and @hit > 1 || $hit[0] ne $pat and not _glob_match($pat, $hit[0]) 0 1 1
Condition33%3/9
not $rec and @hit > 1 || $hit[0] ne $pat and not _glob_match($pat, $hit[0])
!ll&&!rl&&r
100
not $rec and @hit > 1 || $hit[0] ne $pat
!ll&&!rl&&r
010
@hit > 1 or $hit[0] ne $pat
l!l&&r!l&&!r
001
MC/DC0%0/4
not $rec and @hit > 1 || $hit[0] ne $pat and not _glob_match($pat, $hit[0])
not $rec @hit > 1 $hit[0] ne $pat not _glob_match($pat, $hit[0])
Truth table16%1/6
not(A) and B or C and not(D)
A= not $recB= @hit > 1C= $hit[0] ne $patD= not _glob_match($pat, $hit[0])
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
699 1 for my $f (@hit) {
700 1 delete $idx->{$f};
701 1 ▶ delete $dev->{files}{"$root/$f"} unless $cached;
Branch: 1 branch
BranchTrueFalseTotal
unless $cached 0 1 1
702 1 push @out, "rm '$f'";
703 }
704 }
705 1 $r->{index} = $idx;
706 1 return ( join( "\n", @out ), 1 );
707 }
708  
709 0 ▶sub _g_mv {
Subroutine _g_mv: not called CC=9 SCAR=45.0
710 0 my ( $dev, $root, $r, $a ) = @_;
711 0 my @p = grep { !/\A-/ } @$a;
712 0 ▶ return ( 'usage: git mv [<options>] <source>... <destination>', 0 ) unless @p == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @p == 2 0 0 0
713 0 my ( $from, $to ) = _paths( $root, $CWD, @p );
714 0 my $idx = _index($r);
715 0 ▶ my @hit = grep { exists $idx->{$_} } _match_paths( $idx, $from // "\0" );
Condition0%0/2
$from // "\0"
l!l
00
MC/DC0%0/1
$from // "\0"
$from
Truth table0%0/2
A
A= $from
Aresult
11
00
716 0 ▶ return ( "fatal: not under version control, source=$p[0], destination=$p[1]", 0 ) unless @hit;
Branch: 1 branch
BranchTrueFalseTotal
unless @hit 0 0 0
717 0 for my $f (@hit) {
718 0 ( my $n = $f ) =~ s/\A\Q$from\E/$to/;
719 0 ▶ $n = "$to/" . ( $f =~ s{.*/}{}r ) if @hit == 1 && $f eq $from && exists( { map { ( $_ =~ s{/[^/]+\z}{}r ) => 1 } keys %$idx }->{$to} );
Branch: 1 branch
BranchTrueFalseTotal
if @hit == 1 and $f eq $from and exists {map({$_ =~ s[/[^/]+\z][]r, 1;} keys %$idx)}->{$to} 0 0 0
Condition0%0/6
@hit == 1 and $f eq $from and exists {map({$_ =~ s[/[^/]+\z][]r, 1;} keys %$idx)}->{$to}
!ll&&!rl&&r
000
@hit == 1 and $f eq $from
!ll&&!rl&&r
000
MC/DC0%0/3
@hit == 1 and $f eq $from and exists {map({$_ =~ s[/[^/]+\z][]r, 1;} keys %$idx)}->{$to}
@hit == 1 $f eq $from exists {map({$_ =~ s[/[^/]+\z][]r, 1;} keys %$idx)}->{$to}
Truth table0%0/4
A and B and C
A= @hit == 1B= $f eq $fromC= exists {map({$_ =~ s[/[^/]+\z][]r, 1;} keys %$idx)}->{$to}
ABCresult
0XX0
10X0
1100
1111
720 0 $idx->{$n} = delete $idx->{$f};
721 0 my $e = delete $dev->{files}{"$root/$f"};
722 0 ▶ $dev->{files}{"$root/$n"} = $e // $idx->{$n};
Condition0%0/3
$e // $$idx{$n}
l!l&&r!l&&!r
000
MC/DC0%0/2
$e // $$idx{$n}
$e $$idx{$n}
Truth table0%0/3
A // B
A= $eB= $$idx{$n}
ABresult
1X1
011
000
723 }
724 0 $r->{index} = $idx;
725 0 return ( '', 1 );
726 }
727  
728 1 ▶sub _g_restore {
Subroutine _g_restore: called CC=10 SCAR=28.2
729 1 my ( $dev, $root, $r, $a ) = @_;
730 1 ▶ my $staged = grep { $_ eq '--staged' || $_ eq '-S' } @$a;
Condition33%1/3
$_ eq '--staged' || $_ eq '-S'
l!l&&r!l&&!r
001
MC/DC0%0/2
$_ eq '--staged' || $_ eq '-S'
$_ eq '--staged' $_ eq '-S'
Truth table33%1/3
A || B
A= $_ eq '--staged'B= $_ eq '-S'
ABresult
1X1
011
000
731 1 my $idx = _index($r);
732 1 my $head = _tree( $r, _head($r) );
733 1 for my $pat ( _paths( $root, $CWD, grep { !/\A-/ } @$a ) ) {
734 1 ▶ my @hit = _match_paths( { %$idx, %$head }, $pat // "\0" );
Condition50%1/2
$pat // "\0"
l!l
10
MC/DC0%0/1
$pat // "\0"
$pat
Truth table50%1/2
A
A= $pat
Aresult
11
00
735 1 ▶ return ( "error: pathspec '" . ( $pat // '' ) . "' did not match any file(s) known to git", 0 ) unless @hit;
Branch: 1 branch
BranchTrueFalseTotal
unless @hit 0 1 1
Condition0%0/2
$pat // ""
l!l
00
MC/DC0%0/1
$pat // ""
$pat
Truth table0%0/2
A
A= $pat
Aresult
11
00
736 1 for my $f (@hit) {
737 0 ▶ if ($staged) { if ( exists $head->{$f} ) { $idx->{$f} = $head->{$f} } else { delete $idx->{$f} } }
Branch: 3 branches
BranchTrueFalseTotal
if ($staged) { } 0 1 1
elsif (exists $$idx{$f}) { } 1 0 1
if (exists $$head{$f}) { } 0 0 0
738 1 elsif ( exists $idx->{$f} ) { $dev->{files}{"$root/$f"} = $idx->{$f} }
739 }
740 }
741 1 $r->{index} = $idx;
742 1 return ( '', 1 );
743 }
744  
745 7 ▶sub _g_commit {
Subroutine _g_commit: called CC=61 SCAR=62.5
746 7 my ( $dev, $root, $r, $a ) = @_;
747 7 my ( @msg, $amend, $noedit, $all, $reset, $author, $empty );
748 7 my @x = @$a;
749 7 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 9 7 16
750 9 my $o = shift @x;
751 9 ▶ if ( $o eq '-m' || $o eq '--message' ) { push @msg, shift(@x) // '' }
Branch: 12 branches
BranchTrueFalseTotal
if ($o eq '-m' or $o eq '--message') { } 3 6 9
elsif ($o =~ /\A(?:-m|--message=)(.+)\z/s) { } 0 6 6
elsif ($o =~ /\A-([a]*)m\z/) { } 3 3 6
elsif ($o eq '-a' or $o eq '--all') { } 0 3 3
elsif ($o eq '--amend') { } 2 1 3
elsif ($o eq '--no-edit') { } 1 0 1
elsif ($o eq '--reset-author') { } 0 0 0
elsif ($o =~ /\A--author=(.+)\z/) { } 0 0 0
elsif ($o eq '--author') { } 0 0 0
elsif ($o eq '--allow-empty') { } 0 0 0
elsif ($o eq '--no-verify' or $o eq '-n' or $o eq '-q' or $o eq '--quiet' or $o eq '-s' or $o eq '--signoff') { } 0 0 0
elsif ($o eq '-F' or $o eq '--file') { } 0 0 0
Condition60%3/5
$o eq "-m" or $o eq "--message"
l!l&&r!l&&!r
306
shift @x // ""
l!l
30
MC/DC50%1/2
$o eq "-m" or $o eq "--message"
$o eq "-m" $o eq "--message"
MC/DC0%0/1
shift @x // ""
shift @x
Truth table66%2/3
A or B
A= $o eq "-m"B= $o eq "--message"
ABresult
1X1
011
000
Truth table50%1/2
A
A= shift @x
Aresult
11
00
752 0 elsif ( $o =~ /\A(?:-m|--message=)(.+)\z/s ) { push @msg, $1 }
753 3 ▶ elsif ( $o =~ /\A-([a]*)m\z/ ) { $all = 1 if $1; push @msg, shift(@x) // '' }
Branch: 1 branch
BranchTrueFalseTotal
if $1 3 0 3
Condition50%1/2
shift @x // ""
l!l
30
MC/DC0%0/1
shift @x // ""
shift @x
Truth table50%1/2
A
A= shift @x
Aresult
11
00
754 0 ▶ elsif ( $o eq '-a' || $o eq '--all' ) { $all = 1 }
Condition33%1/3
$o eq "-a" or $o eq "--all"
l!l&&r!l&&!r
003
MC/DC0%0/2
$o eq "-a" or $o eq "--all"
$o eq "-a" $o eq "--all"
Truth table33%1/3
A or B
A= $o eq "-a"B= $o eq "--all"
ABresult
1X1
011
000
755 2 elsif ( $o eq '--amend' ) { $amend = 1 }
756 1 elsif ( $o eq '--no-edit' ) { $noedit = 1 }
757 0 elsif ( $o eq '--reset-author' ) { $reset = 1 }
758 0 elsif ( $o =~ /\A--author=(.+)\z/ ) { $author = $1 }
759 0 elsif ( $o eq '--author' ) { $author = shift @x }
760 0 elsif ( $o eq '--allow-empty' ) { $empty = 1 }
761 ▶ elsif ( $o eq '--no-verify' || $o eq '-n' || $o eq '-q' || $o eq '--quiet' || $o eq '-s' || $o eq '--signoff' ) { }
Condition0%0/15
$o eq "--no-verify" or $o eq "-n" or $o eq "-q" or $o eq "--quiet" or $o eq "-s" or $o eq "--signoff"
l!l&&r!l&&!r
000
$o eq "--no-verify" or $o eq "-n" or $o eq "-q" or $o eq "--quiet" or $o eq "-s"
l!l&&r!l&&!r
000
$o eq "--no-verify" or $o eq "-n" or $o eq "-q" or $o eq "--quiet"
l!l&&r!l&&!r
000
$o eq "--no-verify" or $o eq "-n" or $o eq "-q"
l!l&&r!l&&!r
000
$o eq "--no-verify" or $o eq "-n"
l!l&&r!l&&!r
000
MC/DC0%0/6
$o eq "--no-verify" or $o eq "-n" or $o eq "-q" or $o eq "--quiet" or $o eq "-s" or $o eq "--signoff"
$o eq "--no-verify" $o eq "-n" $o eq "-q" $o eq "--quiet" $o eq "-s" $o eq "--signoff"
Truth table0%0/7
A or B or C or D or E or F
A= $o eq "--no-verify"B= $o eq "-n"C= $o eq "-q"D= $o eq "--quiet"E= $o eq "-s"F= $o eq "--signoff"
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
762 0 ▶ elsif ( $o eq '-F' || $o eq '--file' ) { my $f = shift(@x) // ''; my $t = ( $dev->{files} || {} )->{ $f =~ m{\A/} ? $f : "$root/$f" }; return ( "fatal: could not read log file '$f': No such file or directory", 0 ) unless defined $t; push @msg, _text($t) =~ s/\n+\z//r }
Branch: 2 branches
BranchTrueFalseTotal
$f =~ m[\A/] ? : 0 0 0
unless defined $t 0 0 0
Condition0%0/7
$o eq "-F" or $o eq "--file"
l!l&&r!l&&!r
000
shift @x // ""
l!l
00
$$dev{'files'} || {}
l!l
00
MC/DC0%0/2
$o eq "-F" or $o eq "--file"
$o eq "-F" $o eq "--file"
MC/DC0%0/1
shift @x // ""
shift @x
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table0%0/3
A or B
A= $o eq "-F"B= $o eq "--file"
ABresult
1X1
011
000
Truth table0%0/2
A
A= shift @x
Aresult
11
00
Truth table0%0/2
A
A= $$dev{'files'}
Aresult
11
00
763 0 else { return ( "error: unknown option `" . ( $o =~ s/\A-+//r ) . "'", 0 ) }
764 }
765 7 ▶ if ($all) {
Branch: 1 branch
BranchTrueFalseTotal
if ($all) 3 4 7
766 3 my $w = _work( $dev, $root );
767 3 my $idx = _index($r);
768 0 ▶ for my $f ( keys %$idx ) { if ( exists $w->{$f} ) { $idx->{$f} = $w->{$f} } else { delete $idx->{$f} } }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$w{$f}) { } 13 0 13
769 3 $r->{index} = $idx;
770 }
771 7 my $head = _head($r);
772 7 ▶ my $hc = defined $head ? $r->{commits}{$head} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $head ? : 7 0 7
773 0 ▶ if ( !@msg && !( $amend && $noedit ) ) { push @GAPS, 'git commit (Editor)'; return ( 'error: There was a problem with the editor \'editor\'.', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless (@msg or $amend and $noedit) 0 7 7
Condition50%3/6
@msg or $amend and $noedit
l!l&&r!l&&!r
610
$amend and $noedit
!ll&&!rl&&r
001
MC/DC0%0/3
@msg or $amend and $noedit
@msg $amend $noedit
Truth table50%2/4
A or B and C
A= @msgB= $amendC= $noedit
ABCresult
1XX1
0111
00X0
0100
774 7 my $idx = _index($r);
775 7 ▶ my $parent_tree = $amend ? _tree( $r, ( $hc->{parents} || [] )->[0] ) : _tree( $r, $head );
Branch: 1 branch
BranchTrueFalseTotal
$amend ? : 2 5 7
Condition50%1/2
$$hc{'parents'} || []
l!l
20
MC/DC0%0/1
$$hc{'parents'} || []
$$hc{'parents'}
Truth table50%1/2
A
A= $$hc{'parents'}
Aresult
11
00
776 7 ▶ if ( !$amend && !$empty && $J->encode($idx) eq $J->encode( _tree( $r, $head ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $amend || $empty and $J->encode($idx) eq $J->encode(_tree($r, $head))) 0 7 7
Condition66%4/6
not $amend || $empty and $J->encode($idx) eq $J->encode(_tree($r, $head))
!ll&&!rl&&r
250
$amend || $empty
l!l&&r!l&&!r
205
MC/DC0%0/3
not $amend || $empty and $J->encode($idx) eq $J->encode(_tree($r, $head))
$amend $empty $J->encode($idx) eq $J->encode(_tree($r, $head))
Truth table50%2/4
not(A || B) and C
A= $amendB= $emptyC= $J->encode($idx) eq $J->encode(_tree($r, $head))
ABCresult
1XX0
01X0
0000
0011
777 0 my ( undef, $un, $ut ) = _changes( $dev, $root, $r );
778 0 ▶ return ( join( "\n", "On branch " . ( $r->{branch} // 'HEAD' ), @$un ? 'no changes added to commit (use "git add" and/or "git commit -a")' : @$ut ? 'nothing added to commit but untracked files present (use "git add" to track)' : 'nothing to commit, working tree clean' ), 0 );
Branch: 2 branches
BranchTrueFalseTotal
@$un ? : 0 0 0
@$ut ? : 0 0 0
Condition0%0/2
$$r{"branch"} // "HEAD"
l!l
00
MC/DC0%0/1
$$r{"branch"} // "HEAD"
$$r{"branch"}
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
779 }
780 7 ▶ return ( 'fatal: You have nothing to amend.', 0 ) if $amend && !$hc;
Branch: 1 branch
BranchTrueFalseTotal
if $amend and not $hc 0 7 7
Condition66%2/3
$amend and not $hc
!ll&&!rl&&r
520
MC/DC0%0/2
$amend and not $hc
$amend not $hc
Truth table66%2/3
A and not(B)
A= $amendB= not $hc
ABresult
0X0
100
111
781 7 ▶ my $msg = @msg ? join( "\n\n", @msg ) : $hc->{message};
Branch: 1 branch
BranchTrueFalseTotal
@msg ? : 6 1 7
782 7 ▶ my $who = $author // ( $amend && !$reset ? $hc->{author} : _who( $dev, $r ) );
Branch: 1 branch
BranchTrueFalseTotal
$amend && !$reset ? : 2 5 7
Condition50%3/6
$author // ($amend && !$reset ? $$hc{"author"} : _who($dev, $r))
l!l&&r!l&&!r
070
$amend and not $reset
!ll&&!rl&&r
502
MC/DC33%1/3
$author // ($amend && !$reset ? $$hc{"author"} : _who($dev, $r))
$author $amend not $reset
Truth table50%2/4
A // B and not(C)
A= $authorB= $amendC= not $reset
ABCresult
1XX1
0111
00X0
0100
783 7 ▶ $who = "$who <$who>" unless $who =~ /<.*>/;
Branch: 1 branch
BranchTrueFalseTotal
unless $who =~ /<.*>/ 0 7 7
784 2 ▶ my $id = _mk_commit( $dev, $r, parents => $amend ? [ @{ $hc->{parents} || [] } ] : [ grep {defined} $head ], message => $msg, author => $who, tree => _clone($idx),
Branch: 1 branch
BranchTrueFalseTotal
$amend && !$reset ? : 2 5 7
Condition60%3/5
$$hc{'parents'} || []
l!l
20
$amend and not $reset
!ll&&!rl&&r
502
MC/DC0%0/1
$$hc{'parents'} || []
$$hc{'parents'}
MC/DC50%1/2
$amend and not $reset
$amend not $reset
Truth table50%1/2
A
A= $$hc{'parents'}
Aresult
11
00
Truth table66%2/3
A and not(B)
A= $amendB= not $reset
ABresult
0X0
100
111
785 7 ▶ ( $amend && !$reset ? ( date => $hc->{date} ) : () ) );
Branch: 1 branch
BranchTrueFalseTotal
$amend ? : 2 5 7
786 0 ▶ if ( defined $r->{branch} ) { $r->{refs}{heads}{ $r->{branch} } = $id } else { $r->{detached} = $id }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$r{'branch'}) { } 7 0 7
787 7 delete $r->{index};
788 7 my $d = _diff_trees( $parent_tree, $idx, 'name-only' );
789 7 my $n = () = split /\n/, $d;
790 return ( '[' . ( $r->{branch} // 'detached HEAD' ) . ( defined $head || $amend ? '' : ' (root-commit)' ) . ' ' . _short($id) . '] ' . _subject($msg)
791 7 ▶ . ( $amend ? "\n Date: " . _date_text( $r->{commits}{$id}{date} ) : '' ) . "\n $n file" . ( $n == 1 ? '' : 's' ) . ' changed', 1 );
Branch: 3 branches
BranchTrueFalseTotal
defined $head || $amend ? : 7 0 7
$amend ? : 2 5 7
$n == 1 ? : 7 0 7
Condition40%2/5
$$r{"branch"} // "detached HEAD"
l!l
70
defined $head or $amend
l!l&&r!l&&!r
700
MC/DC0%0/1
$$r{"branch"} // "detached HEAD"
$$r{"branch"}
MC/DC0%0/2
defined $head or $amend
defined $head $amend
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
Truth table33%1/3
A or B
A= defined $headB= $amend
ABresult
1X1
011
000
792 }
793  
794 # Verweise auf einen Commit wie --decorate: (HEAD -> main, origin/main, tag: v1)
795 0 ▶sub _deco {
Subroutine _deco: not called CC=15 SCAR=54.8
796 0 my ( $r, $id ) = @_;
797 0 my @d;
798 0 my $h = _head($r);
799 0 ▶ if ( defined $h && $h eq $id ) { push @d, defined $r->{branch} ? "HEAD -> $r->{branch}" : 'HEAD' }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $h and $h eq $id) 0 0 0
defined $$r{'branch'} ? : 0 0 0
Condition0%0/3
defined $h and $h eq $id
!ll&&!rl&&r
000
MC/DC0%0/2
defined $h and $h eq $id
defined $h $h eq $id
Truth table0%0/3
A and B
A= defined $hB= $h eq $id
ABresult
0X0
100
111
800 0 ▶ push @d, grep { ( $r->{refs}{heads}{$_} // '' ) eq $id && $_ ne ( defined $h && $h eq $id ? $r->{branch} // '' : "\0" ) } sort keys %{ $r->{refs}{heads} || {} };
Branch: 1 branch
BranchTrueFalseTotal
defined $h && $h eq $id ? : 0 0 0
Condition0%0/12
($$r{'refs'}{'heads'}{$_} // '') eq $id && $_ ne (defined $h && $h eq $id ? $$r{'branch'} // '' : "\000")
!ll&&!rl&&r
000
$$r{"refs"}{"heads"}{$_} // ""
l!l
00
defined $h and $h eq $id
!ll&&!rl&&r
000
$$r{"branch"} // ""
l!l
00
$$r{'refs'}{'heads'} || {}
l!l
00
MC/DC0%0/2
($$r{'refs'}{'heads'}{$_} // '') eq $id && $_ ne (defined $h && $h eq $id ? $$r{'branch'} // '' : "\000")
$$r{"refs"}{"heads"}{$_} $_ ne (defined $h && $h eq $id ? $$r{'branch'} // '' : "\000")
MC/DC0%0/2
defined $h and $h eq $id
defined $h $h eq $id
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table0%0/3
A && B
A= $$r{"refs"}{"heads"}{$_}B= $_ ne (defined $h && $h eq $id ? $$r{'branch'} // '' : "\000")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $hB= $h eq $id
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
801 0 ▶ push @d, grep { ( $r->{refs}{remotes}{$_} // '' ) eq $id } sort keys %{ $r->{refs}{remotes} || {} };
Condition0%0/4
$$r{"refs"}{"remotes"}{$_} // ""
l!l
00
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/1
$$r{"refs"}{"remotes"}{$_} // ""
$$r{"refs"}{"remotes"}{$_}
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table0%0/2
A
A= $$r{"refs"}{"remotes"}{$_}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
802 0 ▶ push @d, map {"tag: $_"} grep { ( $r->{refs}{tags}{$_}{commit} // '' ) eq $id } sort keys %{ $r->{refs}{tags} || {} };
Condition0%0/4
$$r{"refs"}{"tags"}{$_}{"commit"} // ""
l!l
00
$$r{'refs'}{'tags'} || {}
l!l
00
MC/DC0%0/1
$$r{"refs"}{"tags"}{$_}{"commit"} // ""
$$r{"refs"}{"tags"}{$_}{"commit"}
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table0%0/2
A
A= $$r{"refs"}{"tags"}{$_}{"commit"}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
803 0 ▶ return @d ? ' (' . join( ', ', @d ) . ')' : '';
Branch: 1 branch
BranchTrueFalseTotal
@d ? : 0 0 0
804 }
805  
806 0 ▶sub _ago { my ($t) = @_; my $h = int( ( 1792832400 + 3600 - $t ) / 3600 ); return $h < 1 ? 'vor wenigen Minuten' =~ s/.*/minutes ago/r : $h < 48 ? "$h hours ago" : int( $h / 24 ) . ' days ago' }
Subroutine _ago: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
$h < 1 ? : 0 0 0
$h < 48 ? : 0 0 0
807  
808 0 ▶sub _fmt_commit {
Subroutine _fmt_commit: not called CC=8 SCAR=42.8
809 0 my ( $r, $id, $fmt ) = @_;
810 0 my $c = $r->{commits}{$id};
811 0 my ( $an, $ae ) = $c->{author} =~ /\A(.*?)\s*<(.*)>\z/;
812 my %ph = ( H => $id, h => _short($id), s => _subject( $c->{message} ), an => $an // '', ae => $ae // '', ad => _date_text( $c->{date} ),
813 0 ▶ b => ( $c->{message} =~ /\A[^\n]*\n\n(.*)\z/s ? "$1\n" : '' ), B => "$c->{message}\n", P => join( ' ', @{ $c->{parents} || [] } ),
Condition0%0/2
$$c{'parents'} || []
l!l
00
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table0%0/2
A
A= $$c{'parents'}
Aresult
11
00
814 0 ▶ p => join( ' ', map { _short($_) } @{ $c->{parents} || [] } ), cn => $an // '', ce => $ae // '', cd => _date_text( $c->{date} ), n => "\n",
Condition0%0/6
$$c{'parents'} || []
l!l
00
$an // ""
l!l
00
$ae // ""
l!l
00
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
MC/DC0%0/1
$an // ""
$an
MC/DC0%0/1
$ae // ""
$ae
Truth table0%0/2
A
A= $$c{'parents'}
Aresult
11
00
Truth table0%0/2
A
A= $an
Aresult
11
00
Truth table0%0/2
A
A= $ae
Aresult
11
00
815 ar => _ago( $c->{date} ), cr => _ago( $c->{date} ), d => _deco( $r, $id ), D => _deco( $r, $id ) =~ s/\A \((.*)\)\z/$1/r,
816 0 ▶ aI => _iso( $c->{date} ), cI => _iso( $c->{date} ), ai => _iso( $c->{date} ), ci => _iso( $c->{date} ), T => '', t => '', '%' => '%' );
Branch: 1 branch
BranchTrueFalseTotal
$$c{'message'} =~ /\A[^\n]*\n\n(.*)\z/s ? : 0 0 0
Condition0%0/4
$an // ""
l!l
00
$ae // ""
l!l
00
MC/DC0%0/1
$an // ""
$an
MC/DC0%0/1
$ae // ""
$ae
Truth table0%0/2
A
A= $an
Aresult
11
00
Truth table0%0/2
A
A= $ae
Aresult
11
00
817 0 ( my $o = $fmt ) =~ s/%(an|ae|ad|ar|aI|ai|cn|ce|cd|cr|cI|ci|[HhsbBPpndDTt%])/$ph{$1}/g;
818 0 return $o;
819 }
820  
821 0 ▶sub _iso { my ($t) = @_; my @g = gmtime( $t + 7200 ); return sprintf '%04d-%02d-%02dT%02d:%02d:%02d+02:00', $g[5] + 1900, $g[4] + 1, @g[ 3, 2, 1, 0 ] }
Subroutine _iso: not called CC=1 SCAR=6.9
822  
823 4 ▶sub _log_text {
Subroutine _log_text: called CC=13 SCAR=30.8
824 4 my ( $r, $ids, %o ) = @_;
825 4 my @out;
826 4 for my $id (@$ids) {
827 9 my $c = $r->{commits}{$id};
828 9 ▶ my $deco = $o{decorate} ? _deco( $r, $id ) : '';
Branch: 1 branch
BranchTrueFalseTotal
$o{'decorate'} ? : 0 9 9
829 0 ▶ if ( defined $o{format} ) { push @out, _fmt_commit( $r, $id, $o{format} ); next }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o{"format"}) 0 9 9
830 9 ▶ if ( $o{oneline} ) { push @out, _short($id) . $deco . ' ' . _subject( $c->{message} ); next }
Branch: 1 branch
BranchTrueFalseTotal
if ($o{"oneline"}) 8 1 9
831 0 ▶ my @l = ( "commit $id$deco", ( @{ $c->{parents} || [] } > 1 ? 'Merge: ' . join( ' ', map { _short($_) } @{ $c->{parents} } ) : () ), "Author: $c->{author}", 'Date: ' . _date_text( $c->{date} ), '',
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
832 1 ▶ map( {" $_"} split /\n/, $c->{message} ) );
Branch: 1 branch
BranchTrueFalseTotal
@{$$c{'parents'} or [];} > 1 ? : 0 1 1
833 1 ▶ push @l, '', _diff_trees( _tree( $r, ( $c->{parents} || [] )->[0] ), $c->{tree}, 'stat' ) if $o{stat};
Branch: 1 branch
BranchTrueFalseTotal
if $o{"stat"} 1 0 1
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
834 1 ▶ push @l, '', _diff_trees( _tree( $r, ( $c->{parents} || [] )->[0] ), $c->{tree}, 'name-only' ) if $o{names};
Branch: 1 branch
BranchTrueFalseTotal
if $o{"names"} 0 1 1
Condition0%0/2
$$c{'parents'} || []
l!l
00
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table0%0/2
A
A= $$c{'parents'}
Aresult
11
00
835 1 ▶ push @l, '', _diff_trees( _tree( $r, ( $c->{parents} || [] )->[0] ), $c->{tree} ) if $o{patch};
Branch: 1 branch
BranchTrueFalseTotal
if $o{"patch"} 0 1 1
Condition0%0/2
$$c{'parents'} || []
l!l
00
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table0%0/2
A
A= $$c{'parents'}
Aresult
11
00
836 1 push @out, join( "\n", @l ) . "\n";
837 }
838 4 return join( "\n", @out ) =~ s/\n+\z//r;
839 }
840  
841 3 ▶sub _g_log {
Subroutine _g_log: called CC=46 SCAR=61.3
842 3 my ( $dev, $root, $r, $a ) = @_;
843 3 my ( %o, @revs, @paths );
844 3 my @x = @$a;
845 3 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 5 3 8
846 5 my $v = shift @x;
847 5 ▶ if ( $v eq '--oneline' ) { $o{oneline} = 1 }
Branch: 13 branches
BranchTrueFalseTotal
if ($v eq '--oneline') { } 3 2 5
elsif ($v =~ /\A-(\d+)\z/) { } 1 1 2
elsif ($v eq '-n' or $v eq '--max-count') { } 0 1 1
elsif ($v =~ /\A(?:-n|--max-count=)(\d+)\z/) { } 0 1 1
elsif ($v =~ /\A--(?:format|pretty)=(?:format:|tformat:)?(.*)\z/s) { } 0 1 1
elsif ($v eq '--stat') { } 0 1 1
elsif ($v eq '--name-only' or $v eq '--name-status') { } 0 1 1
elsif ($v eq '-p' or $v eq '--patch') { } 0 1 1
elsif ($v eq '--all') { } 1 0 1
elsif ($v eq '--') { } 0 0 0
elsif ($v =~ /\A--decorate(?:=\w+)?\z/) { } 0 0 0
elsif ($v =~ /\A--(?:graph|no-decorate|abbrev-commit|no-merges|first-parent|reverse|color|no-color|date=\S+)\z/) { } 0 0 0
elsif ($v =~ /\A-/) { } 0 0 0
848 1 elsif ( $v =~ /\A-(\d+)\z/ ) { $o{n} = $1 }
849 0 ▶ elsif ( $v eq '-n' || $v eq '--max-count' ) { $o{n} = shift @x }
Condition33%1/3
$v eq "-n" or $v eq "--max-count"
l!l&&r!l&&!r
001
MC/DC0%0/2
$v eq "-n" or $v eq "--max-count"
$v eq "-n" $v eq "--max-count"
Truth table33%1/3
A or B
A= $v eq "-n"B= $v eq "--max-count"
ABresult
1X1
011
000
850 0 elsif ( $v =~ /\A(?:-n|--max-count=)(\d+)\z/ ) { $o{n} = $1 }
851 0 ▶ elsif ( $v =~ /\A--(?:format|pretty)=(?:format:|tformat:)?(.*)\z/s ) { my $f = $1; $o{format} = $f eq 'oneline' ? undef : $f; $o{oneline} = 1 if $f eq 'oneline'; $o{format} = '%H%nAuthor: %an <%ae>%n%n %s' if $f =~ /\A(?:full|fuller|medium)\z/ }
Branch: 3 branches
BranchTrueFalseTotal
$f eq 'oneline' ? : 0 0 0
if $f eq "oneline" 0 0 0
if $f =~ /\A(?:full|fuller|medium)\z/ 0 0 0
852 0 elsif ( $v eq '--stat' ) { $o{stat} = 1 }
853 0 ▶ elsif ( $v eq '--name-only' || $v eq '--name-status' ) { $o{names} = 1 }
Condition33%1/3
$v eq "--name-only" or $v eq "--name-status"
l!l&&r!l&&!r
001
MC/DC0%0/2
$v eq "--name-only" or $v eq "--name-status"
$v eq "--name-only" $v eq "--name-status"
Truth table33%1/3
A or B
A= $v eq "--name-only"B= $v eq "--name-status"
ABresult
1X1
011
000
854 0 ▶ elsif ( $v eq '-p' || $v eq '--patch' ) { $o{patch} = 1 }
Condition33%1/3
$v eq "-p" or $v eq "--patch"
l!l&&r!l&&!r
001
MC/DC0%0/2
$v eq "-p" or $v eq "--patch"
$v eq "-p" $v eq "--patch"
Truth table33%1/3
A or B
A= $v eq "-p"B= $v eq "--patch"
ABresult
1X1
011
000
855 1 elsif ( $v eq '--all' ) { $o{all} = 1 }
856 0 elsif ( $v eq '--' ) { @paths = @x; last }
857 0 elsif ( $v =~ /\A--decorate(?:=\w+)?\z/ ) { $o{decorate} = 1 }
858 0 ▶ elsif ( $v =~ /\A--(?:graph|no-decorate|abbrev-commit|no-merges|first-parent|reverse|color|no-color|date=\S+)\z/ ) { $o{reverse} = 1 if $v eq '--reverse' }
Branch: 1 branch
BranchTrueFalseTotal
if $v eq "--reverse" 0 0 0
859 0 elsif ( $v =~ /\A-/ ) { return ( "fatal: unrecognized argument: $v", 0 ) }
860 0 else { push @revs, $v }
861 }
862 3 my @ids;
863 3 ▶ if ( $o{all} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o{'all'}) { } 1 2 3
864 1 my %s;
865 0 ▶ my @tips = ( values %{ $r->{refs}{heads} || {} }, values %{ $r->{refs}{remotes} || {} }, map { $_->{commit} } values %{ $r->{refs}{tags} || {} } );
Condition50%3/6
$$r{'refs'}{'heads'} || {}
l!l
10
$$r{'refs'}{'remotes'} || {}
l!l
10
$$r{'refs'}{'tags'} || {}
l!l
10
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table50%1/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
Truth table50%1/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
Truth table50%1/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
866 1 @ids = grep { !$s{$_}++ } map { _range( $r, undef, $_ ) } @tips;
867 1 @ids = _newest_first( $r, @ids );
868 }
869 else {
870 2 my ( $from, $to );
871 2 ▶ if ( @revs && $revs[0] =~ /\A(.*?)\.\.(.*)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@revs and $revs[0] =~ /\A(.*?)\.\.(.*)\z/) { } 0 2 2
Condition33%1/3
@revs and $revs[0] =~ /\A(.*?)\.\.(.*)\z/
!ll&&!rl&&r
200
MC/DC0%0/2
@revs and $revs[0] =~ /\A(.*?)\.\.(.*)\z/
@revs $revs[0] =~ /\A(.*?)\.\.(.*)\z/
Truth table33%1/3
A and B
A= @revsB= $revs[0] =~ /\A(.*?)\.\.(.*)\z/
ABresult
0X0
100
111
872 0 ( $from, $to ) = ( $1, $2 );
873 0 ▶ $from = _rev( $r, length $from ? $from : 'HEAD' ) // return ( "fatal: ambiguous argument '$revs[0]': unknown revision or path not in the working tree.", 0 );
Branch: 1 branch
BranchTrueFalseTotal
length $from ? : 0 0 0
Condition0%0/2
_rev($r, length $from ? $from : "HEAD") // (return "fatal: ambiguous argument '$revs[0]': unknown revision or path not in the working tree.", 0)
l!l
00
MC/DC0%0/1
_rev($r, length $from ? $from : "HEAD") // (return "fatal: ambiguous argument '$revs[0]': unknown revision or path not in the working tree.", 0)
_rev($r, length $from ? $from : "HEAD")
Truth table0%0/2
A
A= _rev($r, length $from ? $from : "HEAD")
Aresult
11
00
874 0 ▶ $to = _rev( $r, length $to ? $to : 'HEAD' ) // return ( "fatal: ambiguous argument '$revs[0]': unknown revision or path not in the working tree.", 0 );
Branch: 1 branch
BranchTrueFalseTotal
length $to ? : 0 0 0
Condition0%0/2
_rev($r, length $to ? $to : "HEAD") // (return "fatal: ambiguous argument '$revs[0]': unknown revision or path not in the working tree.", 0)
l!l
00
MC/DC0%0/1
_rev($r, length $to ? $to : "HEAD") // (return "fatal: ambiguous argument '$revs[0]': unknown revision or path not in the working tree.", 0)
_rev($r, length $to ? $to : "HEAD")
Truth table0%0/2
A
A= _rev($r, length $to ? $to : "HEAD")
Aresult
11
00
875 }
876 else {
877 2 ▶ $to = _rev( $r, $revs[0] // 'HEAD' );
Condition50%1/2
$revs[0] // "HEAD"
l!l
02
MC/DC0%0/1
$revs[0] // "HEAD"
$revs[0]
Truth table50%1/2
A
A= $revs[0]
Aresult
11
00
878 2 ▶ return ( "fatal: your current branch '" . ( $r->{branch} // '' ) . "' does not have any commits yet", 0 ) if !defined $to && !@revs;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $to or @revs 0 2 2
Condition20%1/5
defined $to or @revs
l!l&&r!l&&!r
200
$$r{"branch"} // ""
l!l
00
MC/DC0%0/2
defined $to or @revs
defined $to @revs
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
Truth table33%1/3
A or B
A= defined $toB= @revs
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
879 2 ▶ return ( "fatal: ambiguous argument '$revs[0]': unknown revision or path not in the working tree.", 0 ) unless defined $to;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $to 0 2 2
880 }
881 2 @ids = reverse _range( $r, $from, $to );
882 }
883 3 ▶ if (@paths) {
Branch: 1 branch
BranchTrueFalseTotal
if (@paths) 0 3 3
884 0 my @rel = _paths( $root, $CWD, @paths );
885 0 ▶ @ids = grep { my $c = $r->{commits}{$_}; my $p = _tree( $r, ( $c->{parents} || [] )->[0] ); my $t = $c->{tree};
Condition0%0/2
$$c{'parents'} || []
l!l
00
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table0%0/2
A
A= $$c{'parents'}
Aresult
11
00
886 0 ▶ grep { my $q = $_; grep { ( $p->{$_} // "\0" ) ne ( $t->{$_} // "\0" ) } _match_paths( { %$p, %$t }, $q // "\0" ) } @rel } @ids;
Condition0%0/6
$$p{$_} // "\0"
l!l
00
$$t{$_} // "\0"
l!l
00
$q // "\0"
l!l
00
MC/DC0%0/1
$$p{$_} // "\0"
$$p{$_}
MC/DC0%0/1
$$t{$_} // "\0"
$$t{$_}
MC/DC0%0/1
$q // "\0"
$q
Truth table0%0/2
A
A= $$p{$_}
Aresult
11
00
Truth table0%0/2
A
A= $$t{$_}
Aresult
11
00
Truth table0%0/2
A
A= $q
Aresult
11
00
887 }
888 3 ▶ @ids = @ids[ 0 .. $o{n} - 1 ] if defined $o{n} && $o{n} =~ /\A\d+\z/ && @ids > $o{n};
Branch: 1 branch
BranchTrueFalseTotal
if defined $o{"n"} and $o{"n"} =~ /\A\d+\z/ and @ids > $o{"n"} 1 2 3
Condition66%4/6
defined $o{"n"} and $o{"n"} =~ /\A\d+\z/ and @ids > $o{"n"}
!ll&&!rl&&r
201
defined $o{"n"} and $o{"n"} =~ /\A\d+\z/
!ll&&!rl&&r
201
MC/DC33%1/3
defined $o{"n"} and $o{"n"} =~ /\A\d+\z/ and @ids > $o{"n"}
defined $o{"n"} $o{"n"} =~ /\A\d+\z/ @ids > $o{"n"}
Truth table50%2/4
A and B and C
A= defined $o{"n"}B= $o{"n"} =~ /\A\d+\z/C= @ids > $o{"n"}
ABCresult
0XX0
10X0
1100
1111
889 3 ▶ @ids = reverse @ids if $o{reverse};
Branch: 1 branch
BranchTrueFalseTotal
if $o{"reverse"} 0 3 3
890 3 return ( _log_text( $r, \@ids, %o ), 1 );
891 }
892  
893 1 ▶sub _g_show {
Subroutine _g_show: called CC=17 SCAR=38.6
894 1 my ( $dev, $root, $r, $a ) = @_;
895 1 my @revs = grep { !/\A-/ } @$a;
896 1 my %o = ( patch => 1 );
897 0 ▶ for (@$a) { if ( $_ eq '--stat' ) { %o = ( stat => 1 ) } elsif ( $_ eq '--name-only' ) { %o = ( names => 1 ) } elsif (/\A--(?:format|pretty)=(?:format:)?(.*)\z/) { $o{format} = $1; delete $o{patch} } elsif ( $_ eq '--oneline' ) { $o{oneline} = 1 } }
Branch: 4 branches
BranchTrueFalseTotal
if ($_ eq '--stat') { } 1 1 2
elsif ($_ eq '--name-only') { } 0 1 1
elsif (/\A--(?:format|pretty)=(?:format:)?(.*)\z/) { } 0 1 1
elsif ($_ eq '--oneline') { } 0 1 1
898 1 my @out;
899 1 ▶ for my $spec ( @revs ? @revs : ('HEAD') ) {
Branch: 1 branch
BranchTrueFalseTotal
@revs ? : 1 0 1
900 1 ▶ if ( $spec =~ /\A(.*?):(.+)\z/ ) { # rev:pfad
Branch: 1 branch
BranchTrueFalseTotal
if ($spec =~ /\A(.*?):(.+)\z/) 0 1 1
901 0 ▶ my $id = _rev( $r, $1 ) // return ( "fatal: invalid object name '$1'.", 0 );
Condition0%0/2
_rev($r, $1) // (return "fatal: invalid object name '$1'.", 0)
l!l
00
MC/DC0%0/1
_rev($r, $1) // (return "fatal: invalid object name '$1'.", 0)
_rev($r, $1)
Truth table0%0/2
A
A= _rev($r, $1)
Aresult
11
00
902 0 my $t = _tree( $r, $id );
903 0 ▶ return ( "fatal: path '$2' does not exist in '$1'", 0 ) unless exists $t->{$2};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$t{$2} 0 0 0
904 0 push @out, $t->{$2} =~ s/\n\z//r;
905 0 next;
906 }
907 1 ▶ my $tag = ( $r->{refs}{tags} || {} )->{$spec};
Condition50%1/2
$$r{'refs'}{'tags'} || {}
l!l
10
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table50%1/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
908 1 ▶ my $id = _rev( $r, $spec ) // return ( "fatal: ambiguous argument '$spec': unknown revision or path not in the working tree.", 0 );
Condition50%1/2
_rev($r, $spec) // (return "fatal: ambiguous argument '${spec}': unknown revision or path not in the working tree.", 0)
l!l
10
MC/DC0%0/1
_rev($r, $spec) // (return "fatal: ambiguous argument '${spec}': unknown revision or path not in the working tree.", 0)
_rev($r, $spec)
Truth table50%1/2
A
A= _rev($r, $spec)
Aresult
11
00
909 1 ▶ push @out, "tag $spec\nTagger: " . ( $tag->{tagger} // '' ) . "\n\n" . ( $tag->{message} // '' ) . "\n" if $tag && $tag->{annotated};
Branch: 1 branch
BranchTrueFalseTotal
if $tag and $$tag{"annotated"} 1 0 1
Condition42%3/7
$tag and $$tag{"annotated"}
!ll&&!rl&&r
001
$$tag{"tagger"} // ""
l!l
10
$$tag{"message"} // ""
l!l
10
MC/DC0%0/2
$tag and $$tag{"annotated"}
$tag $$tag{"annotated"}
MC/DC0%0/1
$$tag{"tagger"} // ""
$$tag{"tagger"}
MC/DC0%0/1
$$tag{"message"} // ""
$$tag{"message"}
Truth table33%1/3
A and B
A= $tagB= $$tag{"annotated"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$tag{"tagger"}
Aresult
11
00
Truth table50%1/2
A
A= $$tag{"message"}
Aresult
11
00
910 1 push @out, _log_text( $r, [$id], %o );
911 }
912 1 return ( join( "\n", @out ), 1 );
913 }
914  
915 0 ▶sub _g_diff {
Subroutine _g_diff: not called CC=11 SCAR=48.8
916 0 my ( $dev, $root, $r, $a ) = @_;
917 0 my $cached = grep { /\A--(?:cached|staged)\z/ } @$a;
918 0 ▶ my ($mode) = map { /\A--(stat|name-only)\z/ ? $1 : () } @$a;
Branch: 1 branch
BranchTrueFalseTotal
/\A--(stat|name-only)\z/ ? : 0 0 0
919 0 my @revs = grep { !/\A-/ } @$a;
920 0 my ( $x, $y );
921 0 ▶ if ( @revs && $revs[0] =~ /\A(.+?)\.\.\.?(.+)\z/ ) { $x = _tree( $r, _rev( $r, $1 ) ); $y = _tree( $r, _rev( $r, $2 ) ) }
Branch: 4 branches
BranchTrueFalseTotal
if (@revs and $revs[0] =~ /\A(.+?)\.\.\.?(.+)\z/) { } 0 0 0
elsif (@revs >= 2 and defined _rev($r, $revs[0]) and defined _rev($r, $revs[1])) { } 0 0 0
elsif (@revs and defined _rev($r, $revs[0])) { } 0 0 0
elsif ($cached) { } 0 0 0
Condition0%0/3
@revs and $revs[0] =~ /\A(.+?)\.\.\.?(.+)\z/
!ll&&!rl&&r
000
MC/DC0%0/2
@revs and $revs[0] =~ /\A(.+?)\.\.\.?(.+)\z/
@revs $revs[0] =~ /\A(.+?)\.\.\.?(.+)\z/
Truth table0%0/3
A and B
A= @revsB= $revs[0] =~ /\A(.+?)\.\.\.?(.+)\z/
ABresult
0X0
100
111
922 0 ▶ elsif ( @revs >= 2 && defined _rev( $r, $revs[0] ) && defined _rev( $r, $revs[1] ) ) { $x = _tree( $r, _rev( $r, $revs[0] ) ); $y = _tree( $r, _rev( $r, $revs[1] ) ) }
Condition0%0/6
@revs >= 2 and defined _rev($r, $revs[0]) and defined _rev($r, $revs[1])
!ll&&!rl&&r
000
@revs >= 2 and defined _rev($r, $revs[0])
!ll&&!rl&&r
000
MC/DC0%0/3
@revs >= 2 and defined _rev($r, $revs[0]) and defined _rev($r, $revs[1])
@revs >= 2 defined _rev($r, $revs[0]) defined _rev($r, $revs[1])
Truth table0%0/4
A and B and C
A= @revs >= 2B= defined _rev($r, $revs[0])C= defined _rev($r, $revs[1])
ABCresult
0XX0
10X0
1100
1111
923 0 ▶ elsif ( @revs && defined _rev( $r, $revs[0] ) ) { $x = _tree( $r, _rev( $r, $revs[0] ) ); $y = $cached ? _index($r) : _work_tracked( $dev, $root, $r ) }
Branch: 1 branch
BranchTrueFalseTotal
$cached ? : 0 0 0
Condition0%0/3
@revs and defined _rev($r, $revs[0])
!ll&&!rl&&r
000
MC/DC0%0/2
@revs and defined _rev($r, $revs[0])
@revs defined _rev($r, $revs[0])
Truth table0%0/3
A and B
A= @revsB= defined _rev($r, $revs[0])
ABresult
0X0
100
111
924 0 elsif ($cached) { $x = _tree( $r, _head($r) ); $y = _index($r) }
925 0 else { $x = _index($r); $y = _work_tracked( $dev, $root, $r ) }
926 0 return ( _diff_trees( $x, $y, $mode ), 1 );
927 }
928  
929 0 ▶sub _work_tracked {
Subroutine _work_tracked: not called CC=2 SCAR=17.9
930 0 my ( $dev, $root, $r ) = @_;
931 0 my $w = _work( $dev, $root );
932 0 my $idx = _index($r);
933 0 ▶ return { map { exists $w->{$_} ? ( $_ => $w->{$_} ) : () } keys %$idx };
Branch: 1 branch
BranchTrueFalseTotal
exists $$w{$_} ? : 0 0 0
934 }
935  
936 0 ▶sub _g_ls_files {
Subroutine _g_ls_files: not called CC=1 SCAR=6.9
937 0 my ( $dev, $root, $r, $a ) = @_;
938 0 return ( join( "\n", sort keys %{ _index($r) } ), 1 );
939 }
940  
941 0 ▶sub _g_branch {
Subroutine _g_branch: not called CC=34 SCAR=70.8
942 0 my ( $dev, $root, $r, $a ) = @_;
943 0 my @p = grep { !/\A-/ } @$a;
944 0 ▶ if ( @p && !grep { /\A-[dDm]/ } @$a ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p and not grep({/\A-[dDm]/;} @$a)) 0 0 0
Condition0%0/3
@p and not grep({/\A-[dDm]/;} @$a)
!ll&&!rl&&r
000
MC/DC0%0/2
@p and not grep({/\A-[dDm]/;} @$a)
@p not grep({/\A-[dDm]/;} @$a)
Truth table0%0/3
A and not(B)
A= @pB= not grep({/\A-[dDm]/;} @$a)
ABresult
0X0
100
111
945 0 ▶ my $id = _rev( $r, $p[1] // 'HEAD' ) // return ( "fatal: not a valid object name: '$p[1]'", 0 );
Condition0%0/4
_rev($r, $p[1] // "HEAD") // (return "fatal: not a valid object name: '$p[1]'", 0)
l!l
00
$p[1] // "HEAD"
l!l
00
MC/DC0%0/1
_rev($r, $p[1] // "HEAD") // (return "fatal: not a valid object name: '$p[1]'", 0)
_rev($r, $p[1] // "HEAD")
MC/DC0%0/1
$p[1] // "HEAD"
$p[1]
Truth table0%0/2
A
A= _rev($r, $p[1] // "HEAD")
Aresult
11
00
Truth table0%0/2
A
A= $p[1]
Aresult
11
00
946 0 ▶ my $force = grep { $_ eq '-f' || $_ eq '--force' } @$a;
Condition0%0/3
$_ eq '-f' || $_ eq '--force'
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq '-f' || $_ eq '--force'
$_ eq '-f' $_ eq '--force'
Truth table0%0/3
A || B
A= $_ eq '-f'B= $_ eq '--force'
ABresult
1X1
011
000
947 0 ▶ return ( "fatal: a branch named '$p[0]' already exists", 0 ) if exists $r->{refs}{heads}{ $p[0] } && !$force;
Branch: 1 branch
BranchTrueFalseTotal
if exists $$r{"refs"}{"heads"}{$p[0]} and not $force 0 0 0
Condition0%0/3
exists $$r{"refs"}{"heads"}{$p[0]} and not $force
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$r{"refs"}{"heads"}{$p[0]} and not $force
exists $$r{"refs"}{"heads"}{$p[0]} not $force
Truth table0%0/3
A and not(B)
A= exists $$r{"refs"}{"heads"}{$p[0]}B= not $force
ABresult
0X0
100
111
948 0 ▶ return ( "fatal: cannot force update the branch '$p[0]' used by worktree at '$root'", 0 ) if $force && ( $r->{branch} // '' ) eq $p[0];
Branch: 1 branch
BranchTrueFalseTotal
if $force and ($$r{"branch"} // "") eq $p[0] 0 0 0
Condition0%0/5
$force and ($$r{"branch"} // "") eq $p[0]
!ll&&!rl&&r
000
$$r{"branch"} // ""
l!l
00
MC/DC0%0/2
$force and ($$r{"branch"} // "") eq $p[0]
$force $$r{"branch"}
Truth table0%0/3
A and B
A= $forceB= $$r{"branch"}
ABresult
0X0
100
111
949 0 $r->{refs}{heads}{ $p[0] } = $id;
950 0 return ( '', 1 );
951 }
952 0 ▶ if ( grep { /\A-[dD]\z/ } @$a ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/\A-[dD]\z/;} @$a) 0 0 0
953 0 ▶ my $n = $p[0] // '';
Condition0%0/2
$p[0] // ""
l!l
00
MC/DC0%0/1
$p[0] // ""
$p[0]
Truth table0%0/2
A
A= $p[0]
Aresult
11
00
954 0 ▶ return ( "error: branch '$n' not found.", 0 ) unless exists $r->{refs}{heads}{$n};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$r{"refs"}{"heads"}{$n} 0 0 0
955 0 ▶ return ( "error: Cannot delete branch '$n' checked out at '$root'", 0 ) if ( $r->{branch} // '' ) eq $n;
Branch: 1 branch
BranchTrueFalseTotal
if ($$r{"branch"} // "") eq $n 0 0 0
Condition0%0/2
$$r{"branch"} // ""
l!l
00
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
956 0 my $id = delete $r->{refs}{heads}{$n};
957 0 return ( "Deleted branch $n (was " . _short($id) . ').', 1 );
958 }
959 0 ▶ my $v = grep { /\A-vv?\z/ || $_ eq '--verbose' } @$a;
Condition0%0/3
/\A-vv?\z/ || $_ eq '--verbose'
l!l&&r!l&&!r
000
MC/DC0%0/2
/\A-vv?\z/ || $_ eq '--verbose'
/\A-vv?\z/ $_ eq '--verbose'
Truth table0%0/3
A || B
A= /\A-vv?\z/B= $_ eq '--verbose'
ABresult
1X1
011
000
960 0 my $vv = grep { $_ eq '-vv' } @$a;
961 0 my $w = 0;
962 0 ▶ for ( keys %{ $r->{refs}{heads} || {} } ) { $w = length if length > $w }
Branch: 1 branch
BranchTrueFalseTotal
if length $_ > $w 0 0 0
Condition0%0/2
$$r{'refs'}{'heads'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table0%0/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
963 my @l = map {
964 0 my $b = $_;
965 0 ▶ my $cur = ( $r->{branch} // '' ) eq $b;
Condition0%0/2
$$r{"branch"} // ""
l!l
00
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
966 0 my $id = $r->{refs}{heads}{$b};
967 0 my $up = '';
968 0 ▶ if ( $vv && exists( ( $r->{refs}{remotes} || {} )->{"origin/$b"} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vv and exists(($$r{"refs"}{"remotes"} || {})->{"origin/$b"})) 0 0 0
Condition0%0/5
$vv and exists(($$r{"refs"}{"remotes"} || {})->{"origin/$b"})
!ll&&!rl&&r
000
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/2
$vv and exists(($$r{"refs"}{"remotes"} || {})->{"origin/$b"})
$vv $$r{'refs'}{'remotes'}
Truth table0%0/3
A and B
A= $vvB= $$r{'refs'}{'remotes'}
ABresult
0X0
100
111
969 0 my $u = $r->{refs}{remotes}{"origin/$b"};
970 0 my $ah = () = _range( $r, $u, $id );
971 0 my $be = () = _range( $r, $id, $u );
972 0 ▶ $up = " [origin/$b" . ( $ah && $be ? ": ahead $ah, behind $be" : $ah ? ": ahead $ah" : $be ? ": behind $be" : '' ) . ']';
Branch: 3 branches
BranchTrueFalseTotal
$ah && $be ? : 0 0 0
$ah ? : 0 0 0
$be ? : 0 0 0
Condition0%0/3
$ah and $be
!ll&&!rl&&r
000
MC/DC0%0/2
$ah and $be
$ah $be
Truth table0%0/3
A and B
A= $ahB= $be
ABresult
0X0
100
111
973 }
974 0 ▶ ( $cur ? '* ' : ' ' ) . ( $v ? sprintf( "%-${w}s %s%s %s", $b, _short($id), $up, _subject( $r->{commits}{$id}{message} ) ) : $b );
Branch: 2 branches
BranchTrueFalseTotal
$cur ? : 0 0 0
$v ? : 0 0 0
975 0 ▶ } sort keys %{ $r->{refs}{heads} || {} };
Condition0%0/2
$$r{'refs'}{'heads'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
Truth table0%0/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
976 0 ▶ unshift @l, '* (HEAD detached at ' . _short( $r->{detached} ) . ')' unless defined $r->{branch};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$r{"branch"} 0 0 0
977 0 ▶ push @l, map {" remotes/$_"} sort keys %{ $r->{refs}{remotes} || {} } if grep { /\A-(?:a|r|-all|-remotes)\z/ } @$a;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/\A-(?:a|r|-all|-remotes)\z/;} @$a 0 0 0
Condition0%0/2
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
Truth table0%0/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
978 0 return ( join( "\n", @l ), 1 );
979 }
980  
981 # HEAD auf einen anderen Commit setzen und Index/Arbeitsbaum nachziehen (nur verfolgte Dateien)
982 0 ▶sub _move_head {
Subroutine _move_head: not called CC=5 SCAR=34.0
983 0 my ( $dev, $root, $r, $id, $mode ) = @_;
984 0 my $old = _tree( $r, _head($r) );
985 0 ▶ $r->{index} = _index($r) if $mode eq 'soft'; # der Index bleibt, wie er war
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "soft" 0 0 0
986 0 ▶ if ( defined $r->{branch} ) { $r->{refs}{heads}{ $r->{branch} } = $id } else { $r->{detached} = $id }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$r{'branch'}) { } 0 0 0
987 0 ▶ return if $mode eq 'soft';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "soft" 0 0 0
988 0 my $new = _tree( $r, $id );
989 0 delete $r->{index};
990 0 ▶ if ( $mode eq 'hard' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "hard") 0 0 0
991 0 my $w = _work( $dev, $root );
992 0 my %tracked = map { $_ => 1 } keys %$old;
993 0 _set_work( $dev, $root, { map { $_ => 1 } grep { $tracked{$_} } keys %$w }, _clone($new) );
994 }
995 0 return;
996 }
997  
998 17 ▶sub _dirty {
Subroutine _dirty: called CC=2 SCAR=7.0
999 17 my ( $dev, $root, $r ) = @_;
1000 17 my ( $st, $un ) = _changes( $dev, $root, $r );
1001 17 ▶ return @$st || @$un;
Condition66%2/3
@$st || @$un
l!l&&r!l&&!r
0314
MC/DC50%1/2
@$st || @$un
@$st @$un
Truth table66%2/3
A || B
A= @$stB= @$un
ABresult
1X1
011
000
1002 }
1003  
1004 2 ▶sub _g_checkout {
Subroutine _g_checkout: called CC=25 SCAR=53.6
1005 2 my ( $dev, $root, $r, $a ) = @_;
1006 2 my @x = @$a;
1007 2 ▶ if ( my ($i) = grep { $x[$_] eq '--' } 0 .. $#x ) { return _g_restore( $dev, $root, $r, [ @x[ $i + 1 .. $#x ] ] ) }
Branch: 1 branch
BranchTrueFalseTotal
if (my($i) = grep({$x[$_] eq "--";} 0 .. $#x)) 1 1 2
1008 1 ▶ my $create = grep { $_ eq '-b' || $_ eq '-c' || $_ eq '-B' } @x;
Condition66%4/6
$_ eq '-b' || $_ eq '-c' || $_ eq '-B'
l!l&&r!l&&!r
102
$_ eq "-b" or $_ eq "-c"
l!l&&r!l&&!r
102
MC/DC33%1/3
$_ eq '-b' || $_ eq '-c' || $_ eq '-B'
$_ eq "-b" $_ eq "-c" $_ eq '-B'
Truth table50%2/4
A or B || C
A= $_ eq "-b"B= $_ eq "-c"C= $_ eq '-B'
ABCresult
1XX1
01X1
0011
0000
1009 1 my @p = grep { !/\A-/ } @x;
1010 1 ▶ my $name = $p[0] // return ( 'error: switch `b\' requires a value', 0 );
Condition50%1/2
$p[0] // (return "error: switch `b' requires a value", 0)
l!l
10
MC/DC0%0/1
$p[0] // (return "error: switch `b' requires a value", 0)
$p[0]
Truth table50%1/2
A
A= $p[0]
Aresult
11
00
1011 1 ▶ if ($create) {
Branch: 1 branch
BranchTrueFalseTotal
if ($create) 1 0 1
1012 1 ▶ return ( "fatal: a branch named '$name' already exists", 0 ) if exists $r->{refs}{heads}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $$r{"refs"}{"heads"}{$name} 0 1 1
1013 1 ▶ my $id = _rev( $r, $p[1] // 'HEAD' ) // return ( "fatal: '$p[1]' is not a commit and a branch '$name' cannot be created from it", 0 );
Condition50%2/4
_rev($r, $p[1] // "HEAD") // (return "fatal: '$p[1]' is not a commit and a branch '${name}' cannot be created from it", 0)
l!l
10
$p[1] // "HEAD"
l!l
10
MC/DC0%0/1
_rev($r, $p[1] // "HEAD") // (return "fatal: '$p[1]' is not a commit and a branch '${name}' cannot be created from it", 0)
_rev($r, $p[1] // "HEAD")
MC/DC0%0/1
$p[1] // "HEAD"
$p[1]
Truth table50%1/2
A
A= _rev($r, $p[1] // "HEAD")
Aresult
11
00
Truth table50%1/2
A
A= $p[1]
Aresult
11
00
1014 1 my $dirty = _dirty( $dev, $root, $r );
1015 1 $r->{refs}{heads}{$name} = $id;
1016 1 my $old = _head($r);
1017 1 $r->{branch} = $name;
1018 1 delete $r->{detached};
1019 0 ▶ if ( $id ne ( $old // '' ) ) { return ( "error: Your local changes would be overwritten by checkout.", 0 ) if $dirty; _switch_tree( $dev, $root, $r, $old, $id ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($id ne ($old // "")) 0 1 1
if $dirty 0 0 0
Condition50%1/2
$old // ""
l!l
10
MC/DC0%0/1
$old // ""
$old
Truth table50%1/2
A
A= $old
Aresult
11
00
1020 1 return ( "Switched to a new branch '$name'", 1 );
1021 }
1022 0 ▶ if ( !exists $r->{refs}{heads}{$name} && exists( ( $r->{refs}{remotes} || {} )->{"origin/$name"} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $$r{"refs"}{"heads"}{$name} and exists(($$r{"refs"}{"remotes"} || {})->{"origin/$name"})) 0 0 0
Condition0%0/5
not exists $$r{"refs"}{"heads"}{$name} and exists(($$r{"refs"}{"remotes"} || {})->{"origin/$name"})
!ll&&!rl&&r
000
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/2
not exists $$r{"refs"}{"heads"}{$name} and exists(($$r{"refs"}{"remotes"} || {})->{"origin/$name"})
not exists $$r{"refs"}{"heads"}{$name} $$r{'refs'}{'remotes'}
Truth table0%0/3
not(A) and B
A= not exists $$r{"refs"}{"heads"}{$name}B= $$r{'refs'}{'remotes'}
ABresult
0X0
100
111
1023 0 my $old = _head($r);
1024 0 ▶ return ( "error: Your local changes to the following files would be overwritten by checkout.\nAborting", 0 ) if _dirty( $dev, $root, $r );
Branch: 1 branch
BranchTrueFalseTotal
if _dirty($dev, $root, $r) 0 0 0
1025 0 $r->{refs}{heads}{$name} = $r->{refs}{remotes}{"origin/$name"};
1026 0 $r->{branch} = $name;
1027 0 _switch_tree( $dev, $root, $r, $old, $r->{refs}{heads}{$name} );
1028 0 return ( "branch '$name' set up to track 'origin/$name'.\nSwitched to a new branch '$name'", 1 );
1029 }
1030 0 ▶ if ( exists $r->{refs}{heads}{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$r{"refs"}{"heads"}{$name}) 0 0 0
1031 0 ▶ return ( "Already on '$name'", 1 ) if ( $r->{branch} // '' ) eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if ($$r{"branch"} // "") eq $name 0 0 0
Condition0%0/2
$$r{"branch"} // ""
l!l
00
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
1032 0 my $old = _head($r);
1033 return ( "error: Your local changes to the following files would be overwritten by checkout.\nPlease commit your changes or stash them before you switch branches.\nAborting", 0 )
1034 0 ▶ if _dirty( $dev, $root, $r ) && ( $old // '' ) ne $r->{refs}{heads}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if _dirty($dev, $root, $r) and ($old // "") ne $$r{"refs"}{"heads"}{$name} 0 0 0
Condition0%0/5
_dirty($dev, $root, $r) and ($old // "") ne $$r{"refs"}{"heads"}{$name}
!ll&&!rl&&r
000
$old // ""
l!l
00
MC/DC0%0/2
_dirty($dev, $root, $r) and ($old // "") ne $$r{"refs"}{"heads"}{$name}
_dirty($dev, $root, $r) $old
Truth table0%0/3
A and B
A= _dirty($dev, $root, $r)B= $old
ABresult
0X0
100
111
1035 0 $r->{branch} = $name;
1036 0 delete $r->{detached};
1037 0 _switch_tree( $dev, $root, $r, $old, $r->{refs}{heads}{$name} );
1038 0 return ( "Switched to branch '$name'", 1 );
1039 }
1040 0 my $id = _rev( $r, $name );
1041 0 ▶ if ( defined $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id) 0 0 0
1042 0 ▶ return ( "error: Your local changes would be overwritten by checkout.\nAborting", 0 ) if _dirty( $dev, $root, $r );
Branch: 1 branch
BranchTrueFalseTotal
if _dirty($dev, $root, $r) 0 0 0
1043 0 my $old = _head($r);
1044 0 delete $r->{branch};
1045 0 $r->{detached} = $id;
1046 0 _switch_tree( $dev, $root, $r, $old, $id );
1047 0 return ( "Note: switching to '$name'.\n\nYou are in 'detached HEAD' state.\nHEAD is now at " . _short($id) . ' ' . _subject( $r->{commits}{$id}{message} ), 1 );
1048 }
1049 0 ▶ return _g_restore( $dev, $root, $r, \@p ) if grep { exists _work( $dev, $root )->{$_} } _paths( $root, $CWD, @p );
Branch: 1 branch
BranchTrueFalseTotal
if grep {exists _work($dev, $root)->{$_};} _paths($root, $Langertha::Holmgang::Sim::Linux::Git::CWD, @p) 0 0 0
1050 0 return ( "error: pathspec '$name' did not match any file(s) known to git", 0 );
1051 }
1052  
1053 0 ▶sub _g_switch {
Subroutine _g_switch: not called CC=3 SCAR=24.8
1054 0 my ( $dev, $root, $r, $a ) = @_;
1055 0 ▶ return _g_checkout( $dev, $root, $r, [ map { $_ eq '-c' || $_ eq '--create' ? '-b' : $_ } grep { $_ ne '--detach' } @$a ] );
Branch: 1 branch
BranchTrueFalseTotal
$_ eq '-c' || $_ eq '--create' ? : 0 0 0
Condition0%0/3
$_ eq "-c" or $_ eq "--create"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq "-c" or $_ eq "--create"
$_ eq "-c" $_ eq "--create"
Truth table0%0/3
A or B
A= $_ eq "-c"B= $_ eq "--create"
ABresult
1X1
011
000
1056 }
1057  
1058 7 ▶sub _switch_tree {
Subroutine _switch_tree: called CC=1 SCAR=0.0
1059 7 my ( $dev, $root, $r, $old, $new ) = @_;
1060 7 my $ot = _tree( $r, $old );
1061 7 my $nt = _tree( $r, $new );
1062 7 delete $r->{index};
1063 7 my $w = _work( $dev, $root );
1064 7 _set_work( $dev, $root, { map { $_ => 1 } grep { exists $ot->{$_} } keys %$w }, _clone($nt) );
1065 7 return;
1066 }
1067  
1068 0 ▶sub _g_reset {
Subroutine _g_reset: not called CC=9 SCAR=45.0
1069 0 my ( $dev, $root, $r, $a ) = @_;
1070 0 ▶ my ($mode) = map { /\A--(soft|mixed|hard)\z/ ? $1 : () } @$a;
Branch: 1 branch
BranchTrueFalseTotal
/\A--(soft|mixed|hard)\z/ ? : 0 0 0
1071 0 my @p = grep { !/\A-/ } @$a;
1072 0 ▶ if ( !$mode && @p && !defined _rev( $r, $p[0] ) ) { # reset pfad: aus dem Index nehmen
Branch: 1 branch
BranchTrueFalseTotal
if (not $mode and @p and not defined _rev($r, $p[0])) 0 0 0
Condition0%0/6
not $mode and @p and not defined _rev($r, $p[0])
!ll&&!rl&&r
000
not $mode and @p
!ll&&!rl&&r
000
MC/DC0%0/3
not $mode and @p and not defined _rev($r, $p[0])
not $mode @p not defined _rev($r, $p[0])
Truth table0%0/4
not(A) and B and not(C)
A= not $modeB= @pC= not defined _rev($r, $p[0])
ABCresult
0XX0
10X0
1100
1111
1073 0 return _g_restore( $dev, $root, $r, [ '--staged', @p ] );
1074 }
1075 0 ▶ $mode //= 'mixed';
Condition0%0/2
$mode //= "mixed"
l!l
00
MC/DC0%0/1
$mode //= "mixed"
$mode
Truth table0%0/2
A
A= $mode
Aresult
11
00
1076 0 ▶ my $id = _rev( $r, $p[0] // 'HEAD' ) // return ( "fatal: ambiguous argument '$p[0]': unknown revision or path not in the working tree.", 0 );
Condition0%0/4
_rev($r, $p[0] // "HEAD") // (return "fatal: ambiguous argument '$p[0]': unknown revision or path not in the working tree.", 0)
l!l
00
$p[0] // "HEAD"
l!l
00
MC/DC0%0/1
_rev($r, $p[0] // "HEAD") // (return "fatal: ambiguous argument '$p[0]': unknown revision or path not in the working tree.", 0)
_rev($r, $p[0] // "HEAD")
MC/DC0%0/1
$p[0] // "HEAD"
$p[0]
Truth table0%0/2
A
A= _rev($r, $p[0] // "HEAD")
Aresult
11
00
Truth table0%0/2
A
A= $p[0]
Aresult
11
00
1077 0 _move_head( $dev, $root, $r, $id, $mode );
1078 0 ▶ return ( $mode eq 'hard' ? 'HEAD is now at ' . _short($id) . ' ' . _subject( $r->{commits}{$id}{message} ) : '', 1 );
Branch: 1 branch
BranchTrueFalseTotal
$mode eq 'hard' ? : 0 0 0
1079 }
1080  
1081 3 ▶sub _g_tag {
Subroutine _g_tag: called CC=31 SCAR=50.4
1082 3 my ( $dev, $root, $r, $a ) = @_;
1083 3 my ( $ann, $msg, $del, $list, $force );
1084 3 my @p;
1085 3 my @x = @$a;
1086 3 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 9 3 12
1087 9 my $o = shift @x;
1088 9 ▶ if ( $o eq '-a' || $o eq '--annotate' ) { $ann = 1 }
Branch: 10 branches
BranchTrueFalseTotal
if ($o eq '-a' or $o eq '--annotate') { } 2 7 9
elsif ($o eq '-s') { } 0 7 7
elsif ($o eq '-m') { } 2 5 7
elsif ($o =~ /\A-m(.+)\z/s) { } 0 5 5
elsif ($o eq '-am') { } 0 5 5
elsif ($o eq '-d' or $o eq '--delete') { } 0 5 5
elsif ($o eq '-l' or $o eq '--list') { } 0 5 5
elsif ($o eq '-f' or $o eq '--force') { } 0 5 5
elsif ($o =~ /\A-n\d*\z/) { } 0 5 5
elsif ($o =~ /\A-/) { } 0 5 5
Condition66%2/3
$o eq "-a" or $o eq "--annotate"
l!l&&r!l&&!r
207
MC/DC50%1/2
$o eq "-a" or $o eq "--annotate"
$o eq "-a" $o eq "--annotate"
Truth table66%2/3
A or B
A= $o eq "-a"B= $o eq "--annotate"
ABresult
1X1
011
000
1089 0 elsif ( $o eq '-s' ) { $ann = 1 }
1090 2 elsif ( $o eq '-m' ) { $msg = shift @x; $ann = 1 }
1091 0 elsif ( $o =~ /\A-m(.+)\z/s ) { $msg = $1; $ann = 1 }
1092 0 elsif ( $o eq '-am' ) { $msg = shift @x; $ann = 1 }
1093 0 ▶ elsif ( $o eq '-d' || $o eq '--delete' ) { $del = 1 }
Condition33%1/3
$o eq "-d" or $o eq "--delete"
l!l&&r!l&&!r
005
MC/DC0%0/2
$o eq "-d" or $o eq "--delete"
$o eq "-d" $o eq "--delete"
Truth table33%1/3
A or B
A= $o eq "-d"B= $o eq "--delete"
ABresult
1X1
011
000
1094 0 ▶ elsif ( $o eq '-l' || $o eq '--list' ) { $list = 1 }
Condition33%1/3
$o eq "-l" or $o eq "--list"
l!l&&r!l&&!r
005
MC/DC0%0/2
$o eq "-l" or $o eq "--list"
$o eq "-l" $o eq "--list"
Truth table33%1/3
A or B
A= $o eq "-l"B= $o eq "--list"
ABresult
1X1
011
000
1095 0 ▶ elsif ( $o eq '-f' || $o eq '--force' ) { $force = 1 }
Condition33%1/3
$o eq "-f" or $o eq "--force"
l!l&&r!l&&!r
005
MC/DC0%0/2
$o eq "-f" or $o eq "--force"
$o eq "-f" $o eq "--force"
Truth table33%1/3
A or B
A= $o eq "-f"B= $o eq "--force"
ABresult
1X1
011
000
1096 0 elsif ( $o =~ /\A-n\d*\z/ ) { $list = 1 }
1097 0 elsif ( $o =~ /\A-/ ) { return ( "error: unknown option `" . ( $o =~ s/\A-+//r ) . "'", 0 ) }
1098 5 else { push @p, $o }
1099 }
1100 3 ▶ my $t = $r->{refs}{tags} ||= {};
Condition50%1/2
$$r{"refs"}{"tags"} ||= {}
l!l
30
MC/DC0%0/1
$$r{"refs"}{"tags"} ||= {}
$$r{"refs"}{"tags"}
Truth table50%1/2
A
A= $$r{"refs"}{"tags"}
Aresult
11
00
1101 3 ▶ if ( $del ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($del) 0 3 3
1102 0 my @out;
1103 0 ▶ for my $n (@p) { return ( "error: tag '$n' not found.", 0 ) unless $t->{$n}; push @out, "Deleted tag '$n' (was " . _short( $t->{$n}{commit} ) . ')'; delete $t->{$n} }
Branch: 1 branch
BranchTrueFalseTotal
unless $$t{$n} 0 0 0
1104 0 return ( join( "\n", @out ), 1 );
1105 }
1106 0 ▶ if ( $list || !@p ) { return ( join( "\n", grep { !@p || _glob_match( $p[0], $_ ) || $_ eq $p[0] } sort keys %$t ), 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($list or not @p) 0 3 3
Condition11%1/9
$list or not @p
l!l&&r!l&&!r
003
!@p || _glob_match($p[0], $_) || $_ eq $p[0]
l!l&&r!l&&!r
000
not @p or _glob_match($p[0], $_)
l!l&&r!l&&!r
000
MC/DC0%0/2
$list or not @p
$list not @p
MC/DC0%0/3
!@p || _glob_match($p[0], $_) || $_ eq $p[0]
not @p _glob_match($p[0], $_) $_ eq $p[0]
Truth table33%1/3
A or not(B)
A= $listB= not @p
ABresult
1X1
011
000
Truth table0%0/4
not(A) or B || C
A= not @pB= _glob_match($p[0], $_)C= $_ eq $p[0]
ABCresult
1XX1
01X1
0011
0000
1107 3 my ( $n, $rev ) = @p;
1108 3 ▶ return ( "fatal: tag '$n' already exists", 0 ) if $t->{$n} && !$force;
Branch: 1 branch
BranchTrueFalseTotal
if $$t{$n} and not $force 0 3 3
Condition33%1/3
$$t{$n} and not $force
!ll&&!rl&&r
300
MC/DC0%0/2
$$t{$n} and not $force
$$t{$n} not $force
Truth table33%1/3
A and not(B)
A= $$t{$n}B= not $force
ABresult
0X0
100
111
1109 3 ▶ my $id = _rev( $r, $rev // 'HEAD' ) // return ( "fatal: Failed to resolve '$rev' as a valid ref.", 0 );
Condition75%3/4
_rev($r, $rev // "HEAD") // (return "fatal: Failed to resolve '${rev}' as a valid ref.", 0)
l!l
30
$rev // "HEAD"
l!l
21
MC/DC0%0/1
_rev($r, $rev // "HEAD") // (return "fatal: Failed to resolve '${rev}' as a valid ref.", 0)
_rev($r, $rev // "HEAD")
MC/DC100%1/1
$rev // "HEAD"
$rev
Truth table50%1/2
A
A= _rev($r, $rev // "HEAD")
Aresult
11
00
Truth table100%2/2
A
A= $rev
Aresult
11
00
1110 0 ▶ if ( $ann && !defined $msg ) { push @GAPS, 'git tag -a (Editor)'; return ( "error: There was a problem with the editor 'editor'.", 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($ann and not defined $msg) 0 3 3
Condition66%2/3
$ann and not defined $msg
!ll&&!rl&&r
120
MC/DC0%0/2
$ann and not defined $msg
$ann not defined $msg
Truth table66%2/3
A and not(B)
A= $annB= not defined $msg
ABresult
0X0
100
111
1111 3 ▶ $t->{$n} = { commit => $id, ( $ann ? ( annotated => JSON::MaybeXS::true(), message => $msg, tagger => _who( $dev, $r ) ) : () ) };
Branch: 1 branch
BranchTrueFalseTotal
$ann ? : 2 1 3
1112 3 return ( '', 1 );
1113 }
1114  
1115 # --- Server -----------------------------------------------------------------------------
1116  
1117 23 ▶sub _server {
Subroutine _server: called CC=20 SCAR=37.7
1118 23 my ( $ctx, $r, $remote ) = @_;
1119 23 ▶ my $rm = ( $r->{remotes} || {} )->{ $remote // 'origin' } or return ( undef, "fatal: '" . ( $remote // 'origin' ) . "' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists." );
Branch: 1 branch
BranchTrueFalseTotal
my $rm = ($$r{"remotes"} || {})->{$remote // "origin"} or return undef, q[fatal: '] . ($remote // "origin") . "' does not appear to be a git repository\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists." 23 0 23
Condition50%3/6
$$r{'remotes'} || {}
l!l
230
$remote // "origin"
l!l
1112
$remote // "origin"
l!l
00
MC/DC0%0/1
$$r{'remotes'} || {}
$$r{'remotes'}
MC/DC100%1/1
$remote // "origin"
$remote
MC/DC0%0/1
$remote // "origin"
$remote
Truth table50%1/2
A
A= $$r{'remotes'}
Aresult
11
00
Truth table100%2/2
A
A= $remote
Aresult
11
00
Truth table0%0/2
A
A= $remote
Aresult
11
00
1120 23 ▶ my $srv = ( $ctx->{state} || {} )->{ $rm->{host} // '' };
Condition50%2/4
$$ctx{'state'} || {}
l!l
230
$$rm{"host"} // ""
l!l
230
MC/DC0%0/1
$$ctx{'state'} || {}
$$ctx{'state'}
MC/DC0%0/1
$$rm{"host"} // ""
$$rm{"host"}
Truth table50%1/2
A
A= $$ctx{'state'}
Aresult
11
00
Truth table50%1/2
A
A= $$rm{"host"}
Aresult
11
00
1121 23 ▶ my ($h) = ( $rm->{url} // '' ) =~ m{\A(?:https?://|ssh://)?(?:[^@/]+@)?([^:/]+)};
Condition50%1/2
$$rm{"url"} // ""
l!l
230
MC/DC0%0/1
$$rm{"url"} // ""
$$rm{"url"}
Truth table50%1/2
A
A= $$rm{"url"}
Aresult
11
00
1122 23 ▶ $srv //= _by_hosts_file( $ctx, $h );
Condition66%2/3
$srv //= _by_hosts_file($ctx, $h)
l!l&&r!l&&!r
2201
MC/DC50%1/2
$srv //= _by_hosts_file($ctx, $h)
$srv _by_hosts_file($ctx, $h)
Truth table66%2/3
A //= B
A= $srvB= _by_hosts_file($ctx, $h)
ABresult
1X1
011
000
1123 23 ▶ return ( undef, "ssh: Could not resolve hostname " . ( $h // '' ) . ": Name or service not known\nfatal: Could not read from remote repository." ) unless $srv;
Branch: 1 branch
BranchTrueFalseTotal
unless $srv 1 22 23
Condition50%1/2
$h // ""
l!l
10
MC/DC0%0/1
$h // ""
$h
Truth table50%1/2
A
A= $h
Aresult
11
00
1124 return ( undef, "ssh: connect to host $h port 22: Connection refused\nfatal: Could not read from remote repository." )
1125 22 ▶ if ( $srv->{services} || {} )->{ $rm->{service} // 'forgejo' } && !$srv->{services}{ $rm->{service} // 'forgejo' }{active};
Branch: 1 branch
BranchTrueFalseTotal
if ($$srv{"services"} || {})->{$$rm{"service"} // "forgejo"} and not $$srv{"services"}{$$rm{"service"} // "forgejo"}{"active"} 0 22 22
Condition44%4/9
($$srv{"services"} || {})->{$$rm{"service"} // "forgejo"} and not $$srv{"services"}{$$rm{"service"} // "forgejo"}{"active"}
!ll&&!rl&&r
0220
$$srv{'services'} || {}
l!l
220
$$rm{"service"} // "forgejo"
l!l
022
$$rm{"service"} // "forgejo"
l!l
022
MC/DC0%0/2
($$srv{"services"} || {})->{$$rm{"service"} // "forgejo"} and not $$srv{"services"}{$$rm{"service"} // "forgejo"}{"active"}
$$srv{'services'} not $$srv{"services"}{$$rm{"service"} // "forgejo"}{"active"}
MC/DC0%0/1
$$rm{"service"} // "forgejo"
$$rm{"service"}
MC/DC0%0/1
$$rm{"service"} // "forgejo"
$$rm{"service"}
Truth table33%1/3
A and not(B)
A= $$srv{'services'}B= not $$srv{"services"}{$$rm{"service"} // "forgejo"}{"active"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$rm{"service"}
Aresult
11
00
Truth table50%1/2
A
A= $$rm{"service"}
Aresult
11
00
1126 22 ▶ my $repo = ( ( $srv->{forgejo} || {} )->{repos} || {} )->{ $rm->{repo} // '' } or return ( undef, "fatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists." );
Branch: 1 branch
BranchTrueFalseTotal
my $repo = (($$srv{"forgejo"} || {})->{"repos"} || {})->{$$rm{"repo"} // ""} or return undef, "fatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists." 22 0 22
Condition50%3/6
($$srv{'forgejo'} || {})->{'repos'} || {}
l!l
220
$$srv{'forgejo'} || {}
l!l
220
$$rm{"repo"} // ""
l!l
220
MC/DC0%0/1
($$srv{'forgejo'} || {})->{'repos'} || {}
$$srv{'forgejo'}
MC/DC0%0/1
$$rm{"repo"} // ""
$$rm{"repo"}
Truth table50%1/2
A
A= $$srv{'forgejo'}
Aresult
11
00
Truth table50%1/2
A
A= $$rm{"repo"}
Aresult
11
00
1127 22 return ( $repo, undef, $rm, $srv );
1128 }
1129  
1130 # Name ueber /etc/hosts des aufrufenden Geraets -> Geraet mit dieser Adresse
1131 1 ▶sub _by_hosts_file {
Subroutine _by_hosts_file: called CC=16 SCAR=44.9
1132 1 my ( $ctx, $name ) = @_;
1133 1 ▶ return undef unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 1 1
1134 1 ▶ my $st = $ctx->{state} || {};
Condition50%1/2
$$ctx{'state'} || {}
l!l
10
MC/DC0%0/1
$$ctx{'state'} || {}
$$ctx{'state'}
Truth table50%1/2
A
A= $$ctx{'state'}
Aresult
11
00
1135 1 ▶ my $me = $st->{ $ctx->{host} // '' } or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $me = $$st{$$ctx{"host"} // ""} or return undef 1 0 1
Condition50%1/2
$$ctx{"host"} // ""
l!l
10
MC/DC0%0/1
$$ctx{"host"} // ""
$$ctx{"host"}
Truth table50%1/2
A
A= $$ctx{"host"}
Aresult
11
00
1136 1 ▶ my $hf = ( $me->{files} || {} )->{'/etc/hosts'};
Condition50%1/2
$$me{'files'} || {}
l!l
10
MC/DC0%0/1
$$me{'files'} || {}
$$me{'files'}
Truth table50%1/2
A
A= $$me{'files'}
Aresult
11
00
1137 1 ▶ $hf = $hf->{content} if ref $hf eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $hf eq "HASH" 0 1 1
1138 1 ▶ for my $l ( split /\n/, $hf // '' ) {
Condition50%1/2
$hf // ""
l!l
01
MC/DC0%0/1
$hf // ""
$hf
Truth table50%1/2
A
A= $hf
Aresult
11
00
1139 0 my ( $ip, @names ) = split ' ', $l =~ s/#.*//r;
1140 0 ▶ next unless defined $ip && grep { $_ eq $name } @names;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip and grep {$_ eq $name;} @names 0 0 0
Condition0%0/3
defined $ip and grep {$_ eq $name;} @names
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ip and grep {$_ eq $name;} @names
defined $ip grep {$_ eq $name;} @names
Truth table0%0/3
A and B
A= defined $ipB= grep {$_ eq $name;} @names
ABresult
0X0
100
111
1141 0 for my $d ( sort keys %$st ) {
1142 0 ▶ my $if = ( ref $st->{$d} eq 'HASH' ? $st->{$d}{interfaces} : undef ) || {};
Branch: 1 branch
BranchTrueFalseTotal
ref $$st{$d} eq 'HASH' ? : 0 0 0
Condition0%0/2
(ref $$st{$d} eq 'HASH' ? $$st{$d}{'interfaces'} : undef) || {}
l!l
00
MC/DC0%0/1
(ref $$st{$d} eq 'HASH' ? $$st{$d}{'interfaces'} : undef) || {}
(ref $$st{$d} eq 'HASH' ? $$st{$d}{'interfaces'} : undef)
Truth table0%0/2
A
A= (ref $$st{$d} eq 'HASH' ? $$st{$d}{'interfaces'} : undef)
Aresult
11
00
1143 0 ▶ return $st->{$d} if grep { ( $_ =~ s{/\d+\z}{}r ) eq $ip } map { @{ $_->{addr} || [] } } values %$if;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ =~ s[/\d+\z][]r eq $ip;} map({@{$$_{"addr"} or [];};} values %$if) 0 0 0
Condition0%0/2
$$_{'addr'} || []
l!l
00
MC/DC0%0/1
$$_{'addr'} || []
$$_{'addr'}
Truth table0%0/2
A
A= $$_{'addr'}
Aresult
11
00
1144 }
1145 }
1146 1 return undef;
1147 }
1148  
1149 # Commits des Servers in das lokale Repo uebernehmen
1150 8 ▶sub _import {
Subroutine _import: called CC=3 SCAR=11.1
1151 8 my ( $r, $srepo, $ids ) = @_;
1152 8 ▶ for my $id (@$ids) { $r->{commits}{$id} //= _clone( $srepo->{commits}{$id} ) }
Condition66%2/3
$$r{"commits"}{$id} //= _clone($$srepo{"commits"}{$id})
l!l&&r!l&&!r
1680
MC/DC0%0/2
$$r{"commits"}{$id} //= _clone($$srepo{"commits"}{$id})
$$r{"commits"}{$id} _clone($$srepo{"commits"}{$id})
Truth table66%2/3
A //= B
A= $$r{"commits"}{$id}B= _clone($$srepo{"commits"}{$id})
ABresult
1X1
011
000
1153 8 return;
1154 }
1155  
1156 12 ▶sub _g_fetch {
Subroutine _g_fetch: called CC=17 SCAR=34.9
1157 12 my ( $dev, $root, $r, $a, $ctx ) = @_;
1158 0 my ($remote) = grep { !/\A-/ } @$a;
1159 12 my ( $s, $err, $rm ) = _server( $ctx, $r, $remote );
1160 12 ▶ return ( $err, 0 ) unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 1 11 12
1161 11 my @out;
1162 11 ▶ for my $b ( sort keys %{ $s->{refs}{heads} || {} } ) {
Condition50%1/2
$$s{'refs'}{'heads'} || {}
l!l
110
MC/DC0%0/1
$$s{'refs'}{'heads'} || {}
$$s{'refs'}{'heads'}
Truth table50%1/2
A
A= $$s{'refs'}{'heads'}
Aresult
11
00
1163 11 my $tip = $s->{refs}{heads}{$b};
1164 11 ▶ my $old = ( $r->{refs}{remotes} || {} )->{ ( $remote // 'origin' ) . "/$b" };
Condition50%2/4
$$r{'refs'}{'remotes'} || {}
l!l
110
$remote // "origin"
l!l
011
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
MC/DC0%0/1
$remote // "origin"
$remote
Truth table50%1/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
Truth table50%1/2
A
A= $remote
Aresult
11
00
1165 11 ▶ next if defined $old && $old eq $tip;
Branch: 1 branch
BranchTrueFalseTotal
if defined $old and $old eq $tip 3 8 11
Condition66%2/3
defined $old and $old eq $tip
!ll&&!rl&&r
083
MC/DC50%1/2
defined $old and $old eq $tip
defined $old $old eq $tip
Truth table66%2/3
A and B
A= defined $oldB= $old eq $tip
ABresult
0X0
100
111
1166 8 _import( $r, $s, [ _range( $s, undef, $tip ) ] );
1167 8 ▶ $r->{refs}{remotes}{ ( $remote // 'origin' ) . "/$b" } = $tip;
Condition50%1/2
$remote // "origin"
l!l
08
MC/DC0%0/1
$remote // "origin"
$remote
Truth table50%1/2
A
A= $remote
Aresult
11
00
1168 8 ▶ push @out, defined $old ? sprintf( ' %s..%s %-10s -> %s/%s', _short($old), _short($tip), $b, $remote // 'origin', $b ) : sprintf( ' * [new branch] %-10s -> %s/%s', $b, $remote // 'origin', $b );
Branch: 1 branch
BranchTrueFalseTotal
defined $old ? : 8 0 8
Condition25%1/4
$remote // "origin"
l!l
08
$remote // "origin"
l!l
00
MC/DC0%0/1
$remote // "origin"
$remote
MC/DC0%0/1
$remote // "origin"
$remote
Truth table50%1/2
A
A= $remote
Aresult
11
00
Truth table0%0/2
A
A= $remote
Aresult
11
00
1169 }
1170 11 ▶ for my $tg ( sort keys %{ $s->{refs}{tags} || {} } ) {
Condition50%1/2
$$s{'refs'}{'tags'} || {}
l!l
110
MC/DC0%0/1
$$s{'refs'}{'tags'} || {}
$$s{'refs'}{'tags'}
Truth table50%1/2
A
A= $$s{'refs'}{'tags'}
Aresult
11
00
1171 0 ▶ next if ( $r->{refs}{tags} || {} )->{$tg};
Branch: 1 branch
BranchTrueFalseTotal
if ($$r{"refs"}{"tags"} || {})->{$tg} 0 0 0
Condition0%0/2
$$r{'refs'}{'tags'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table0%0/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
1172 0 _import( $r, $s, [ _range( $s, undef, $s->{refs}{tags}{$tg}{commit} ) ] );
1173 0 $r->{refs}{tags}{$tg} = _clone( $s->{refs}{tags}{$tg} );
1174 0 push @out, " * [new tag] $tg -> $tg";
1175 }
1176 11 ▶ return ( @out ? join( "\n", "From $rm->{url}", @out ) : '', 1 );
Branch: 1 branch
BranchTrueFalseTotal
@out ? : 8 3 11
1177 }
1178  
1179 # Commits $ids (aelteste zuerst) auf $onto neu aufsetzen; Konflikt -> undef
1180 1 ▶sub _replay {
Subroutine _replay: called CC=14 SCAR=31.1
1181 1 my ( $dev, $r, $ids, $onto ) = @_;
1182 1 my $tip = $onto;
1183 1 for my $id (@$ids) {
1184 1 my $c = $r->{commits}{$id};
1185 1 ▶ my $base = _tree( $r, ( $c->{parents} || [] )->[0] );
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
1186 1 my $tree = _clone( _tree( $r, $tip ) );
1187 1 for my $p ( keys %{ { %$base, %{ $c->{tree} } } } ) {
1188 4 my ( $b, $n, $t ) = ( $base->{$p}, $c->{tree}{$p}, $tree->{$p} );
1189 4 ▶ next if ( $b // "\0" ) eq ( $n // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($b // "\0") eq ($n // "\0") 3 1 4
Condition50%2/4
$b // "\0"
l!l
40
$n // "\0"
l!l
40
MC/DC0%0/1
$b // "\0"
$b
MC/DC0%0/1
$n // "\0"
$n
Truth table50%1/2
A
A= $b
Aresult
11
00
Truth table50%1/2
A
A= $n
Aresult
11
00
1190 1 ▶ return ( undef, $p ) if ( $t // "\0" ) ne ( $b // "\0" ) && ( $t // "\0" ) ne ( $n // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($t // "\0") ne ($b // "\0") and ($t // "\0") ne ($n // "\0") 0 1 1
Condition27%3/11
($t // "\0") ne ($b // "\0") and ($t // "\0") ne ($n // "\0")
!ll&&!rl&&r
100
$t // "\0"
l!l
10
$b // "\0"
l!l
10
$t // "\0"
l!l
00
$n // "\0"
l!l
00
MC/DC0%0/2
($t // "\0") ne ($b // "\0") and ($t // "\0") ne ($n // "\0")
$t $t
MC/DC0%0/1
$b // "\0"
$b
MC/DC0%0/1
$n // "\0"
$n
Truth table0%0/3
A and B
A= $tB= $t
ABresult
0X0
100
111
Truth table50%1/2
A
A= $b
Aresult
11
00
Truth table0%0/2
A
A= $n
Aresult
11
00
1191 0 ▶ if ( defined $n ) { $tree->{$p} = $n } else { delete $tree->{$p} }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $n) { } 1 0 1
1192 }
1193 1 $tip = _mk_commit( $dev, $r, parents => [$tip], message => $c->{message}, author => $c->{author}, date => $c->{date} + 1, tree => $tree );
1194 }
1195 1 return ($tip);
1196 }
1197  
1198 0 ▶sub _merge_trees {
Subroutine _merge_trees: not called CC=12 SCAR=50.5
1199 0 my ( $r, $base, $x, $y ) = @_;
1200 0 my ( $bt, $xt, $yt ) = map { _tree( $r, $_ ) } $base, $x, $y;
1201 0 my %t = %$xt;
1202 0 for my $p ( keys %{ { %$bt, %$xt, %$yt } } ) {
1203 0 my ( $b, $m, $o ) = ( $bt->{$p}, $xt->{$p}, $yt->{$p} );
1204 0 ▶ next if ( $o // "\0" ) eq ( $b // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($o // "\0") eq ($b // "\0") 0 0 0
Condition0%0/4
$o // "\0"
l!l
00
$b // "\0"
l!l
00
MC/DC0%0/1
$o // "\0"
$o
MC/DC0%0/1
$b // "\0"
$b
Truth table0%0/2
A
A= $o
Aresult
11
00
Truth table0%0/2
A
A= $b
Aresult
11
00
1205 0 ▶ next if ( $m // "\0" ) eq ( $o // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($m // "\0") eq ($o // "\0") 0 0 0
Condition0%0/4
$m // "\0"
l!l
00
$o // "\0"
l!l
00
MC/DC0%0/1
$m // "\0"
$m
MC/DC0%0/1
$o // "\0"
$o
Truth table0%0/2
A
A= $m
Aresult
11
00
Truth table0%0/2
A
A= $o
Aresult
11
00
1206 0 ▶ return ( undef, $p ) if ( $m // "\0" ) ne ( $b // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($m // "\0") ne ($b // "\0") 0 0 0
Condition0%0/4
$m // "\0"
l!l
00
$b // "\0"
l!l
00
MC/DC0%0/1
$m // "\0"
$m
MC/DC0%0/1
$b // "\0"
$b
Truth table0%0/2
A
A= $m
Aresult
11
00
Truth table0%0/2
A
A= $b
Aresult
11
00
1207 0 ▶ if ( defined $o ) { $t{$p} = $o } else { delete $t{$p} }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o) { } 0 0 0
1208 }
1209 0 return ( \%t );
1210 }
1211  
1212 2 ▶sub _base {
Subroutine _base: called CC=1 SCAR=0.0
1213 2 my ( $r, $x, $y ) = @_;
1214 2 my $ax = _ancestors( $r, $x );
1215 2 my ($b) = grep { $ax->{$_} } map { $_ } reverse _range( $r, undef, $y );
1216 2 return $b;
1217 }
1218  
1219 7 ▶sub _integrate {
Subroutine _integrate: called CC=20 SCAR=40.2
1220 7 my ( $dev, $root, $r, $up, $how ) = @_;
1221 7 my $h = _head($r);
1222 7 ▶ my $name = $r->{branch} // 'HEAD';
Condition50%1/2
$$r{"branch"} // "HEAD"
l!l
70
MC/DC0%0/1
$$r{"branch"} // "HEAD"
$$r{"branch"}
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
1223 7 ▶ return ( 'Already up to date.', 1 ) if _ancestors( $r, $h )->{$up};
Branch: 1 branch
BranchTrueFalseTotal
if _ancestors($r, $h)->{$up} 0 7 7
1224 7 ▶ return ( "error: cannot pull with rebase: You have unstaged changes.\nerror: please commit or stash them.", 0 ) if $how eq 'rebase' && _dirty( $dev, $root, $r );
Branch: 1 branch
BranchTrueFalseTotal
if $how eq "rebase" and _dirty($dev, $root, $r) 1 6 7
Condition66%2/3
$how eq "rebase" and _dirty($dev, $root, $r)
!ll&&!rl&&r
061
MC/DC50%1/2
$how eq "rebase" and _dirty($dev, $root, $r)
$how eq "rebase" _dirty($dev, $root, $r)
Truth table66%2/3
A and B
A= $how eq "rebase"B= _dirty($dev, $root, $r)
ABresult
0X0
100
111
1225 6 ▶ if ( !defined $h || _ancestors( $r, $up )->{$h} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $h or _ancestors($r, $up)->{$h}) 5 1 6
Condition66%2/3
not defined $h or _ancestors($r, $up)->{$h}
l!l&&r!l&&!r
051
MC/DC50%1/2
not defined $h or _ancestors($r, $up)->{$h}
not defined $h _ancestors($r, $up)->{$h}
Truth table66%2/3
not(A) or B
A= not defined $hB= _ancestors($r, $up)->{$h}
ABresult
1X1
011
000
1226 5 ▶ return ( 'error: Your local changes to the following files would be overwritten by merge.', 0 ) if _dirty( $dev, $root, $r );
Branch: 1 branch
BranchTrueFalseTotal
if _dirty($dev, $root, $r) 0 5 5
1227 5 _switch_tree( $dev, $root, $r, $h, $up );
1228 5 ▶ $r->{refs}{heads}{ $r->{branch} } = $up if defined $r->{branch};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$r{"branch"} 5 0 5
1229 5 return ( 'Updating ' . _short($h) . '..' . _short($up) . "\nFast-forward", 1 );
1230 }
1231 1 ▶ return ( "hint: Diverging branches can't be fast-forwarded, you need to either:\nhint:\nhint: \tgit merge --no-ff\nhint:\nhint: or:\nhint:\nhint: \tgit rebase\nhint:\nhint: Disable this message with \"git config advice.diverging false\"\nfatal: Not possible to fast-forward, aborting.", 0 )
Branch: 1 branch
BranchTrueFalseTotal
if $how eq "ff-only" 0 1 1
1232 if $how eq 'ff-only';
1233 1 my $base = _base( $r, $h, $up );
1234 1 ▶ if ( $how eq 'rebase' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($how eq "rebase") 1 0 1
1235 1 my @mine = _range( $r, $base, $h );
1236 1 my ( $tip, $conf ) = _replay( $dev, $r, \@mine, $up );
1237 1 ▶ return ( "CONFLICT (content): Merge conflict in $conf\nerror: could not apply " . _short( $mine[0] ) . "...\nhint: Resolve all conflicts manually, mark them as resolved with\nhint: \"git add/rm <conflicted_files>\", then run \"git rebase --continue\".", 0 ) unless $tip;
Branch: 1 branch
BranchTrueFalseTotal
unless $tip 0 1 1
1238 1 _switch_tree( $dev, $root, $r, $h, $tip );
1239 1 ▶ $r->{refs}{heads}{ $r->{branch} } = $tip if defined $r->{branch};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$r{"branch"} 1 0 1
1240 1 ▶ $r->{detached} = $tip unless defined $r->{branch};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$r{"branch"} 0 1 1
1241 1 return ( "Successfully rebased and updated refs/heads/$name.", 1 );
1242 }
1243 0 ▶ return ( "error: Your local changes to the following files would be overwritten by merge.", 0 ) if _dirty( $dev, $root, $r );
Branch: 1 branch
BranchTrueFalseTotal
if _dirty($dev, $root, $r) 0 0 0
1244 0 my ( $tree, $conf ) = _merge_trees( $r, $base, $h, $up );
1245 0 ▶ return ( "Auto-merging $conf\nCONFLICT (content): Merge conflict in $conf\nAutomatic merge failed; fix conflicts and then commit the result.", 0 ) unless $tree;
Branch: 1 branch
BranchTrueFalseTotal
unless $tree 0 0 0
1246 0 ▶ my $id = _mk_commit( $dev, $r, parents => [ $h, $up ], message => $how eq 'pull' ? "Merge branch '$name' of " . ( ( $r->{remotes}{origin} || {} )->{url} // 'origin' ) : "Merge remote-tracking branch '$how'", author => _who( $dev, $r ), tree => $tree );
Branch: 1 branch
BranchTrueFalseTotal
$how eq 'pull' ? : 0 0 0
Condition0%0/4
($$r{"remotes"}{"origin"} || {})->{"url"} // "origin"
l!l
00
$$r{'remotes'}{'origin'} || {}
l!l
00
MC/DC0%0/1
($$r{"remotes"}{"origin"} || {})->{"url"} // "origin"
$$r{'remotes'}{'origin'}
Truth table0%0/2
A
A= $$r{'remotes'}{'origin'}
Aresult
11
00
1247 0 _switch_tree( $dev, $root, $r, $h, $id );
1248 0 ▶ $r->{refs}{heads}{ $r->{branch} } = $id if defined $r->{branch};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$r{"branch"} 0 0 0
1249 0 return ( "Merge made by the 'ort' strategy.", 1 );
1250 }
1251  
1252 8 ▶sub _g_pull {
Subroutine _g_pull: called CC=25 SCAR=40.5
1253 8 my ( $dev, $root, $r, $a, $ctx ) = @_;
1254 0 ▶ my $how = ( grep { $_ eq '--rebase' || $_ eq '-r' } @$a ) ? 'rebase' : ( grep { $_ eq '--ff-only' } @$a ) ? 'ff-only' : ( grep { $_ eq '--no-rebase' || $_ eq '--no-ff' } @$a ) ? 'pull' : undef;
Branch: 3 branches
BranchTrueFalseTotal
grep({$_ eq '--rebase' or $_ eq '-r';} @$a) ? : 7 1 8
grep({$_ eq '--ff-only';} @$a) ? : 0 1 1
grep({$_ eq '--no-rebase' or $_ eq '--no-ff';} @$a) ? : 0 1 1
Condition33%2/6
$_ eq '--rebase' || $_ eq '-r'
l!l&&r!l&&!r
701
$_ eq '--no-rebase' || $_ eq '--no-ff'
l!l&&r!l&&!r
000
MC/DC50%1/2
$_ eq '--rebase' || $_ eq '-r'
$_ eq '--rebase' $_ eq '-r'
MC/DC0%0/2
$_ eq '--no-rebase' || $_ eq '--no-ff'
$_ eq '--no-rebase' $_ eq '--no-ff'
Truth table66%2/3
A || B
A= $_ eq '--rebase'B= $_ eq '-r'
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $_ eq '--no-rebase'B= $_ eq '--no-ff'
ABresult
1X1
011
000
1255 8 ▶ my %cfg = ( %{ ( $dev->{git} || {} )->{config} || {} }, %{ $r->{config} || {} } );
Condition66%4/6
($$dev{'git'} || {})->{'config'} || {}
l!l
80
$$dev{'git'} || {}
l!l
80
$$r{'config'} || {}
l!l
17
MC/DC0%0/1
($$dev{'git'} || {})->{'config'} || {}
$$dev{'git'}
MC/DC100%1/1
$$r{'config'} || {}
$$r{'config'}
Truth table50%1/2
A
A= $$dev{'git'}
Aresult
11
00
Truth table100%2/2
A
A= $$r{'config'}
Aresult
11
00
1256 8 ▶ $how //= ( $cfg{'pull.rebase'} // '' ) =~ /\A(?:true|merges)\z/ ? 'rebase' : ( $cfg{'pull.ff'} // '' ) eq 'only' ? 'ff-only' : ( $cfg{'pull.rebase'} // '' ) eq 'false' ? 'pull' : undef;
Branch: 3 branches
BranchTrueFalseTotal
($cfg{'pull.rebase'} // '') =~ /\A(?:true|merges)\z/ ? : 0 1 1
($cfg{'pull.ff'} // '') eq 'only' ? : 0 1 1
($cfg{'pull.rebase'} // '') eq 'false' ? : 0 1 1
Condition62%5/8
$how //= ($cfg{"pull.rebase"} // "") =~ /\A(?:true|merges)\z/ ? "rebase" : (($cfg{"pull.ff"} // "") eq "only" ? "ff-only" : (($cfg{"pull.rebase"} // "") eq "false" ? "pull" : undef))
l!l
71
$cfg{"pull.rebase"} // ""
l!l
01
$cfg{"pull.ff"} // ""
l!l
01
$cfg{"pull.rebase"} // ""
l!l
01
MC/DC100%1/1
$how //= ($cfg{"pull.rebase"} // "") =~ /\A(?:true|merges)\z/ ? "rebase" : (($cfg{"pull.ff"} // "") eq "only" ? "ff-only" : (($cfg{"pull.rebase"} // "") eq "false" ? "pull" : undef))
$how
MC/DC0%0/1
$cfg{"pull.ff"} // ""
$cfg{"pull.ff"}
Truth table100%2/2
A
A= $how
Aresult
11
00
Truth table50%1/2
A
A= $cfg{"pull.ff"}
Aresult
11
00
1257 8 my ( $fo, $fok ) = _g_fetch( $dev, $root, $r, [ grep { !/\A-/ } @$a ], $ctx );
1258 8 ▶ return ( $fo, 0 ) unless $fok;
Branch: 1 branch
BranchTrueFalseTotal
unless $fok 0 8 8
1259 8 ▶ my $up = ( $r->{refs}{remotes} || {} )->{ 'origin/' . ( $r->{branch} // '' ) } // return ( "There is no tracking information for the current branch.", 0 );
Condition50%3/6
($$r{"refs"}{"remotes"} || {})->{'origin/' . ($$r{"branch"} // "")} // (return "There is no tracking information for the current branch.", 0)
l!l
80
$$r{'refs'}{'remotes'} || {}
l!l
80
$$r{"branch"} // ""
l!l
80
MC/DC0%0/1
($$r{"refs"}{"remotes"} || {})->{'origin/' . ($$r{"branch"} // "")} // (return "There is no tracking information for the current branch.", 0)
$$r{'refs'}{'remotes'}
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
Truth table50%1/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
1260 8 my $h = _head($r);
1261 8 ▶ if ( !defined $how ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $how) 1 7 8
1262 2 return ( join( "\n", grep {length} $fo, "hint: You have divergent branches and need to specify how to reconcile them.\nhint: You can do so by running one of the following commands sometime before\nhint: your next pull:\nhint:\nhint: git config pull.rebase false # merge\nhint: git config pull.rebase true # rebase\nhint: git config pull.ff only # fast-forward only\nhint:\nhint: You can replace \"git config\" with \"git config --global\" to set a default\nhint: preference for all repositories. You can also pass --rebase, --no-rebase,\nhint: or --ff-only on the command line to override the configured default per\nhint: invocation.\nfatal: Need to specify how to reconcile divergent branches." ), 0, 1 )
1263 1 ▶ if !_ancestors( $r, $up )->{$h} && !_ancestors( $r, $h )->{$up};
Branch: 1 branch
BranchTrueFalseTotal
unless _ancestors($r, $up)->{$h} or _ancestors($r, $h)->{$up} 1 0 1
Condition33%1/3
_ancestors($r, $up)->{$h} or _ancestors($r, $h)->{$up}
l!l&&r!l&&!r
001
MC/DC0%0/2
_ancestors($r, $up)->{$h} or _ancestors($r, $h)->{$up}
_ancestors($r, $up)->{$h} _ancestors($r, $h)->{$up}
Truth table33%1/3
A or B
A= _ancestors($r, $up)->{$h}B= _ancestors($r, $h)->{$up}
ABresult
1X1
011
000
1264 0 $how = 'pull';
1265 }
1266 0 my ( $o, $ok ) = $how eq 'rebase' || grep( { $_ eq '--autostash' } @$a )
1267 7 ▶ ? _autostash( $dev, $root, $r, $a, sub { _integrate( $dev, $root, $r, $up, $how ) } )
Subroutine __ANON__: called CC=1 SCAR=0.0
1268 7 ▶ : _integrate( $dev, $root, $r, $up, $how );
Branch: 1 branch
BranchTrueFalseTotal
$how eq 'rebase' || grep({$_ eq '--autostash';} @$a) ? : 7 0 7
Condition33%1/3
$how eq "rebase" or grep {$_ eq "--autostash";} @$a
l!l&&r!l&&!r
700
MC/DC0%0/2
$how eq "rebase" or grep {$_ eq "--autostash";} @$a
$how eq "rebase" grep {$_ eq "--autostash";} @$a
Truth table33%1/3
A or B
A= $how eq "rebase"B= grep {$_ eq "--autostash";} @$a
ABresult
1X1
011
000
1269 7 return ( join( "\n", grep {length} $fo, $o ), $ok, 1 );
1270 }
1271  
1272 0 ▶sub _g_rebase {
Subroutine _g_rebase: not called CC=8 SCAR=42.8
1273 0 my ( $dev, $root, $r, $a ) = @_;
1274 0 ▶ if ( grep { /\A(?:-i|--interactive)\z/ } @$a ) { push @GAPS, 'git rebase -i'; return ( 'error: There was a problem with the editor \'editor\'.', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/\A(?:-i|--interactive)\z/;} @$a) 0 0 0
1275 0 ▶ return ( 'fatal: No rebase in progress?', 0 ) if grep { /\A--(?:abort|continue|skip)\z/ } @$a;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/\A--(?:abort|continue|skip)\z/;} @$a 0 0 0
1276 0 my ($onto) = grep { !/\A-/ } @$a;
1277 0 ▶ $onto //= 'origin/' . ( $r->{branch} // '' );
Condition0%0/4
$onto //= 'origin/' . ($$r{"branch"} // "")
l!l
00
$$r{"branch"} // ""
l!l
00
MC/DC0%0/1
$onto //= 'origin/' . ($$r{"branch"} // "")
$onto
MC/DC0%0/1
$$r{"branch"} // ""
$$r{"branch"}
Truth table0%0/2
A
A= $onto
Aresult
11
00
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
1278 0 ▶ my $up = _rev( $r, $onto ) // return ( "fatal: invalid upstream '$onto'", 0 );
Condition0%0/2
_rev($r, $onto) // (return "fatal: invalid upstream '${onto}'", 0)
l!l
00
MC/DC0%0/1
_rev($r, $onto) // (return "fatal: invalid upstream '${onto}'", 0)
_rev($r, $onto)
Truth table0%0/2
A
A= _rev($r, $onto)
Aresult
11
00
1279 0 ▶ return ( 'Current branch ' . ( $r->{branch} // 'HEAD' ) . ' is up to date.', 1 ) if _ancestors( $r, _head($r) )->{$up};
Branch: 1 branch
BranchTrueFalseTotal
if _ancestors($r, _head($r))->{$up} 0 0 0
Condition0%0/2
$$r{"branch"} // "HEAD"
l!l
00
MC/DC0%0/1
$$r{"branch"} // "HEAD"
$$r{"branch"}
Truth table0%0/2
A
A= $$r{"branch"}
Aresult
11
00
1280 0 ▶ return _autostash( $dev, $root, $r, $a, sub { _integrate( $dev, $root, $r, $up, 'rebase' ) } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
1281 }
1282  
1283 0 ▶sub _g_merge {
Subroutine _g_merge: not called CC=4 SCAR=30.0
1284 0 my ( $dev, $root, $r, $a ) = @_;
1285 0 my ($what) = grep { !/\A-/ } @$a;
1286 0 ▶ return ( 'fatal: No remote for the current branch.', 0 ) unless defined $what;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $what 0 0 0
1287 0 ▶ my $up = _rev( $r, $what ) // return ( "merge: $what - not something we can merge", 0 );
Condition0%0/2
_rev($r, $what) // (return "merge: $what - not something we can merge", 0)
l!l
00
MC/DC0%0/1
_rev($r, $what) // (return "merge: $what - not something we can merge", 0)
_rev($r, $what)
Truth table0%0/2
A
A= _rev($r, $what)
Aresult
11
00
1288 0 ▶ return _integrate( $dev, $root, $r, $up, ( grep { $_ eq '--ff-only' } @$a ) ? 'ff-only' : $what );
Branch: 1 branch
BranchTrueFalseTotal
grep({$_ eq '--ff-only';} @$a) ? : 0 0 0
1289 }
1290  
1291 1 ▶sub _g_cherry_pick {
Subroutine _g_cherry_pick: called CC=33 SCAR=46.5
1292 1 my ( $dev, $root, $r, $a ) = @_;
1293 1 my $x = grep { $_ eq '-x' } @$a;
1294 1 ▶ my $nocommit = grep { $_ eq '-n' || $_ eq '--no-commit' } @$a;
Condition33%1/3
$_ eq '-n' || $_ eq '--no-commit'
l!l&&r!l&&!r
002
MC/DC0%0/2
$_ eq '-n' || $_ eq '--no-commit'
$_ eq '-n' $_ eq '--no-commit'
Truth table33%1/3
A || B
A= $_ eq '-n'B= $_ eq '--no-commit'
ABresult
1X1
011
000
1295 1 ▶ return ( 'error: no cherry-pick or revert in progress', 0 ) if grep { /\A--(?:abort|continue|skip|quit)\z/ } @$a;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/\A--(?:abort|continue|skip|quit)\z/;} @$a 0 1 1
1296 0 ▶ if ( grep { $_ eq '-e' || $_ eq '--edit' } @$a ) { push @GAPS, 'git cherry-pick --edit'; return ( "error: There was a problem with the editor 'editor'.", 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "-e" or $_ eq "--edit";} @$a) 0 1 1
Condition33%1/3
$_ eq '-e' || $_ eq '--edit'
l!l&&r!l&&!r
002
MC/DC0%0/2
$_ eq '-e' || $_ eq '--edit'
$_ eq '-e' $_ eq '--edit'
Truth table33%1/3
A || B
A= $_ eq '-e'B= $_ eq '--edit'
ABresult
1X1
011
000
1297 1 my @specs = grep { !/\A-/ } @$a;
1298 1 ▶ return ( 'usage: git cherry-pick [--edit] [-n] [-m <parent-number>] [-s] [-x] [--ff] <commit>...', 0 ) unless @specs;
Branch: 1 branch
BranchTrueFalseTotal
unless @specs 0 1 1
1299 1 ▶ return ( "error: your local changes would be overwritten by cherry-pick.\nhint: commit your changes or stash them to proceed.\nfatal: cherry-pick failed", 0 ) if _dirty( $dev, $root, $r ) && !$nocommit;
Branch: 1 branch
BranchTrueFalseTotal
if _dirty($dev, $root, $r) and not $nocommit 0 1 1
Condition33%1/3
_dirty($dev, $root, $r) and not $nocommit
!ll&&!rl&&r
100
MC/DC0%0/2
_dirty($dev, $root, $r) and not $nocommit
_dirty($dev, $root, $r) not $nocommit
Truth table33%1/3
A and not(B)
A= _dirty($dev, $root, $r)B= not $nocommit
ABresult
0X0
100
111
1300 1 my @ids;
1301 1 for my $sp (@specs) {
1302 1 ▶ if ( $sp =~ /\A(.+?)\.\.(.+)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sp =~ /\A(.+?)\.\.(.+)\z/) 0 1 1
1303 0 my ( $f, $t ) = ( _rev( $r, $1 ), _rev( $r, $2 ) );
1304 0 ▶ return ( "fatal: bad revision '$sp'", 0 ) unless defined $f && defined $t;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $f and defined $t 0 0 0
Condition0%0/3
defined $f and defined $t
!ll&&!rl&&r
000
MC/DC0%0/2
defined $f and defined $t
defined $f defined $t
Truth table0%0/3
A and B
A= defined $fB= defined $t
ABresult
0X0
100
111
1305 0 push @ids, _range( $r, $f, $t );
1306 0 next;
1307 }
1308 1 ▶ push @ids, _rev( $r, $sp ) // return ( "fatal: bad revision '$sp'", 0 );
Condition50%1/2
_rev($r, $sp) // (return "fatal: bad revision '${sp}'", 0)
l!l
10
MC/DC0%0/1
_rev($r, $sp) // (return "fatal: bad revision '${sp}'", 0)
_rev($r, $sp)
Truth table50%1/2
A
A= _rev($r, $sp)
Aresult
11
00
1309 }
1310 1 my $h = _head($r);
1311 1 my $tip = $h;
1312 1 my @out;
1313 1 for my $id (@ids) {
1314 1 my $c = $r->{commits}{$id};
1315 1 ▶ return ( "error: commit $id is a merge but no -m option was given.\nfatal: cherry-pick failed", 0 ) if @{ $c->{parents} || [] } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$$c{"parents"} or [];} > 1 0 1 1
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
1316 1 ▶ my $base = _tree( $r, ( $c->{parents} || [] )->[0] );
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
1317 1 my $tree = _clone( _tree( $r, $tip ) );
1318 1 for my $p ( keys %{ { %$base, %{ $c->{tree} } } } ) {
1319 5 my ( $b, $n ) = ( $base->{$p}, $c->{tree}{$p} );
1320 5 ▶ next if ( $b // "\0" ) eq ( $n // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($b // "\0") eq ($n // "\0") 4 1 5
Condition75%3/4
$b // "\0"
l!l
41
$n // "\0"
l!l
50
MC/DC100%1/1
$b // "\0"
$b
MC/DC0%0/1
$n // "\0"
$n
Truth table100%2/2
A
A= $b
Aresult
11
00
Truth table50%1/2
A
A= $n
Aresult
11
00
1321 return ( "error: could not apply " . _short($id) . '... ' . _subject( $c->{message} ) . "\nhint: After resolving the conflicts, mark them with\nhint: \"git add/rm <pathspec>\", then run\nhint: \"git cherry-pick --continue\".\nCONFLICT (content): Merge conflict in $p", 0 )
1322 1 ▶ if ( $tree->{$p} // "\0" ) ne ( $b // "\0" ) && ( $tree->{$p} // "\0" ) ne ( $n // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($$tree{$p} // "\0") ne ($b // "\0") and ($$tree{$p} // "\0") ne ($n // "\0") 0 1 1
Condition27%3/11
($$tree{$p} // "\0") ne ($b // "\0") and ($$tree{$p} // "\0") ne ($n // "\0")
!ll&&!rl&&r
100
$$tree{$p} // "\0"
l!l
01
$b // "\0"
l!l
01
$$tree{$p} // "\0"
l!l
00
$n // "\0"
l!l
00
MC/DC0%0/2
($$tree{$p} // "\0") ne ($b // "\0") and ($$tree{$p} // "\0") ne ($n // "\0")
$$tree{$p} $$tree{$p}
MC/DC0%0/1
$b // "\0"
$b
MC/DC0%0/1
$n // "\0"
$n
Truth table33%1/3
A and B
A= $$tree{$p}B= $$tree{$p}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $b
Aresult
11
00
Truth table0%0/2
A
A= $n
Aresult
11
00
1323 0 ▶ if ( defined $n ) { $tree->{$p} = $n } else { delete $tree->{$p} }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $n) { } 1 0 1
1324 }
1325 0 ▶ if ($nocommit) { $r->{index} = $tree; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($nocommit) 0 1 1
1326 1 ▶ my $msg = $c->{message} . ( $x ? "\n\n(cherry picked from commit $id)" : '' );
Branch: 1 branch
BranchTrueFalseTotal
$x ? : 1 0 1
1327 1 $tip = _mk_commit( $dev, $r, parents => [ grep {defined} $tip ], message => $msg, author => $c->{author}, tree => $tree );
1328 1 ▶ push @out, '[' . ( $r->{branch} // 'detached HEAD' ) . ' ' . _short($tip) . '] ' . _subject($msg);
Condition50%1/2
$$r{"branch"} // "detached HEAD"
l!l
10
MC/DC0%0/1
$$r{"branch"} // "detached HEAD"
$$r{"branch"}
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
1329 }
1330 0 ▶ if ($nocommit) { _set_work( $dev, $root, _work_tracked( $dev, $root, $r ), $r->{index} ); return ( '', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($nocommit) 0 1 1
1331 1 _switch_tree( $dev, $root, $r, $h, $tip );
1332 0 ▶ if ( defined $r->{branch} ) { $r->{refs}{heads}{ $r->{branch} } = $tip } else { $r->{detached} = $tip }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$r{'branch'}) { } 1 0 1
1333 1 return ( join( "\n", @out ), 1 );
1334 }
1335  
1336 2 ▶sub _g_revert {
Subroutine _g_revert: called CC=26 SCAR=36.3
1337 2 my ( $dev, $root, $r, $a ) = @_;
1338 2 my $noedit = grep { $_ eq '--no-edit' } @$a;
1339 2 ▶ my $nocommit = grep { $_ eq '-n' || $_ eq '--no-commit' } @$a;
Condition33%1/3
$_ eq '-n' || $_ eq '--no-commit'
l!l&&r!l&&!r
003
MC/DC0%0/2
$_ eq '-n' || $_ eq '--no-commit'
$_ eq '-n' $_ eq '--no-commit'
Truth table33%1/3
A || B
A= $_ eq '-n'B= $_ eq '--no-commit'
ABresult
1X1
011
000
1340 2 my @revs = grep { !/\A-/ } @$a;
1341 2 ▶ return ( 'usage: git revert [--[no-]edit] [-n] [-m <parent-number>] [-s] [-S[<keyid>]] <commit>...', 0 ) unless @revs;
Branch: 1 branch
BranchTrueFalseTotal
unless @revs 0 2 2
1342 2 ▶ if ( !$noedit && !$nocommit ) { push @GAPS, 'git revert (Editor)'; return ( "error: There was a problem with the editor 'editor'.\nPlease supply the message using either -m or -F option.", 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($noedit or $nocommit) 1 1 2
Condition66%2/3
$noedit or $nocommit
l!l&&r!l&&!r
101
MC/DC50%1/2
$noedit or $nocommit
$noedit $nocommit
Truth table66%2/3
A or B
A= $noeditB= $nocommit
ABresult
1X1
011
000
1343 1 ▶ return ( "error: your local changes would be overwritten by revert.\nhint: commit your changes or stash them to proceed.\nfatal: revert failed", 0 ) if _dirty( $dev, $root, $r ) && !$nocommit;
Branch: 1 branch
BranchTrueFalseTotal
if _dirty($dev, $root, $r) and not $nocommit 0 1 1
Condition33%1/3
_dirty($dev, $root, $r) and not $nocommit
!ll&&!rl&&r
100
MC/DC0%0/2
_dirty($dev, $root, $r) and not $nocommit
_dirty($dev, $root, $r) not $nocommit
Truth table33%1/3
A and not(B)
A= _dirty($dev, $root, $r)B= not $nocommit
ABresult
0X0
100
111
1344 1 my @out;
1345 1 for my $spec (@revs) {
1346 1 ▶ my $id = _rev( $r, $spec ) // return ( "fatal: bad revision '$spec'", 0 );
Condition50%1/2
_rev($r, $spec) // (return "fatal: bad revision '${spec}'", 0)
l!l
10
MC/DC0%0/1
_rev($r, $spec) // (return "fatal: bad revision '${spec}'", 0)
_rev($r, $spec)
Truth table50%1/2
A
A= _rev($r, $spec)
Aresult
11
00
1347 1 my $c = $r->{commits}{$id};
1348 1 ▶ return ( "error: commit $id is a merge but no -m option was given.\nfatal: revert failed", 0 ) if @{ $c->{parents} || [] } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @{$$c{"parents"} or [];} > 1 0 1 1
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
1349 1 ▶ my $base = _tree( $r, ( $c->{parents} || [] )->[0] );
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
1350 1 ▶ my $tree = _clone( $nocommit ? _index($r) : _tree( $r, _head($r) ) );
Branch: 1 branch
BranchTrueFalseTotal
$nocommit ? : 0 1 1
1351 1 for my $p ( keys %{ { %$base, %{ $c->{tree} } } } ) {
1352 5 my ( $old, $new ) = ( $base->{$p}, $c->{tree}{$p} );
1353 5 ▶ next if ( $old // "\0" ) eq ( $new // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($old // "\0") eq ($new // "\0") 4 1 5
Condition75%3/4
$old // "\0"
l!l
41
$new // "\0"
l!l
50
MC/DC100%1/1
$old // "\0"
$old
MC/DC0%0/1
$new // "\0"
$new
Truth table100%2/2
A
A= $old
Aresult
11
00
Truth table50%1/2
A
A= $new
Aresult
11
00
1354 return ( "error: could not revert " . _short($id) . '... ' . _subject( $c->{message} ) . "\nhint: after resolving the conflicts, mark the corrected paths\nhint: with 'git add <paths>' or 'git rm <paths>'\nCONFLICT (content): Merge conflict in $p", 0 )
1355 1 ▶ if ( $tree->{$p} // "\0" ) ne ( $new // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($$tree{$p} // "\0") ne ($new // "\0") 0 1 1
Condition50%2/4
$$tree{$p} // "\0"
l!l
10
$new // "\0"
l!l
10
MC/DC0%0/1
$$tree{$p} // "\0"
$$tree{$p}
MC/DC0%0/1
$new // "\0"
$new
Truth table50%1/2
A
A= $$tree{$p}
Aresult
11
00
Truth table50%1/2
A
A= $new
Aresult
11
00
1356 0 ▶ if ( defined $old ) { $tree->{$p} = $old } else { delete $tree->{$p} }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old) { } 0 1 1
1357 }
1358 1 my $w = _work( $dev, $root );
1359 1 ▶ _set_work( $dev, $root, { map { $_ => 1 } grep { exists $base->{$_} || exists $c->{tree}{$_} } keys %$w }, { map { exists $tree->{$_} ? ( $_ => $tree->{$_} ) : () } keys %{ { %$base, %{ $c->{tree} } } } } );
Branch: 1 branch
BranchTrueFalseTotal
exists $$tree{$_} ? : 4 1 5
Condition66%2/3
exists $$base{$_} || exists $$c{'tree'}{$_}
l!l&&r!l&&!r
410
MC/DC0%0/2
exists $$base{$_} || exists $$c{'tree'}{$_}
exists $$base{$_} exists $$c{'tree'}{$_}
Truth table66%2/3
A || B
A= exists $$base{$_}B= exists $$c{'tree'}{$_}
ABresult
1X1
011
000
1360 0 ▶ if ($nocommit) { $r->{index} = $tree; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($nocommit) 0 1 1
1361 1 my $h = _head($r);
1362 1 my $nid = _mk_commit( $dev, $r, parents => [$h], message => 'Revert "' . _subject( $c->{message} ) . "\"\n\nThis reverts commit $id.", author => _who( $dev, $r ), tree => $tree );
1363 0 ▶ if ( defined $r->{branch} ) { $r->{refs}{heads}{ $r->{branch} } = $nid } else { $r->{detached} = $nid }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$r{'branch'}) { } 1 0 1
1364 1 delete $r->{index};
1365 1 ▶ push @out, '[' . ( $r->{branch} // 'detached HEAD' ) . ' ' . _short($nid) . '] Revert "' . _subject( $c->{message} ) . '"';
Condition50%1/2
$$r{"branch"} // "detached HEAD"
l!l
10
MC/DC0%0/1
$$r{"branch"} // "detached HEAD"
$$r{"branch"}
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
1366 }
1367 1 return ( join( "\n", @out ), 1 );
1368 }
1369  
1370 # stash: Eintraege (neuester zuerst) mit Basis-Commit, verfolgtem Arbeitsbaum und
1371 # (mit -u) unverfolgten Dateien; der Index wird nicht eigens gesichert.
1372 6 ▶sub _stash_save {
Subroutine _stash_save: called CC=26 SCAR=34.2
1373 6 my ( $dev, $root, $r, $msg, $untracked, $only ) = @_;
1374 6 my $h = _head($r);
1375 6 my $base = _tree( $r, $h );
1376 6 my $w = _work( $dev, $root );
1377 6 my $idx = _index($r);
1378 # mit Pfaden (stash push -- PFAD): nur diese beiseite, alles andere bleibt, wie es ist
1379 6 ▶ my $sel = sub { my ($p) = @_; return 1 unless $only; return scalar grep { $_ eq '' || $p eq $_ || index( $p, "$_/" ) == 0 } @$only };
Subroutine __ANON__: called CC=4 SCAR=14.0
Branch: 1 branch
BranchTrueFalseTotal
unless $only 21 4 25
Condition66%4/6
$_ eq '' || $p eq $_ || index($p, "$_/") == 0
l!l&&r!l&&!r
103
$_ eq "" or $p eq $_
l!l&&r!l&&!r
013
MC/DC33%1/3
$_ eq '' || $p eq $_ || index($p, "$_/") == 0
$_ eq "" $p eq $_ index($p, "$_/") == 0
Truth table50%2/4
A or B || C
A= $_ eq ""B= $p eq $_C= index($p, "$_/") == 0
ABCresult
1XX1
01X1
0011
0000
1380 6 my %track = map { $_ => 1 } grep { $sel->($_) } keys %{ { %$base, %$idx } };
1381 6 ▶ my %saved = map { exists $w->{$_} ? ( $_ => $w->{$_} ) : () } keys %track;
Branch: 1 branch
BranchTrueFalseTotal
exists $$w{$_} ? : 21 0 21
1382 6 ▶ $saved{$_} //= $idx->{$_} for grep { !exists $base->{$_} && $track{$_} } keys %$idx; # neu im Index
Condition16%1/6
!exists($$base{$_}) && $track{$_}
!ll&&!rl&&r
2400
$saved{$_} //= $$idx{$_}
l!l&&r!l&&!r
000
MC/DC0%0/2
!exists($$base{$_}) && $track{$_}
!exists($$base{$_}) $track{$_}
MC/DC0%0/2
$saved{$_} //= $$idx{$_}
$saved{$_} $$idx{$_}
Truth table33%1/3
not(A) && B
A= !exists($$base{$_})B= $track{$_}
ABresult
0X0
100
111
Truth table0%0/3
A //= B
A= $saved{$_}B= $$idx{$_}
ABresult
1X1
011
000
1383 6 my @ig = _ignore_res($w);
1384 6 ▶ my %un = $untracked ? map { ( $_ => $w->{$_} ) } grep { !$track{$_} && $sel->($_) && !_ignored( \@ig, $_ ) } keys %$w : ();
Branch: 1 branch
BranchTrueFalseTotal
$untracked ? : 1 5 6
Condition66%4/6
!$track{$_} && &$sel($_) && !_ignored(\@ig, $_)
!ll&&!rl&&r
401
not $track{$_} and &$sel($_)
!ll&&!rl&&r
401
MC/DC33%1/3
!$track{$_} && &$sel($_) && !_ignored(\@ig, $_)
not $track{$_} &$sel($_) !_ignored(\@ig, $_)
Truth table50%2/4
not(A) and B && not(C)
A= not $track{$_}B= &$sel($_)C= !_ignored(\@ig, $_)
ABCresult
0XX0
10X0
1100
1111
1385 6 ▶ my $changed = grep { ( $saved{$_} // "\0" ) ne ( $base->{$_} // "\0" ) } keys %{ { %saved, %$base } };
Condition75%3/4
$saved{$_} // "\0"
l!l
213
$$base{$_} // "\0"
l!l
240
MC/DC100%1/1
$saved{$_} // "\0"
$saved{$_}
MC/DC0%0/1
$$base{$_} // "\0"
$$base{$_}
Truth table100%2/2
A
A= $saved{$_}
Aresult
11
00
Truth table50%1/2
A
A= $$base{$_}
Aresult
11
00
1386 6 ▶ return undef unless $changed || %un;
Branch: 1 branch
BranchTrueFalseTotal
unless $changed or %un 1 5 6
Condition100%3/3
$changed or %un
l!l&&r!l&&!r
411
MC/DC100%2/2
$changed or %un
$changed %un
Truth table100%3/3
A or B
A= $changedB= %un
ABresult
1X1
011
000
1387 my $label = defined $msg ? 'On ' . ( $r->{branch} // '(no branch)' ) . ": $msg"
1388 5 ▶ : 'WIP on ' . ( $r->{branch} // '(no branch)' ) . ': ' . _short($h) . ' ' . _subject( ( $r->{commits}{$h} || {} )->{message} );
Branch: 1 branch
BranchTrueFalseTotal
defined $msg ? : 2 3 5
Condition50%3/6
$$r{"branch"} // "(no branch)"
l!l
20
$$r{"branch"} // "(no branch)"
l!l
30
$$r{'commits'}{$h} || {}
l!l
30
MC/DC0%0/1
$$r{"branch"} // "(no branch)"
$$r{"branch"}
MC/DC0%0/1
$$r{"branch"} // "(no branch)"
$$r{"branch"}
MC/DC0%0/1
$$r{'commits'}{$h} || {}
$$r{'commits'}{$h}
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{'commits'}{$h}
Aresult
11
00
1389 5 ▶ $saved{$_} //= $base->{$_} for grep { !$track{$_} } keys %$base; # nicht gewaehlt: unveraendert
Condition33%1/3
$saved{$_} //= $$base{$_}
l!l&&r!l&&!r
030
MC/DC0%0/2
$saved{$_} //= $$base{$_}
$saved{$_} $$base{$_}
Truth table33%1/3
A //= B
A= $saved{$_}B= $$base{$_}
ABresult
1X1
011
000
1390 5 my $e = { base => $h, work => \%saved, untracked => \%un, message => $label };
1391 5 $e->{id} = Digest::SHA::sha1_hex( $J->encode($e) );
1392 5 unshift @{ $r->{stash} }, $e;
1393 5 ▶ _set_work( $dev, $root, { map { $_ => 1 } grep { $track{$_} || exists $un{$_} } keys %$w }, { map { exists $base->{$_} ? ( $_ => $base->{$_} ) : () } keys %track } );
Branch: 1 branch
BranchTrueFalseTotal
exists $$base{$_} ? : 17 0 17
Condition100%3/3
$track{$_} || exists $un{$_}
l!l&&r!l&&!r
1714
MC/DC100%2/2
$track{$_} || exists $un{$_}
$track{$_} exists $un{$_}
Truth table100%3/3
A || B
A= $track{$_}B= exists $un{$_}
ABresult
1X1
011
000
1394 5 ▶ if ($only) {
Branch: 1 branch
BranchTrueFalseTotal
if ($only) { } 1 4 5
1395 1 $idx->{$_} = $base->{$_} for grep { exists $base->{$_} } keys %track;
1396 1 delete $idx->{$_} for grep { !exists $base->{$_} } keys %track;
1397 1 $r->{index} = $idx;
1398 1 ▶ delete $r->{index} unless grep { ( $idx->{$_} // "\0" ) ne ( $base->{$_} // "\0" ) } keys %{ { %$idx, %$base } };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {($$idx{$_} // "\0") ne ($$base{$_} // "\0");} keys %{+{%$idx, %$base};} 1 0 1
Condition50%2/4
$$idx{$_} // "\0"
l!l
40
$$base{$_} // "\0"
l!l
40
MC/DC0%0/1
$$idx{$_} // "\0"
$$idx{$_}
MC/DC0%0/1
$$base{$_} // "\0"
$$base{$_}
Truth table50%1/2
A
A= $$idx{$_}
Aresult
11
00
Truth table50%1/2
A
A= $$base{$_}
Aresult
11
00
1399 }
1400 4 else { delete $r->{index} }
1401 5 return $e;
1402 }
1403  
1404 5 ▶sub _stash_apply {
Subroutine _stash_apply: called CC=20 SCAR=35.1
1405 5 my ( $dev, $root, $r, $e ) = @_;
1406 5 my $base = _tree( $r, $e->{base} );
1407 5 my $head = _tree( $r, _head($r) );
1408 5 my $w = _work( $dev, $root );
1409 5 my ( $st, $un ) = _changes( $dev, $root, $r );
1410 0 my %dirty = map { $_->[1] => 1 } @$st, @$un;
1411 5 my %new = %$w;
1412 5 for my $p ( sort keys %{ { %$base, %{ $e->{work} } } } ) {
1413 20 my ( $old, $mine ) = ( $base->{$p}, $e->{work}{$p} );
1414 20 ▶ next if ( $old // "\0" ) eq ( $mine // "\0" );
Branch: 1 branch
BranchTrueFalseTotal
if ($old // "\0") eq ($mine // "\0") 16 4 20
Condition50%2/4
$old // "\0"
l!l
200
$mine // "\0"
l!l
200
MC/DC0%0/1
$old // "\0"
$old
MC/DC0%0/1
$mine // "\0"
$mine
Truth table50%1/2
A
A= $old
Aresult
11
00
Truth table50%1/2
A
A= $mine
Aresult
11
00
1415 4 ▶ return ( "error: Your local changes to the following files would be overwritten by merge:\n\t$p\nPlease commit your changes or stash them before you merge.\nAborting", 0 ) if $dirty{$p};
Branch: 1 branch
BranchTrueFalseTotal
if $dirty{$p} 0 4 4
1416 4 my $cur = $head->{$p};
1417 4 ▶ if ( ( $cur // "\0" ) ne ( $old // "\0" ) && ( $cur // "\0" ) ne ( $mine // "\0" ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($cur // "\0") ne ($old // "\0") and ($cur // "\0") ne ($mine // "\0")) 0 4 4
Condition27%3/11
($cur // "\0") ne ($old // "\0") and ($cur // "\0") ne ($mine // "\0")
!ll&&!rl&&r
400
$cur // "\0"
l!l
40
$old // "\0"
l!l
40
$cur // "\0"
l!l
00
$mine // "\0"
l!l
00
MC/DC0%0/2
($cur // "\0") ne ($old // "\0") and ($cur // "\0") ne ($mine // "\0")
$cur $cur
MC/DC0%0/1
$old // "\0"
$old
MC/DC0%0/1
$mine // "\0"
$mine
Truth table0%0/3
A and B
A= $curB= $cur
ABresult
0X0
100
111
Truth table50%1/2
A
A= $old
Aresult
11
00
Truth table0%0/2
A
A= $mine
Aresult
11
00
1418 0 return ( "Auto-merging $p\nCONFLICT (content): Merge conflict in $p\nThe stash entry is kept in case you need it again.", 0 );
1419 }
1420 0 ▶ if ( defined $mine ) { $new{$p} = $mine } else { delete $new{$p} }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mine) { } 4 0 4
1421 }
1422 5 for my $p ( keys %{ $e->{untracked} } ) {
1423 1 ▶ return ( "$p already exists, no checkout\nerror: could not restore untracked files from stash", 0 ) if exists $w->{$p};
Branch: 1 branch
BranchTrueFalseTotal
if exists $$w{$p} 0 1 1
1424 1 $new{$p} = $e->{untracked}{$p};
1425 }
1426 5 _set_work( $dev, $root, $w, \%new );
1427 5 my $idx = _index($r);
1428 5 ▶ $idx->{$_} = $e->{work}{$_} for grep { !exists $base->{$_} && defined $e->{work}{$_} } keys %{ $e->{work} }; # neue Dateien wieder im Index
Condition33%1/3
!exists($$base{$_}) && defined $$e{'work'}{$_}
!ll&&!rl&&r
2000
MC/DC0%0/2
!exists($$base{$_}) && defined $$e{'work'}{$_}
!exists($$base{$_}) defined $$e{'work'}{$_}
Truth table33%1/3
not(A) && B
A= !exists($$base{$_})B= defined $$e{'work'}{$_}
ABresult
0X0
100
111
1429 5 $r->{index} = $idx;
1430 5 ▶ delete $r->{index} unless grep { ( $idx->{$_} // "\0" ) ne ( $head->{$_} // "\0" ) } keys %{ { %$idx, %$head } };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {($$idx{$_} // "\0") ne ($$head{$_} // "\0");} keys %{+{%$idx, %$head};} 5 0 5
Condition50%2/4
$$idx{$_} // "\0"
l!l
230
$$head{$_} // "\0"
l!l
230
MC/DC0%0/1
$$idx{$_} // "\0"
$$idx{$_}
MC/DC0%0/1
$$head{$_} // "\0"
$$head{$_}
Truth table50%1/2
A
A= $$idx{$_}
Aresult
11
00
Truth table50%1/2
A
A= $$head{$_}
Aresult
11
00
1431 5 return ( '', 1 );
1432 }
1433  
1434 5 ▶sub _stash_ref {
Subroutine _stash_ref: called CC=5 SCAR=23.0
1435 5 my ( $r, $spec ) = @_;
1436 5 ▶ my $n = !defined $spec ? 0 : $spec =~ /\A(?:stash\@\{(\d+)\}|(\d+))\z/ ? $1 // $2 : return;
Branch: 2 branches
BranchTrueFalseTotal
!defined($spec) ? : 5 0 5
$spec =~ /\A(?:stash\@\{(\d+)\}|(\d+))\z/ ? : 0 0 0
Condition0%0/3
$1 // $2
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 // $2
$1 $2
Truth table0%0/3
A // B
A= $1B= $2
ABresult
1X1
011
000
1437 5 ▶ return ( $n, ( $r->{stash} || [] )->[$n] );
Condition50%1/2
$$r{'stash'} || []
l!l
50
MC/DC0%0/1
$$r{'stash'} || []
$$r{'stash'}
Truth table50%1/2
A
A= $$r{'stash'}
Aresult
11
00
1438 }
1439  
1440 10 ▶sub _g_stash {
Subroutine _g_stash: called CC=35 SCAR=39.5
1441 10 my ( $dev, $root, $r, $a ) = @_;
1442 10 my @x = @$a;
1443 10 ▶ my $sub = @x && $x[0] !~ /\A-/ ? shift @x : 'push';
Branch: 1 branch
BranchTrueFalseTotal
@x && !($x[0] =~ /\A-/) ? : 8 2 10
Condition100%3/3
@x and not $x[0] =~ /\A-/
!ll&&!rl&&r
118
MC/DC100%2/2
@x and not $x[0] =~ /\A-/
@x not $x[0] =~ /\A-/
Truth table100%3/3
A and not(B)
A= @xB= not $x[0] =~ /\A-/
ABresult
0X0
100
111
1444 10 my @p = grep { !/\A-/ } @x;
1445 10 ▶ if ( $sub eq 'push' || $sub eq 'save' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "push" or $sub eq "save") 4 6 10
Condition66%2/3
$sub eq "push" or $sub eq "save"
l!l&&r!l&&!r
406
MC/DC50%1/2
$sub eq "push" or $sub eq "save"
$sub eq "push" $sub eq "save"
Truth table66%2/3
A or B
A= $sub eq "push"B= $sub eq "save"
ABresult
1X1
011
000
1446 4 my $msg;
1447 4 ▶ for my $i ( 0 .. $#x ) { $msg = $x[ $i + 1 ] if $x[$i] eq '-m' || $x[$i] eq '--message' }
Branch: 1 branch
BranchTrueFalseTotal
if $x[$i] eq "-m" or $x[$i] eq "--message" 2 5 7
Condition66%2/3
$x[$i] eq "-m" or $x[$i] eq "--message"
l!l&&r!l&&!r
205
MC/DC50%1/2
$x[$i] eq "-m" or $x[$i] eq "--message"
$x[$i] eq "-m" $x[$i] eq "--message"
Truth table66%2/3
A or B
A= $x[$i] eq "-m"B= $x[$i] eq "--message"
ABresult
1X1
011
000
1448 4 ▶ $msg //= join ' ', @p if $sub eq 'save' && @p;
Branch: 1 branch
BranchTrueFalseTotal
if $sub eq "save" and @p 0 4 4
Condition20%1/5
$sub eq "save" and @p
!ll&&!rl&&r
400
$msg //= join(" ", @p)
l!l
00
MC/DC0%0/2
$sub eq "save" and @p
$sub eq "save" @p
MC/DC0%0/1
$msg //= join(" ", @p)
$msg
Truth table33%1/3
A and B
A= $sub eq "save"B= @p
ABresult
0X0
100
111
Truth table0%0/2
A
A= $msg
Aresult
11
00
1449 4 ▶ my @spec = $sub eq 'push' ? grep { !defined $msg || $_ ne $msg } @p : ();
Branch: 1 branch
BranchTrueFalseTotal
$sub eq 'push' ? : 4 0 4
Condition66%2/3
!defined($msg) || $_ ne $msg
l!l&&r!l&&!r
012
MC/DC50%1/2
!defined($msg) || $_ ne $msg
!defined($msg) $_ ne $msg
Truth table66%2/3
not(A) || B
A= !defined($msg)B= $_ ne $msg
ABresult
1X1
011
000
1450 4 ▶ my $only = @spec ? [ grep {defined} _paths( $root, $CWD, @spec ) ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@spec ? : 1 3 4
1451 4 ▶ my $u = grep { $_ eq '-u' || $_ eq '--include-untracked' || $_ eq '-a' || $_ eq '--all' } @x;
Condition66%6/9
$_ eq '-u' || $_ eq '--include-untracked' || $_ eq '-a' || $_ eq '--all'
l!l&&r!l&&!r
106
$_ eq "-u" or $_ eq "--include-untracked" or $_ eq "-a"
l!l&&r!l&&!r
106
$_ eq "-u" or $_ eq "--include-untracked"
l!l&&r!l&&!r
106
MC/DC25%1/4
$_ eq '-u' || $_ eq '--include-untracked' || $_ eq '-a' || $_ eq '--all'
$_ eq "-u" $_ eq "--include-untracked" $_ eq "-a" $_ eq '--all'
Truth table40%2/5
A or B or C || D
A= $_ eq "-u"B= $_ eq "--include-untracked"C= $_ eq "-a"D= $_ eq '--all'
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1452 4 ▶ my $e = _stash_save( $dev, $root, $r, $msg, $u, $only ) // return ( 'No local changes to save', 1 );
Condition100%2/2
_stash_save($dev, $root, $r, $msg, $u, $only) // (return "No local changes to save", 1)
l!l
31
MC/DC100%1/1
_stash_save($dev, $root, $r, $msg, $u, $only) // (return "No local changes to save", 1)
_stash_save($dev, $root, $r, $msg, $u, $only)
Truth table100%2/2
A
A= _stash_save($dev, $root, $r, $msg, $u, $only)
Aresult
11
00
1453 3 return ( "Saved working directory and index state $e->{message}", 1 );
1454 }
1455 6 ▶ if ( $sub eq 'list' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "list") 1 5 6
1456 1 ▶ my $l = $r->{stash} || [];
Condition50%1/2
$$r{'stash'} || []
l!l
10
MC/DC0%0/1
$$r{'stash'} || []
$$r{'stash'}
Truth table50%1/2
A
A= $$r{'stash'}
Aresult
11
00
1457 1 return ( join( "\n", map {"stash\@{$_}: $l->[$_]{message}"} 0 .. $#$l ), 1 );
1458 }
1459 0 ▶ if ( $sub eq 'clear' ) { delete $r->{stash}; return ( '', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "clear") 0 5 5
1460 5 my ( $n, $e ) = _stash_ref( $r, $p[0] );
1461 5 ▶ return ( defined $p[0] ? "error: $p[0] is not a valid reference" : 'No stash entries found.', 0 ) unless $e;
Branch: 2 branches
BranchTrueFalseTotal
unless $e 0 5 5
defined $p[0] ? : 0 0 0
1462 5 ▶ if ( $sub eq 'show' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "show") 1 4 5
1463 0 ▶ my $mode = ( grep { $_ eq '-p' || $_ eq '--patch' } @x ) ? undef : ( grep { $_ eq '--name-only' } @x ) ? 'name-only' : 'stat';
Branch: 2 branches
BranchTrueFalseTotal
grep({$_ eq '-p' or $_ eq '--patch';} @x) ? : 1 0 1
grep({$_ eq '--name-only';} @x) ? : 0 0 0
Condition33%1/3
$_ eq '-p' || $_ eq '--patch'
l!l&&r!l&&!r
100
MC/DC0%0/2
$_ eq '-p' || $_ eq '--patch'
$_ eq '-p' $_ eq '--patch'
Truth table33%1/3
A || B
A= $_ eq '-p'B= $_ eq '--patch'
ABresult
1X1
011
000
1464 1 my $base = _tree( $r, $e->{base} );
1465 1 return ( _diff_trees( $base, { %$base, %{ $e->{work} } }, $mode ), 1 );
1466 }
1467 4 ▶ if ( $sub eq 'apply' || $sub eq 'pop' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "apply" or $sub eq "pop") 3 1 4
Condition100%3/3
$sub eq "apply" or $sub eq "pop"
l!l&&r!l&&!r
121
MC/DC100%2/2
$sub eq "apply" or $sub eq "pop"
$sub eq "apply" $sub eq "pop"
Truth table100%3/3
A or B
A= $sub eq "apply"B= $sub eq "pop"
ABresult
1X1
011
000
1468 3 my ( $o, $ok ) = _stash_apply( $dev, $root, $r, $e );
1469 3 ▶ return ( $o, 0 ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 3 3
1470 3 ▶ splice @{ $r->{stash} }, $n, 1 if $sub eq 'pop';
Branch: 1 branch
BranchTrueFalseTotal
if $sub eq "pop" 2 1 3
1471 3 my ( $st, $un, $ut ) = _changes( $dev, $root, $r );
1472 2 ▶ return ( join( "\n", 'On branch ' . ( $r->{branch} // 'HEAD' ), 'Changes not staged for commit:', ( map {"\t$_->[0]: $_->[1]"} @$un ),
Branch: 1 branch
BranchTrueFalseTotal
@$ut ? : 2 1 3
1473 2 ▶ ( @$ut ? ( 'Untracked files:', map {"\t$_"} @$ut ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$sub eq 'pop' ? : 2 1 3
1474 3 ▶ ( $sub eq 'pop' ? "Dropped refs/stash\@{$n} (" . $e->{id} . ')' : () ) ), 1 );
Condition50%1/2
$$r{"branch"} // "HEAD"
l!l
30
MC/DC0%0/1
$$r{"branch"} // "HEAD"
$$r{"branch"}
Truth table50%1/2
A
A= $$r{"branch"}
Aresult
11
00
1475 }
1476 1 ▶ if ( $sub eq 'drop' ) { splice @{ $r->{stash} }, $n, 1; return ( "Dropped refs/stash\@{$n} ($e->{id})", 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "drop") 1 0 1
1477 0 push @GAPS, "git stash $sub";
1478 0 return ( '', 0 );
1479 }
1480  
1481 # --autostash (oder rebase.autoStash): vor dem Rebase beiseite, danach zurueck
1482 7 ▶sub _autostash {
Subroutine _autostash: called CC=12 SCAR=25.7
1483 7 my ( $dev, $root, $r, $a, $run ) = @_;
1484 7 ▶ my %cfg = ( %{ ( $dev->{git} || {} )->{config} || {} }, %{ $r->{config} || {} } );
Condition66%4/6
($$dev{'git'} || {})->{'config'} || {}
l!l
70
$$dev{'git'} || {}
l!l
70
$$r{'config'} || {}
l!l
16
MC/DC0%0/1
($$dev{'git'} || {})->{'config'} || {}
$$dev{'git'}
MC/DC100%1/1
$$r{'config'} || {}
$$r{'config'}
Truth table50%1/2
A
A= $$dev{'git'}
Aresult
11
00
Truth table100%2/2
A
A= $$r{'config'}
Aresult
11
00
1485 7 ▶ my $on = ( grep { $_ eq '--autostash' } @$a ) ? 1 : ( grep { $_ eq '--no-autostash' } @$a ) ? 0 : ( $cfg{'rebase.autoStash'} // $cfg{'rebase.autostash'} // '' ) eq 'true';
Branch: 2 branches
BranchTrueFalseTotal
grep({$_ eq '--autostash';} @$a) ? : 1 6 7
grep({$_ eq '--no-autostash';} @$a) ? : 0 6 6
Condition80%4/5
($cfg{"rebase.autoStash"} // $cfg{"rebase.autostash"}) // ""
l!l
15
$cfg{"rebase.autoStash"} // $cfg{"rebase.autostash"}
l!l&&r!l&&!r
015
MC/DC50%1/2
($cfg{"rebase.autoStash"} // $cfg{"rebase.autostash"}) // ""
$cfg{"rebase.autoStash"} $cfg{"rebase.autostash"}
Truth table66%2/3
A // B
A= $cfg{"rebase.autoStash"}B= $cfg{"rebase.autostash"}
ABresult
1X1
011
000
1486 7 ▶ return $run->() unless $on && _dirty( $dev, $root, $r );
Branch: 1 branch
BranchTrueFalseTotal
unless $on and _dirty($dev, $root, $r) 5 2 7
Condition66%2/3
$on and _dirty($dev, $root, $r)
!ll&&!rl&&r
502
MC/DC50%1/2
$on and _dirty($dev, $root, $r)
$on _dirty($dev, $root, $r)
Truth table66%2/3
A and B
A= $onB= _dirty($dev, $root, $r)
ABresult
0X0
100
111
1487 2 my $e = _stash_save( $dev, $root, $r, undef, 0 );
1488 2 my ( $o, $ok, $keep ) = $run->();
1489 2 shift @{ $r->{stash} };
1490 2 my ( $ao, $aok ) = _stash_apply( $dev, $root, $r, $e );
1491 0 ▶ unshift @{ $r->{stash} }, $e unless $aok;
Branch: 1 branch
BranchTrueFalseTotal
unless $aok 0 2 2
1492 2 ▶ return ( join( "\n", 'Created autostash: ' . _short( $e->{id} ), grep( {length} $o ),
Branch: 1 branch
BranchTrueFalseTotal
$aok ? : 2 0 2
1493 $aok ? 'Applied autostash.' : "Applying autostash resulted in conflicts.\nYour changes are safe in the stash.\nYou can run \"git stash pop\" or \"git stash drop\" at any time." ), $ok, $keep );
1494 }
1495  
1496 3 ▶sub _g_rev_list {
Subroutine _g_rev_list: called CC=27 SCAR=43.6
1497 3 my ( $dev, $root, $r, $a ) = @_;
1498 3 my ( $count, $all, $n, @inc, @exc );
1499 3 my @x = @$a;
1500 3 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 4 3 7
1501 4 my $v = shift @x;
1502 4 ▶ if ( $v eq '--count' ) { $count = 1 }
Branch: 9 branches
BranchTrueFalseTotal
if ($v eq '--count') { } 1 3 4
elsif ($v eq '--all') { } 0 3 3
elsif ($v =~ /\A(?:-n|--max-count=?)(\d*)\z/) { } 0 3 3
elsif ($v =~ /\A-(\d+)\z/) { } 0 3 3
elsif ($v =~ /\A--(?:no-merges|first-parent|reverse|abbrev-commit)\z/) { } 0 3 3
elsif ($v eq '--') { } 0 3 3
elsif ($v =~ /\A-/) { } 0 3 3
elsif ($v =~ /\A(.*?)\.\.(.*)\z/) { } 1 2 3
elsif ($v =~ /\A\^(.+)\z/) { } 0 2 2
1503 0 elsif ( $v eq '--all' ) { $all = 1 }
1504 0 ▶ elsif ( $v =~ /\A(?:-n|--max-count=?)(\d*)\z/ ) { $n = length $1 ? $1 : shift @x }
Branch: 1 branch
BranchTrueFalseTotal
length $1 ? : 0 0 0
1505 0 elsif ( $v =~ /\A-(\d+)\z/ ) { $n = $1 }
1506 elsif ( $v =~ /\A--(?:no-merges|first-parent|reverse|abbrev-commit)\z/ ) { }
1507 0 elsif ( $v eq '--' ) { last }
1508 0 elsif ( $v =~ /\A-/ ) { return ( "fatal: unrecognized argument: $v", 0 ) }
1509 1 ▶ elsif ( $v =~ /\A(.*?)\.\.(.*)\z/ ) { push @exc, length $1 ? $1 : 'HEAD'; push @inc, length $2 ? $2 : 'HEAD' }
Branch: 2 branches
BranchTrueFalseTotal
length $1 ? : 1 0 1
length $2 ? : 1 0 1
1510 0 elsif ( $v =~ /\A\^(.+)\z/ ) { push @exc, $1 }
1511 2 else { push @inc, $v }
1512 }
1513 0 ▶ my @tips = $all ? ( values %{ $r->{refs}{heads} || {} }, values %{ $r->{refs}{remotes} || {} }, map { $_->{commit} } values %{ $r->{refs}{tags} || {} } ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$all ? : 0 3 3
Condition0%0/6
$$r{'refs'}{'heads'} || {}
l!l
00
$$r{'refs'}{'remotes'} || {}
l!l
00
$$r{'refs'}{'tags'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'heads'} || {}
$$r{'refs'}{'heads'}
MC/DC0%0/1
$$r{'refs'}{'remotes'} || {}
$$r{'refs'}{'remotes'}
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table0%0/2
A
A= $$r{'refs'}{'heads'}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'refs'}{'remotes'}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
1514 3 ▶ for (@inc) { push @tips, _rev( $r, $_ ) // return ( "fatal: ambiguous argument '$_': unknown revision or path not in the working tree.", 0 ) }
Condition50%1/2
_rev($r, $_) // (return "fatal: ambiguous argument '${_}': unknown revision or path not in the working tree.", 0)
l!l
30
MC/DC0%0/1
_rev($r, $_) // (return "fatal: ambiguous argument '${_}': unknown revision or path not in the working tree.", 0)
_rev($r, $_)
Truth table50%1/2
A
A= _rev($r, $_)
Aresult
11
00
1515 3 ▶ return ( "usage: git rev-list [<options>] <commit>... [--] [<path>...]", 0 ) unless @tips;
Branch: 1 branch
BranchTrueFalseTotal
unless @tips 0 3 3
1516 3 my %ex;
1517 3 ▶ for (@exc) { my $id = _rev( $r, $_ ) // return ( "fatal: ambiguous argument '$_': unknown revision or path not in the working tree.", 0 ); %ex = ( %ex, %{ _ancestors( $r, $id ) } ) }
Condition50%1/2
_rev($r, $_) // (return "fatal: ambiguous argument '${_}': unknown revision or path not in the working tree.", 0)
l!l
10
MC/DC0%0/1
_rev($r, $_) // (return "fatal: ambiguous argument '${_}': unknown revision or path not in the working tree.", 0)
_rev($r, $_)
Truth table50%1/2
A
A= _rev($r, $_)
Aresult
11
00
1518 3 my %s;
1519 3 ▶ my @ids = _newest_first( $r, grep { !$s{$_}++ && !$ex{$_} } map { _range( $r, undef, $_ ) } @tips );
Condition66%2/3
$s{$_}++ || $ex{$_}
l!l&&r!l&&!r
025
MC/DC50%1/2
$s{$_}++ || $ex{$_}
$s{$_}++ $ex{$_}
Truth table66%2/3
A || B
A= $s{$_}++B= $ex{$_}
ABresult
1X1
011
000
1520 3 ▶ splice @ids, $n if defined $n && $n < @ids;
Branch: 1 branch
BranchTrueFalseTotal
if defined $n and $n < @ids 0 3 3
Condition33%1/3
defined $n and $n < @ids
!ll&&!rl&&r
300
MC/DC0%0/2
defined $n and $n < @ids
defined $n $n < @ids
Truth table33%1/3
A and B
A= defined $nB= $n < @ids
ABresult
0X0
100
111
1521 3 ▶ return ( $count ? scalar(@ids) : join( "\n", @ids ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$count ? : 1 2 3
1522 }
1523  
1524 # reflog: aus der Geschichte des Zweigs (der Simulator fuehrt kein eigenes Protokoll)
1525 1 ▶sub _g_reflog {
Subroutine _g_reflog: called CC=7 SCAR=21.3
1526 1 my ( $dev, $root, $r, $a ) = @_;
1527 1 my @x = grep { $_ ne 'show' } @$a;
1528 1 ▶ my ($n) = map { /\A-n(\d+)\z|\A-(\d+)\z/ ? $1 // $2 : () } @x;
Branch: 1 branch
BranchTrueFalseTotal
/\A-n(\d+)\z|\A-(\d+)\z/ ? : 1 0 1
Condition33%1/3
$1 // $2
l!l&&r!l&&!r
100
MC/DC0%0/2
$1 // $2
$1 $2
Truth table33%1/3
A // B
A= $1B= $2
ABresult
1X1
011
000
1529 1 my @ids = reverse _range( $r, undef, _head($r) );
1530 1 ▶ splice @ids, $n if defined $n && $n < @ids;
Branch: 1 branch
BranchTrueFalseTotal
if defined $n and $n < @ids 1 0 1
Condition33%1/3
defined $n and $n < @ids
!ll&&!rl&&r
001
MC/DC0%0/2
defined $n and $n < @ids
defined $n $n < @ids
Truth table33%1/3
A and B
A= defined $nB= $n < @ids
ABresult
0X0
100
111
1531 1 my $i = 0;
1532 1 ▶ return ( join( "\n", map { my $c = $r->{commits}{$_}; _short($_) . ' HEAD@{' . $i++ . '}: ' . ( @{ $c->{parents} || [] } ? 'commit' : 'commit (initial)' ) . ': ' . _subject( $c->{message} ) } @ids ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
@{$$c{'parents'} or [];} ? : 1 0 1
Condition50%1/2
$$c{'parents'} || []
l!l
10
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
1533 }
1534  
1535 2 ▶sub _g_merge_base {
Subroutine _g_merge_base: called CC=6 SCAR=18.3
1536 2 my ( $dev, $root, $r, $a ) = @_;
1537 2 my $anc = grep { $_ eq '--is-ancestor' } @$a;
1538 2 my @x = grep { !/\A-/ } @$a;
1539 2 ▶ return ( 'usage: git merge-base [-a | --all] <commit> <commit>...', 0 ) unless @x == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless @x == 2 0 2 2
1540 2 ▶ my @id = map { _rev( $r, $_ ) // return ( "fatal: Not a valid object name $_", 0 ) } @x;
Condition50%1/2
_rev($r, $_) // (return "fatal: Not a valid object name $_", 0)
l!l
40
MC/DC0%0/1
_rev($r, $_) // (return "fatal: Not a valid object name $_", 0)
_rev($r, $_)
Truth table50%1/2
A
A= _rev($r, $_)
Aresult
11
00
1541 2 ▶ return ( '', _ancestors( $r, $id[1] )->{ $id[0] } ? 1 : 0 ) if $anc;
Branch: 2 branches
BranchTrueFalseTotal
if $anc 1 1 2
_ancestors($r, $id[1])->{$id[0]} ? : 1 0 1
1542 1 ▶ my $b = _base( $r, @id ) // return ( '', 0 );
Condition50%1/2
_base($r, @id) // (return "", 0)
l!l
10
MC/DC0%0/1
_base($r, @id) // (return "", 0)
_base($r, @id)
Truth table50%1/2
A
A= _base($r, @id)
Aresult
11
00
1543 1 return ( $b, 1 );
1544 }
1545  
1546 0 ▶sub _g_fsck { return ( "Checking object directories: 100% (256/256), done.", 1 ) }
Subroutine _g_fsck: not called CC=1 SCAR=6.9
1547  
1548 0 ▶sub _g_describe {
Subroutine _g_describe: not called CC=16 SCAR=56.1
1549 0 my ( $dev, $root, $r, $args ) = @_;
1550 0 ▶ my $all = grep { $_ eq '--tags' || $_ eq '--all' } @$args;
Condition0%0/3
$_ eq '--tags' || $_ eq '--all'
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq '--tags' || $_ eq '--all'
$_ eq '--tags' $_ eq '--all'
Truth table0%0/3
A || B
A= $_ eq '--tags'B= $_ eq '--all'
ABresult
1X1
011
000
1551 0 my ($rev) = grep { !/\A-/ } @$args;
1552 0 ▶ my $id = _rev( $r, $rev // 'HEAD' ) // return ( "fatal: Not a valid object name " . ( $rev // 'HEAD' ), 0 );
Condition0%0/6
_rev($r, $rev // "HEAD") // (return 'fatal: Not a valid object name ' . ($rev // "HEAD"), 0)
l!l
00
$rev // "HEAD"
l!l
00
$rev // "HEAD"
l!l
00
MC/DC0%0/1
_rev($r, $rev // "HEAD") // (return 'fatal: Not a valid object name ' . ($rev // "HEAD"), 0)
_rev($r, $rev // "HEAD")
MC/DC0%0/1
$rev // "HEAD"
$rev
MC/DC0%0/1
$rev // "HEAD"
$rev
Truth table0%0/2
A
A= _rev($r, $rev // "HEAD")
Aresult
11
00
Truth table0%0/2
A
A= $rev
Aresult
11
00
Truth table0%0/2
A
A= $rev
Aresult
11
00
1553 0 my %tag;
1554 0 ▶ for my $t ( keys %{ $r->{refs}{tags} || {} } ) { push @{ $tag{ $r->{refs}{tags}{$t}{commit} } }, $t if $all || $r->{refs}{tags}{$t}{annotated} }
Branch: 1 branch
BranchTrueFalseTotal
if $all or $$r{"refs"}{"tags"}{$t}{"annotated"} 0 0 0
Condition0%0/5
$$r{'refs'}{'tags'} || {}
l!l
00
$all or $$r{"refs"}{"tags"}{$t}{"annotated"}
l!l&&r!l&&!r
000
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
MC/DC0%0/2
$all or $$r{"refs"}{"tags"}{$t}{"annotated"}
$all $$r{"refs"}{"tags"}{$t}{"annotated"}
Truth table0%0/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
Truth table0%0/3
A or B
A= $allB= $$r{"refs"}{"tags"}{$t}{"annotated"}
ABresult
1X1
011
000
1555 0 my @q = ( [ $id, 0 ] );
1556 0 my %seen;
1557 0 ▶ while (@q) {
Branch: 1 branch
BranchTrueFalseTotal
if (@q) 0 0 0
1558 0 my ( $x, $d ) = @{ shift @q };
1559 0 ▶ next if $seen{$x}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$x}++ 0 0 0
1560 0 ▶ if ( $tag{$x} ) { my ($t) = sort @{ $tag{$x} }; return ( $d ? "$t-$d-g" . _short($id) : $t, 1 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($tag{$x}) 0 0 0
$d ? : 0 0 0
1561 0 ▶ push @q, map { [ $_, $d + 1 ] } @{ ( $r->{commits}{$x} || {} )->{parents} || [] };
Condition0%0/4
($$r{'commits'}{$x} || {})->{'parents'} || []
l!l
00
$$r{'commits'}{$x} || {}
l!l
00
MC/DC0%0/1
($$r{'commits'}{$x} || {})->{'parents'} || []
$$r{'commits'}{$x}
Truth table0%0/2
A
A= $$r{'commits'}{$x}
Aresult
11
00
1562 }
1563 0 ▶ return ( $all ? 'fatal: No names found, cannot describe anything.' : "fatal: No annotated tags can describe '$id'.\nHowever, there were unannotated tags: try --tags.", 0 );
Branch: 1 branch
BranchTrueFalseTotal
$all ? : 0 0 0
1564 }
1565  
1566 0 ▶sub _g_ls_remote {
Subroutine _g_ls_remote: not called CC=4 SCAR=30.0
1567 0 my ( $dev, $root, $r, $a, $ctx ) = @_;
1568 0 my ($remote) = grep { !/\A-/ } @$a;
1569 0 my ( $s, $err ) = _server( $ctx, $r, $remote );
1570 0 ▶ return ( $err, 0 ) unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 0 0 0
1571 0 ▶ my @l = map {"$s->{refs}{heads}{$_}\trefs/heads/$_"} sort keys %{ $s->{refs}{heads} || {} };
Condition0%0/2
$$s{'refs'}{'heads'} || {}
l!l
00
MC/DC0%0/1
$$s{'refs'}{'heads'} || {}
$$s{'refs'}{'heads'}
Truth table0%0/2
A
A= $$s{'refs'}{'heads'}
Aresult
11
00
1572 0 ▶ push @l, map {"$s->{refs}{tags}{$_}{commit}\trefs/tags/$_"} sort keys %{ $s->{refs}{tags} || {} };
Condition0%0/2
$$s{'refs'}{'tags'} || {}
l!l
00
MC/DC0%0/1
$$s{'refs'}{'tags'} || {}
$$s{'refs'}{'tags'}
Truth table0%0/2
A
A= $$s{'refs'}{'tags'}
Aresult
11
00
1573 0 return ( join( "\n", @l ), 1 );
1574 }
1575  
1576 # Regeln des pre-receive-Hooks: erste Verletzung -> Text oder undef
1577 8 ▶sub _policy {
Subroutine _policy: called CC=15 SCAR=28.3
1578 8 my ( $srv, $s, $ids, $ref ) = @_;
1579 8 my $hook = $s->{hook};
1580 8 ▶ if ( defined $hook ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hook) 8 0 8
1581 8 ▶ my $e = ( $srv->{files} || {} )->{$hook};
Condition50%1/2
$$srv{'files'} || {}
l!l
80
MC/DC0%0/1
$$srv{'files'} || {}
$$srv{'files'}
Truth table50%1/2
A
A= $$srv{'files'}
Aresult
11
00
1582 8 ▶ return undef unless defined $e;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 0 8 8
1583 8 require Langertha::Holmgang::Sim::Linux;
1584 8 ▶ return undef unless Langertha::Holmgang::Sim::Linux::_can( $srv, 'git', $hook, 'x' );
Branch: 1 branch
BranchTrueFalseTotal
unless Langertha::Holmgang::Sim::Linux::_can($srv, "git", $hook, "x") 1 7 8
1585 }
1586 7 ▶ for my $p ( @{ $s->{policy} || [] } ) {
Condition50%1/2
$$s{'policy'} || []
l!l
70
MC/DC0%0/1
$$s{'policy'} || []
$$s{'policy'}
Truth table50%1/2
A
A= $$s{'policy'}
Aresult
11
00
1587 12 ▶ next if defined $p->{refs} && $ref !~ /$p->{refs}/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"refs"} and not $ref =~ /$$p{"refs"}/ 0 12 12
Condition33%1/3
defined $$p{"refs"} and not $ref =~ /$$p{"refs"}/
!ll&&!rl&&r
1200
MC/DC0%0/2
defined $$p{"refs"} and not $ref =~ /$$p{"refs"}/
defined $$p{"refs"} not $ref =~ /$$p{"refs"}/
Truth table33%1/3
A and not(B)
A= defined $$p{"refs"}B= not $ref =~ /$$p{"refs"}/
ABresult
0X0
100
111
1588 12 for my $id (@$ids) {
1589 10 ▶ my $c = $s->{_new}{$id} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $c = $$s{"_new"}{$id} or next 10 0 10
1590 my $bad = $p->{kind} eq 'message' ? $c->{message} !~ /$p->{regex}/
1591 : $p->{kind} eq 'author' ? $c->{author} !~ /$p->{regex}/
1592 10 ▶ : $p->{kind} eq 'path' ? scalar( grep {/$p->{regex}/} keys %{ $c->{tree} } )
Branch: 3 branches
BranchTrueFalseTotal
$$p{'kind'} eq 'message' ? : 6 4 10
$$p{'kind'} eq 'author' ? : 0 4 4
$$p{'kind'} eq 'path' ? : 4 0 4
1593 : 0;
1594 10 ▶ next unless $bad;
Branch: 1 branch
BranchTrueFalseTotal
unless $bad 7 3 10
1595 3 my $t = $p->{text};
1596 3 $t =~ s/\{commit\}/_short($id)/ge;
1597 3 $t =~ s/\{subject\}/_subject( $c->{message} )/ge;
1598 3 $t =~ s/\{author\}/$c->{author}/g;
1599 3 return $t;
1600 }
1601 }
1602 4 return undef;
1603 }
1604  
1605 10 ▶sub _g_push {
Subroutine _g_push: called CC=120 SCAR=73.7
1606 10 my ( $dev, $root, $r, $a, $ctx ) = @_;
1607 10 my ( $force, $lease, $tags, $setup, $follow, $delete, $dry );
1608 10 my @p;
1609 10 for (@$a) {
1610 7 ▶ if ( $_ eq '--force' || $_ eq '-f' ) { $force = 1 }
Branch: 9 branches
BranchTrueFalseTotal
if ($_ eq '--force' or $_ eq '-f') { } 2 5 7
elsif (/\A--force-with-lease/) { } 0 5 5
elsif ($_ eq '--tags') { } 0 5 5
elsif ($_ eq '--follow-tags') { } 0 5 5
elsif ($_ eq '-u' or $_ eq '--set-upstream') { } 0 5 5
elsif ($_ eq '-d' or $_ eq '--delete') { } 0 5 5
elsif ($_ eq '-n' or $_ eq '--dry-run') { } 0 5 5
elsif ($_ eq '--no-verify' or $_ eq '-q' or $_ eq '--quiet' or $_ eq '-v') { } 1 4 5
elsif (/\A-/) { } 0 4 4
Condition100%3/3
$_ eq "--force" or $_ eq "-f"
l!l&&r!l&&!r
115
MC/DC100%2/2
$_ eq "--force" or $_ eq "-f"
$_ eq "--force" $_ eq "-f"
Truth table100%3/3
A or B
A= $_ eq "--force"B= $_ eq "-f"
ABresult
1X1
011
000
1611 0 elsif (/\A--force-with-lease/) { $lease = 1 }
1612 0 elsif ( $_ eq '--tags' ) { $tags = 1 }
1613 0 elsif ( $_ eq '--follow-tags' ) { $follow = 1 }
1614 0 ▶ elsif ( $_ eq '-u' || $_ eq '--set-upstream' ) { $setup = 1 }
Condition33%1/3
$_ eq "-u" or $_ eq "--set-upstream"
l!l&&r!l&&!r
005
MC/DC0%0/2
$_ eq "-u" or $_ eq "--set-upstream"
$_ eq "-u" $_ eq "--set-upstream"
Truth table33%1/3
A or B
A= $_ eq "-u"B= $_ eq "--set-upstream"
ABresult
1X1
011
000
1615 0 ▶ elsif ( $_ eq '-d' || $_ eq '--delete' ) { $delete = 1 }
Condition33%1/3
$_ eq "-d" or $_ eq "--delete"
l!l&&r!l&&!r
005
MC/DC0%0/2
$_ eq "-d" or $_ eq "--delete"
$_ eq "-d" $_ eq "--delete"
Truth table33%1/3
A or B
A= $_ eq "-d"B= $_ eq "--delete"
ABresult
1X1
011
000
1616 0 ▶ elsif ( $_ eq '-n' || $_ eq '--dry-run' ) { $dry = 1 }
Condition33%1/3
$_ eq "-n" or $_ eq "--dry-run"
l!l&&r!l&&!r
005
MC/DC0%0/2
$_ eq "-n" or $_ eq "--dry-run"
$_ eq "-n" $_ eq "--dry-run"
Truth table33%1/3
A or B
A= $_ eq "-n"B= $_ eq "--dry-run"
ABresult
1X1
011
000
1617 ▶ elsif ( $_ eq '--no-verify' || $_ eq '-q' || $_ eq '--quiet' || $_ eq '-v' ) { }
Condition66%6/9
$_ eq "--no-verify" or $_ eq "-q" or $_ eq "--quiet" or $_ eq "-v"
l!l&&r!l&&!r
104
$_ eq "--no-verify" or $_ eq "-q" or $_ eq "--quiet"
l!l&&r!l&&!r
104
$_ eq "--no-verify" or $_ eq "-q"
l!l&&r!l&&!r
104
MC/DC25%1/4
$_ eq "--no-verify" or $_ eq "-q" or $_ eq "--quiet" or $_ eq "-v"
$_ eq "--no-verify" $_ eq "-q" $_ eq "--quiet" $_ eq "-v"
Truth table40%2/5
A or B or C or D
A= $_ eq "--no-verify"B= $_ eq "-q"C= $_ eq "--quiet"D= $_ eq "-v"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1618 0 elsif (/\A-/) { return ( "error: unknown option `" . s/\A-+//r . "'", 0 ) }
1619 4 else { push @p, $_ }
1620 }
1621 10 ▶ my $remote = shift(@p) // 'origin';
Condition100%2/2
shift @p // "origin"
l!l
28
MC/DC100%1/1
shift @p // "origin"
shift @p
Truth table100%2/2
A
A= shift @p
Aresult
11
00
1622 10 my ( $s, $err, $rm, $srv ) = _server( $ctx, $r, $remote );
1623 10 ▶ return ( $err, 0 ) unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 0 10 10
1624 10 my @specs; # [ lokal-id, ziel-ref, art, name, erzwingen ]
1625 10 my $b = $r->{branch};
1626 10 ▶ if ( !@p && !$tags ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@p or $tags) 8 2 10
Condition66%2/3
@p or $tags
l!l&&r!l&&!r
208
MC/DC50%1/2
@p or $tags
@p $tags
Truth table66%2/3
A or B
A= @pB= $tags
ABresult
1X1
011
000
1627 8 ▶ return ( "fatal: You are not currently on a branch.", 0 ) unless defined $b;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $b 0 8 8
1628 return ( "fatal: The current branch $b has no upstream branch.\nTo push the current branch and set the remote as upstream, use\n\n git push --set-upstream $remote $b\n", 0 )
1629 8 ▶ unless exists( ( $r->{refs}{remotes} || {} )->{"$remote/$b"} ) || $setup;
Branch: 1 branch
BranchTrueFalseTotal
unless exists(($$r{"refs"}{"remotes"} || {})->{"$remote/$b"}) or $setup 0 8 8
Condition40%2/5
exists(($$r{"refs"}{"remotes"} || {})->{"$remote/$b"}) or $setup
l!l&&r!l&&!r
800
$$r{'refs'}{'remotes'} || {}
l!l
80
MC/DC0%0/2
exists(($$r{"refs"}{"remotes"} || {})->{"$remote/$b"}) or $setup
$$r{'refs'}{'remotes'} $setup
Truth table33%1/3
A or B
A= $$r{'refs'}{'remotes'}B= $setup
ABresult
1X1
011
000
1630 8 @p = ($b);
1631 }
1632 10 for my $spec (@p) {
1633 10 ▶ my $f = $spec =~ s/\A\+// ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$spec =~ s/\A\+// ? : 0 10 10
1634 10 my ( $src, $dst ) = split /:/, $spec, 2;
1635 10 ▶ $dst //= $src;
Condition33%1/3
$dst //= $src
l!l&&r!l&&!r
0100
MC/DC0%0/2
$dst //= $src
$dst $src
Truth table33%1/3
A //= B
A= $dstB= $src
ABresult
1X1
011
000
1636 10 ▶ $src =~ s{\Arefs/(?:heads|tags)/}{} if defined $src;
Branch: 1 branch
BranchTrueFalseTotal
if defined $src 10 0 10
1637 10 ▶ $src = $b if $src eq 'HEAD' && defined $b;
Branch: 1 branch
BranchTrueFalseTotal
if $src eq "HEAD" and defined $b 0 10 10
Condition33%1/3
$src eq "HEAD" and defined $b
!ll&&!rl&&r
1000
MC/DC0%0/2
$src eq "HEAD" and defined $b
$src eq "HEAD" defined $b
Truth table33%1/3
A and B
A= $src eq "HEAD"B= defined $b
ABresult
0X0
100
111
1638 10 ▶ $dst = $b if $dst eq 'HEAD' && defined $b;
Branch: 1 branch
BranchTrueFalseTotal
if $dst eq "HEAD" and defined $b 0 10 10
Condition33%1/3
$dst eq "HEAD" and defined $b
!ll&&!rl&&r
1000
MC/DC0%0/2
$dst eq "HEAD" and defined $b
$dst eq "HEAD" defined $b
Truth table33%1/3
A and B
A= $dst eq "HEAD"B= defined $b
ABresult
0X0
100
111
1639 10 ▶ if ( $delete || ( defined $src && $src eq '' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delete or defined $src and $src eq "") 0 10 10
Condition33%2/6
$delete or defined $src and $src eq ""
l!l&&r!l&&!r
0010
defined $src and $src eq ""
!ll&&!rl&&r
0100
MC/DC0%0/3
$delete or defined $src and $src eq ""
$delete defined $src $src eq ""
Truth table25%1/4
A or B and C
A= $deleteB= defined $srcC= $src eq ""
ABCresult
1XX1
0111
00X0
0100
1640 0 ( my $n = $dst ) =~ s{\Arefs/(?:heads|tags)/}{};
1641 0 ▶ my $kind = $dst =~ m{\Arefs/tags/} ? 'tag' : $dst =~ m{\Arefs/heads/} ? 'head' : exists( ( $s->{refs}{tags} || {} )->{$n} ) && !exists( ( $s->{refs}{heads} || {} )->{$n} ) ? 'tag' : 'head';
Branch: 3 branches
BranchTrueFalseTotal
$dst =~ m[\Arefs/tags/] ? : 0 0 0
$dst =~ m[\Arefs/heads/] ? : 0 0 0
exists(($$s{'refs'}{'tags'} || {})->{$n}) && !exists(($$s{'refs'}{'heads'} || {})->{$n}) ? : 0 0 0
Condition0%0/7
exists(($$s{"refs"}{"tags"} || {})->{$n}) and not exists(($$s{"refs"}{"heads"} || {})->{$n})
!ll&&!rl&&r
000
$$s{'refs'}{'tags'} || {}
l!l
00
$$s{'refs'}{'heads'} || {}
l!l
00
MC/DC0%0/2
exists(($$s{"refs"}{"tags"} || {})->{$n}) and not exists(($$s{"refs"}{"heads"} || {})->{$n})
$$s{'refs'}{'tags'} $$s{'refs'}{'heads'}
Truth table0%0/3
A and not(B)
A= $$s{'refs'}{'tags'}B= $$s{'refs'}{'heads'}
ABresult
0X0
110
101
1642 0 push @specs, [ undef, $n, $kind, $n, 1 ];
1643 0 next;
1644 }
1645 10 ▶ if ( ( $r->{refs}{tags} || {} )->{$src} && !exists( ( $r->{refs}{heads} || {} )->{$src} ) ) { push @specs, [ $r->{refs}{tags}{$src}{commit}, $dst =~ s{\Arefs/tags/}{}r, 'tag', $src, $f ]; next }
Branch: 1 branch
BranchTrueFalseTotal
if (($$r{"refs"}{"tags"} || {})->{$src} and not exists(($$r{"refs"}{"heads"} || {})->{$src})) 1 9 10
Condition57%4/7
($$r{"refs"}{"tags"} || {})->{$src} and not exists(($$r{"refs"}{"heads"} || {})->{$src})
!ll&&!rl&&r
901
$$r{'refs'}{'tags'} || {}
l!l
100
$$r{'refs'}{'heads'} || {}
l!l
10
MC/DC0%0/2
($$r{"refs"}{"tags"} || {})->{$src} and not exists(($$r{"refs"}{"heads"} || {})->{$src})
$$r{'refs'}{'tags'} $$r{'refs'}{'heads'}
Truth table33%1/3
A and not(B)
A= $$r{'refs'}{'tags'}B= $$r{'refs'}{'heads'}
ABresult
0X0
110
101
1646 9 ▶ my $id = _rev( $r, $src ) // return ( "error: src refspec $src does not match any\nerror: failed to push some refs to '$rm->{url}'", 0 );
Condition50%1/2
_rev($r, $src) // (return qq[error: src refspec $src does not match any\nerror: failed to push some refs to '$$rm{"url"}'], 0)
l!l
90
MC/DC0%0/1
_rev($r, $src) // (return qq[error: src refspec $src does not match any\nerror: failed to push some refs to '$$rm{"url"}'], 0)
_rev($r, $src)
Truth table50%1/2
A
A= _rev($r, $src)
Aresult
11
00
1647 9 push @specs, [ $id, $dst =~ s{\Arefs/heads/}{}r, 'head', $src, $f ];
1648 }
1649 10 ▶ if ( $tags || $follow ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tags or $follow) 0 10 10
Condition33%1/3
$tags or $follow
l!l&&r!l&&!r
0010
MC/DC0%0/2
$tags or $follow
$tags $follow
Truth table33%1/3
A or B
A= $tagsB= $follow
ABresult
1X1
011
000
1650 0 ▶ for my $tg ( sort keys %{ $r->{refs}{tags} || {} } ) {
Condition0%0/2
$$r{'refs'}{'tags'} || {}
l!l
00
MC/DC0%0/1
$$r{'refs'}{'tags'} || {}
$$r{'refs'}{'tags'}
Truth table0%0/2
A
A= $$r{'refs'}{'tags'}
Aresult
11
00
1651 0 ▶ next if $follow && !$tags && !$r->{refs}{tags}{$tg}{annotated};
Branch: 1 branch
BranchTrueFalseTotal
if $follow and not $tags and not $$r{"refs"}{"tags"}{$tg}{"annotated"} 0 0 0
Condition0%0/6
$follow and not $tags and not $$r{"refs"}{"tags"}{$tg}{"annotated"}
!ll&&!rl&&r
000
$follow and not $tags
!ll&&!rl&&r
000
MC/DC0%0/3
$follow and not $tags and not $$r{"refs"}{"tags"}{$tg}{"annotated"}
$follow not $tags not $$r{"refs"}{"tags"}{$tg}{"annotated"}
Truth table0%0/4
A and not(B) and not(C)
A= $followB= not $tagsC= not $$r{"refs"}{"tags"}{$tg}{"annotated"}
ABCresult
0XX0
10X0
1100
1111
1652 0 ▶ next if grep { $_->[2] eq 'tag' && $_->[1] eq $tg } @specs;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$$_[2] eq "tag" and $$_[1] eq $tg;} @specs 0 0 0
Condition0%0/3
$$_[2] eq 'tag' && $$_[1] eq $tg
!ll&&!rl&&r
000
MC/DC0%0/2
$$_[2] eq 'tag' && $$_[1] eq $tg
$$_[2] eq 'tag' $$_[1] eq $tg
Truth table0%0/3
A && B
A= $$_[2] eq 'tag'B= $$_[1] eq $tg
ABresult
0X0
100
111
1653 0 push @specs, [ $r->{refs}{tags}{$tg}{commit}, $tg, 'tag', $tg, 0 ];
1654 }
1655 }
1656 10 my @out = ("To $rm->{url}");
1657 10 my $fail = 0;
1658 10 my $hook_msg;
1659 10 for my $sp (@specs) {
1660 10 my ( $id, $ref, $kind, $name, $f ) = @$sp;
1661 10 ▶ my $cur = $kind eq 'tag' ? ( ( $s->{refs}{tags} || {} )->{$ref} || {} )->{commit} : ( $s->{refs}{heads} || {} )->{$ref};
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'tag' ? : 1 9 10
Condition50%3/6
($$s{'refs'}{'tags'} || {})->{$ref} || {}
l!l
01
$$s{'refs'}{'tags'} || {}
l!l
10
$$s{'refs'}{'heads'} || {}
l!l
90
MC/DC0%0/1
($$s{'refs'}{'tags'} || {})->{$ref} || {}
$$s{'refs'}{'tags'}
MC/DC0%0/1
$$s{'refs'}{'heads'} || {}
$$s{'refs'}{'heads'}
Truth table50%1/2
A
A= $$s{'refs'}{'tags'}
Aresult
11
00
Truth table50%1/2
A
A= $$s{'refs'}{'heads'}
Aresult
11
00
1662 10 ▶ if ( !defined $id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 0 10 10
1663 0 ▶ if ( !defined $cur ) { push @out, " ! [remote rejected] $ref (not found)"; $fail = 1; next }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cur) 0 0 0
1664 0 ▶ if ( $kind eq 'head' && exists( ( $s->{protected} || {} )->{$ref} ) ) { push @out, " ! [remote rejected] $ref (protected branch)"; $hook_msg //= "remote: \nremote: Forgejo: branch $ref is protected from deletion"; $fail = 1; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "head" and exists(($$s{"protected"} || {})->{$ref})) 0 0 0
Condition0%0/7
$kind eq "head" and exists(($$s{"protected"} || {})->{$ref})
!ll&&!rl&&r
000
$$s{'protected'} || {}
l!l
00
$hook_msg //= "remote: \nremote: Forgejo: branch $ref is protected from deletion"
l!l
00
MC/DC0%0/2
$kind eq "head" and exists(($$s{"protected"} || {})->{$ref})
$kind eq "head" $$s{'protected'}
MC/DC0%0/1
$hook_msg //= "remote: \nremote: Forgejo: branch $ref is protected from deletion"
$hook_msg
Truth table0%0/3
A and B
A= $kind eq "head"B= $$s{'protected'}
ABresult
0X0
100
111
Truth table0%0/2
A
A= $hook_msg
Aresult
11
00
1665 0 ▶ next if $dry;
Branch: 1 branch
BranchTrueFalseTotal
if $dry 0 0 0
1666 0 ▶ if ( $kind eq 'tag' ) { delete $s->{refs}{tags}{$ref} } else { delete $s->{refs}{heads}{$ref}; delete $r->{refs}{remotes}{"$remote/$ref"} }
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq 'tag') { } 0 0 0
1667 0 push @out, " - [deleted] $ref";
1668 0 next;
1669 }
1670 0 ▶ if ( defined $cur && $cur eq $id && !( $kind eq 'tag' && $r->{refs}{tags}{$name}{annotated} && !( $s->{refs}{tags}{$ref} || {} )->{annotated} ) ) { push @out, " = [up to date] $name -> $ref" if @p; next }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $cur and $cur eq $id and not $kind eq "tag" && $$r{"refs"}{"tags"}{$name}{"annotated"} && !($$s{"refs"}{"tags"}{$ref} || {})->{"annotated"}) 0 10 10
if @p 0 0 0
Condition21%3/14
defined $cur and $cur eq $id and not $kind eq "tag" && $$r{"refs"}{"tags"}{$name}{"annotated"} && !($$s{"refs"}{"tags"}{$ref} || {})->{"annotated"}
!ll&&!rl&&r
1000
defined $cur and $cur eq $id
!ll&&!rl&&r
190
$kind eq 'tag' && $$r{'refs'}{'tags'}{$name}{'annotated'} && !($$s{'refs'}{'tags'}{$ref} || {})->{'annotated'}
!ll&&!rl&&r
000
$kind eq "tag" and $$r{"refs"}{"tags"}{$name}{"annotated"}
!ll&&!rl&&r
000
$$s{'refs'}{'tags'}{$ref} || {}
l!l
00
MC/DC0%0/5
defined $cur and $cur eq $id and not $kind eq "tag" && $$r{"refs"}{"tags"}{$name}{"annotated"} && !($$s{"refs"}{"tags"}{$ref} || {})->{"annotated"}
defined $cur $cur eq $id $kind eq "tag" $$r{"refs"}{"tags"}{$name}{"annotated"} $$s{'refs'}{'tags'}{$ref}
Truth table33%2/6
A and B and not(C and D && not(E))
A= defined $curB= $cur eq $idC= $kind eq "tag"D= $$r{"refs"}{"tags"}{$name}{"annotated"}E= $$s{'refs'}{'tags'}{$ref}
ABCDEresult
0XXXX0
10XXX0
111100
110XX1
1110X1
111111
1671 10 ▶ my $known = defined $cur ? exists $r->{commits}{$cur} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $cur ? : 9 1 10
1672 10 ▶ my $ff = !defined $cur || $known && _ancestors( $r, $id )->{$cur};
Condition83%5/6
!defined($cur) || $known && _ancestors($r, $id)->{$cur}
l!l&&r!l&&!r
163
$known and _ancestors($r, $id)->{$cur}
!ll&&!rl&&r
306
MC/DC66%2/3
!defined($cur) || $known && _ancestors($r, $id)->{$cur}
!defined($cur) $known _ancestors($r, $id)->{$cur}
Truth table75%3/4
not(A) || B and C
A= !defined($cur)B= $knownC= _ancestors($r, $id)->{$cur}
ABCresult
1XX1
0111
00X0
0100
1673 0 ▶ if ( $kind eq 'tag' && defined $cur && !$force && !$f ) { push @out, " ! [rejected] $name -> $ref (already exists)"; $fail = 1; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "tag" and defined $cur and not $force and not $f) 0 10 10
Condition44%4/9
$kind eq "tag" and defined $cur and not $force and not $f
!ll&&!rl&&r
1000
$kind eq "tag" and defined $cur and not $force
!ll&&!rl&&r
1000
$kind eq "tag" and defined $cur
!ll&&!rl&&r
910
MC/DC0%0/4
$kind eq "tag" and defined $cur and not $force and not $f
$kind eq "tag" defined $cur not $force not $f
Truth table40%2/5
A and B and not(C) and not(D)
A= $kind eq "tag"B= defined $curC= not $forceD= not $f
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1674 10 ▶ if ( !$ff && !$force && !$f ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ff or $force or $f) 1 9 10
Condition83%5/6
$ff or $force or $f
l!l&&r!l&&!r
901
$ff or $force
l!l&&r!l&&!r
721
MC/DC66%2/3
$ff or $force or $f
$ff $force $f
Truth table75%3/4
A or B or C
A= $ffB= $forceC= $f
ABCresult
1XX1
01X1
0011
0000
1675 1 ▶ my $lease_ok = $lease && defined( ( $r->{refs}{remotes} || {} )->{"$remote/$ref"} ) && $r->{refs}{remotes}{"$remote/$ref"} eq $cur;
Condition25%2/8
$lease && defined(($$r{'refs'}{'remotes'} || {})->{"$remote/$ref"}) && $$r{'refs'}{'remotes'}{"$remote/$ref"} eq $cur
!ll&&!rl&&r
100
$lease and defined(($$r{"refs"}{"remotes"} || {})->{"$remote/$ref"})
!ll&&!rl&&r
100
$$r{'refs'}{'remotes'} || {}
l!l
00
MC/DC0%0/3
$lease && defined(($$r{'refs'}{'remotes'} || {})->{"$remote/$ref"}) && $$r{'refs'}{'remotes'}{"$remote/$ref"} eq $cur
$lease $$r{'refs'}{'remotes'} $$r{'refs'}{'remotes'}{"$remote/$ref"} eq $cur
Truth table25%1/4
A and B && C
A= $leaseB= $$r{'refs'}{'remotes'}C= $$r{'refs'}{'remotes'}{"$remote/$ref"} eq $cur
ABCresult
0XX0
10X0
1100
1111
1676 1 ▶ unless ($lease_ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($lease_ok) 1 0 1
1677 1 ▶ push @out, " ! [" . ( $lease ? 'rejected' : 'rejected' ) . "] $name -> $ref " . ( $lease ? '(stale info)' : $known ? '(non-fast-forward)' : '(fetch first)' );
Branch: 3 branches
BranchTrueFalseTotal
$lease ? : 0 1 1
$lease ? : 0 1 1
$known ? : 0 1 1
1678 1 $fail = 2;
1679 1 next;
1680 }
1681 }
1682 9 ▶ if ( !$ff && $kind eq 'head' && exists( ( $s->{protected} || {} )->{$ref} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ff and $kind eq "head" and exists(($$s{"protected"} || {})->{$ref})) 1 8 9
Condition87%7/8
not $ff and $kind eq "head" and exists(($$s{"protected"} || {})->{$ref})
!ll&&!rl&&r
711
not $ff and $kind eq "head"
!ll&&!rl&&r
702
$$s{'protected'} || {}
l!l
11
MC/DC66%2/3
not $ff and $kind eq "head" and exists(($$s{"protected"} || {})->{$ref})
not $ff $kind eq "head" $$s{'protected'}
Truth table75%3/4
not(A) and B and C
A= not $ffB= $kind eq "head"C= $$s{'protected'}
ABCresult
0XX0
10X0
1100
1111
1683 1 push @out, " ! [remote rejected] $name -> $ref (pre-receive hook declined)";
1684 1 ▶ $hook_msg //= "remote: \nremote: Forgejo: branch $ref is protected from force push";
Condition50%1/2
$hook_msg //= "remote: \nremote: Forgejo: branch $ref is protected from force push"
l!l
01
MC/DC0%0/1
$hook_msg //= "remote: \nremote: Forgejo: branch $ref is protected from force push"
$hook_msg
Truth table50%1/2
A
A= $hook_msg
Aresult
11
00
1685 1 $fail = 1;
1686 1 next;
1687 }
1688 8 ▶ my $prot = ( $s->{protected} || {} )->{$ref};
Condition100%2/2
$$s{'protected'} || {}
l!l
71
MC/DC100%1/1
$$s{'protected'} || {}
$$s{'protected'}
Truth table100%2/2
A
A= $$s{'protected'}
Aresult
11
00
1689 8 ▶ if ( $kind eq 'head' && ref $prot eq 'HASH' && exists $prot->{push} && !$prot->{push} ) { # nur ueber Pull-Request
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "head" and ref $prot eq "HASH" and exists $$prot{"push"} and not $$prot{"push"}) 0 8 8
Condition66%6/9
$kind eq "head" and ref $prot eq "HASH" and exists $$prot{"push"} and not $$prot{"push"}
!ll&&!rl&&r
800
$kind eq "head" and ref $prot eq "HASH" and exists $$prot{"push"}
!ll&&!rl&&r
260
$kind eq "head" and ref $prot eq "HASH"
!ll&&!rl&&r
116
MC/DC0%0/4
$kind eq "head" and ref $prot eq "HASH" and exists $$prot{"push"} and not $$prot{"push"}
$kind eq "head" ref $prot eq "HASH" exists $$prot{"push"} not $$prot{"push"}
Truth table60%3/5
A and B and C and not(D)
A= $kind eq "head"B= ref $prot eq "HASH"C= exists $$prot{"push"}D= not $$prot{"push"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1690 0 push @out, " ! [remote rejected] $name -> $ref (pre-receive hook declined)";
1691 0 ▶ $hook_msg //= "remote: \nremote: Forgejo: Not allowed to push to protected branch $ref";
Condition0%0/2
$hook_msg //= "remote: \nremote: Forgejo: Not allowed to push to protected branch $ref"
l!l
00
MC/DC0%0/1
$hook_msg //= "remote: \nremote: Forgejo: Not allowed to push to protected branch $ref"
$hook_msg
Truth table0%0/2
A
A= $hook_msg
Aresult
11
00
1692 0 $fail = 1;
1693 0 next;
1694 }
1695 # neue Commits fuer die Hook-Regeln
1696 8 my @new = grep { !$s->{commits}{$_} } _range( $r, undef, $id );
1697 8 local $s->{_new} = { map { $_ => $r->{commits}{$_} } @new };
1698 8 ▶ if ( defined( my $why = _policy( $srv, $s, \@new, $kind eq 'tag' ? "refs/tags/$ref" : "refs/heads/$ref" ) ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $why = _policy($srv, $s, \@new, $kind eq "tag" ? "refs/tags/$ref" : "refs/heads/$ref"))) 3 5 8
$kind eq 'tag' ? : 1 7 8
1699 3 push @out, " ! [remote rejected] $name -> $ref (pre-receive hook declined)";
1700 3 ▶ $hook_msg //= join "\n", map {"remote: $_"} split /\n/, $why;
Condition50%1/2
$hook_msg //= join("\n", map({"remote: $_";} split(/\n/, $why, 0)))
l!l
03
MC/DC0%0/1
$hook_msg //= join("\n", map({"remote: $_";} split(/\n/, $why, 0)))
$hook_msg
Truth table50%1/2
A
A= $hook_msg
Aresult
11
00
1701 3 $fail = 1;
1702 3 next;
1703 }
1704 5 ▶ next if $dry;
Branch: 1 branch
BranchTrueFalseTotal
if $dry 0 5 5
1705 5 ▶ $s->{commits}{$_} //= _clone( $r->{commits}{$_} ) for @new;
Condition33%1/3
$$s{"commits"}{$_} //= _clone($$r{"commits"}{$_})
l!l&&r!l&&!r
040
MC/DC0%0/2
$$s{"commits"}{$_} //= _clone($$r{"commits"}{$_})
$$s{"commits"}{$_} _clone($$r{"commits"}{$_})
Truth table33%1/3
A //= B
A= $$s{"commits"}{$_}B= _clone($$r{"commits"}{$_})
ABresult
1X1
011
000
1706 5 ▶ if ( $kind eq 'tag' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq 'tag') { } 1 4 5
1707 1 $s->{refs}{tags}{$ref} = _clone( $r->{refs}{tags}{$name} );
1708 1 push @out, sprintf( ' * [new tag] %s -> %s', $name, $ref );
1709 }
1710 else {
1711 4 $s->{refs}{heads}{$ref} = $id;
1712 4 $r->{refs}{remotes}{"$remote/$ref"} = $id;
1713 4 ▶ push @out, !defined $cur ? sprintf( ' * [new branch] %s -> %s', $name, $ref )
Branch: 2 branches
BranchTrueFalseTotal
!defined($cur) ? : 0 4 4
$ff ? : 3 1 4
1714 : $ff ? sprintf( ' %s..%s %s -> %s', _short($cur), _short($id), $name, $ref )
1715 : sprintf( ' + %s...%s %s -> %s (forced update)', _short($cur), _short($id), $name, $ref );
1716 4 $s->{pushes}++;
1717 }
1718 }
1719 10 ▶ if ($fail) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fail) 5 5 10
1720 5 ▶ unshift @out, $hook_msg if defined $hook_msg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $hook_msg 4 1 5
1721 5 push @out, "error: failed to push some refs to '$rm->{url}'";
1722 5 ▶ push @out, "hint: Updates were rejected because the remote contains work that you do not\nhint: have locally. This is usually caused by another repository pushing to\nhint: the same ref. If you want to integrate the remote changes, use\nhint: 'git pull' before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details." if $fail == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $fail == 2 1 4 5
1723 5 return ( join( "\n", @out ), 0, 1 );
1724 }
1725 5 ▶ push @out, "branch '$b' set up to track '$remote/$b'." if $setup && defined $b;
Branch: 1 branch
BranchTrueFalseTotal
if $setup and defined $b 0 5 5
Condition33%1/3
$setup and defined $b
!ll&&!rl&&r
500
MC/DC0%0/2
$setup and defined $b
$setup defined $b
Truth table33%1/3
A and B
A= $setupB= defined $b
ABresult
0X0
100
111
1726 5 view($s);
1727 5 ▶ return ( @out > 1 ? join( "\n", @out ) : 'Everything up-to-date', 1 );
Branch: 1 branch
BranchTrueFalseTotal
@out > 1 ? : 5 0 5
1728 }
1729  
1730  
1731 8 ▶sub view {
Subroutine view: called CC=6 SCAR=18.3
Pod documented
1732 8 my ($s) = @_;
1733 8 my %v;
1734 8 ▶ for my $b ( keys %{ $s->{refs}{heads} || {} } ) {
Condition50%1/2
$$s{'refs'}{'heads'} || {}
l!l
80
MC/DC0%0/1
$$s{'refs'}{'heads'} || {}
$$s{'refs'}{'heads'}
Truth table50%1/2
A
A= $$s{'refs'}{'heads'}
Aresult
11
00
1735 8 my $tip = $s->{refs}{heads}{$b};
1736 8 ▶ my $c = $s->{commits}{$tip} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $c = $$s{"commits"}{$tip} or next 8 0 8
1737 8 ▶ $v{$b} = { message => $c->{message}, author => $c->{author}, tree => _clone( $c->{tree} ), parents => scalar @{ $c->{parents} || [] },
Condition50%1/2
$$c{'parents'} || []
l!l
80
MC/DC0%0/1
$$c{'parents'} || []
$$c{'parents'}
Truth table50%1/2
A
A= $$c{'parents'}
Aresult
11
00
1738 8 ▶ log => [ map { my $x = $s->{commits}{$_}; +{ id => $_, message => $x->{message}, author => $x->{author}, parents => scalar @{ $x->{parents} || [] } } } reverse _range( $s, undef, $tip ) ] };
Condition50%1/2
$$x{'parents'} || []
l!l
290
MC/DC0%0/1
$$x{'parents'} || []
$$x{'parents'}
Truth table50%1/2
A
A= $$x{'parents'}
Aresult
11
00
1739 }
1740 8 $s->{view} = \%v;
1741 8 return;
1742 }
1743  
1744 # --- forgejo-runner -------------------------------------------------------------------------
1745  
1746  
1747 3 ▶sub runner {
Subroutine runner: called CC=50 SCAR=55.7
Pod documented
1748 3 my ( $dev, $av, $ctx, $cwd, $user ) = @_;
1749 3 my @a = @$av;
1750 3 my $usage = "A runner for Forgejo Actions\n\nUsage:\n forgejo-runner [flags]\n forgejo-runner [command]\n\nAvailable Commands:\n"
1751 . " cache-server Start a cache server for the cache action\n completion Generate the autocompletion script for the specified shell\n"
1752 . " create-runner-file Create a runner file using a shared secret used to pre-register the runner on the Forgejo instance\n"
1753 . " daemon Run as a runner daemon\n exec Run workflow locally.\n generate-config Generate an example config file\n"
1754 . " help Help about any command\n register Register a runner to the server\n\nFlags:\n -c, --config string config file path\n -h, --help help for forgejo-runner\n -v, --version version for forgejo-runner";
1755 3 ▶ my $verb = shift(@a) // return ( $usage, 1 );
Condition50%1/2
shift @a // (return $usage, 1)
l!l
30
MC/DC0%0/1
shift @a // (return $usage, 1)
shift @a
Truth table50%1/2
A
A= shift @a
Aresult
11
00
1756 3 ▶ return ( $usage, 1 ) if $verb eq '--help' || $verb eq '-h' || $verb eq 'help' && !@a;
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "--help" or $verb eq "-h" or $verb eq "help" and not @a 0 3 3
Condition33%3/9
$verb eq "--help" or $verb eq "-h" or $verb eq "help" and not @a
l!l&&r!l&&!r
003
$verb eq "--help" or $verb eq "-h"
l!l&&r!l&&!r
003
$verb eq "help" and not @a
!ll&&!rl&&r
300
MC/DC0%0/4
$verb eq "--help" or $verb eq "-h" or $verb eq "help" and not @a
$verb eq "--help" $verb eq "-h" $verb eq "help" not @a
Truth table20%1/5
A or B or C and not(D)
A= $verb eq "--help"B= $verb eq "-h"C= $verb eq "help"D= not @a
ABCDresult
1XXX1
01XX1
00111
000X0
00100
1757 return ( "Register a runner to the server\n\nUsage:\n forgejo-runner register [flags]\n\nFlags:\n -h, --help help for register\n --instance string Forgejo instance address\n"
1758 . " --labels string Runner tags, comma separated\n --name string Runner name\n --no-interactive Disable interactive mode\n"
1759 3 ▶ . " --token string Runner token\n\nGlobal Flags:\n -c, --config string config file path", 1 ) if $verb eq 'register' && grep { $_ eq '--help' || $_ eq '-h' } @a or $verb eq 'help' && ( $a[0] // '' ) eq 'register';
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "register" and grep {$_ eq "--help" or $_ eq "-h";} @a or $verb eq "help" and ($a[0] // "") eq "register" 0 3 3
Condition28%4/14
$verb eq "register" and grep {$_ eq "--help" or $_ eq "-h";} @a or $verb eq "help" and ($a[0] // "") eq "register"
l!l&&r!l&&!r
003
$verb eq "register" and grep {$_ eq "--help" or $_ eq "-h";} @a
!ll&&!rl&&r
030
$_ eq '--help' || $_ eq '-h'
l!l&&r!l&&!r
0023
$verb eq "help" and ($a[0] // "") eq "register"
!ll&&!rl&&r
300
$a[0] // ""
l!l
00
MC/DC0%0/4
$verb eq "register" and grep {$_ eq "--help" or $_ eq "-h";} @a or $verb eq "help" and ($a[0] // "") eq "register"
$verb eq "register" grep {$_ eq "--help" or $_ eq "-h";} @a $verb eq "help" $a[0]
MC/DC0%0/2
$_ eq '--help' || $_ eq '-h'
$_ eq '--help' $_ eq '-h'
Truth table14%1/7
A and B or C and D
A= $verb eq "register"B= grep {$_ eq "--help" or $_ eq "-h";} @aC= $verb eq "help"D= $a[0]
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
Truth table33%1/3
A || B
A= $_ eq '--help'B= $_ eq '-h'
ABresult
1X1
011
000
1760 3 ▶ return ( 'forgejo-runner version v3.5.1', 1 ) if $verb eq '--version' || $verb eq '-v' || $verb eq 'version';
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "--version" or $verb eq "-v" or $verb eq "version" 0 3 3
Condition33%2/6
$verb eq "--version" or $verb eq "-v" or $verb eq "version"
l!l&&r!l&&!r
003
$verb eq "--version" or $verb eq "-v"
l!l&&r!l&&!r
003
MC/DC0%0/3
$verb eq "--version" or $verb eq "-v" or $verb eq "version"
$verb eq "--version" $verb eq "-v" $verb eq "version"
Truth table25%1/4
A or B or C
A= $verb eq "--version"B= $verb eq "-v"C= $verb eq "version"
ABCresult
1XX1
01X1
0011
0000
1761 3 ▶ if ( $verb eq 'generate-config' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "generate-config") 0 3 3
1762 0 return ( "log:\n level: info\nrunner:\n file: .runner\n capacity: 1\n timeout: 3h\n labels: []\ncache:\n enabled: true\ncontainer:\n network: \"\"\n privileged: false\n docker_host: \"\"", 1 );
1763 }
1764 0 ▶ unless ( $verb eq 'register' ) { push @GAPS, "forgejo-runner $verb"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($verb eq "register") 0 3 3
1765 3 my %o;
1766 3 ▶ while (@a) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a) 13 3 16
1767 13 my $x = shift @a;
1768 0 ▶ if ( $x =~ /\A--(instance|token|name|labels)=(.*)\z/ ) { $o{$1} = $2 }
Branch: 4 branches
BranchTrueFalseTotal
if ($x =~ /\A--(instance|token|name|labels)=(.*)\z/) { } 0 13 13
elsif ($x =~ /\A--(instance|token|name|labels)\z/) { } 10 3 13
elsif ($x eq '--no-interactive') { } 3 0 3
elsif ($x eq '-c' or $x eq '--config') { } 0 0 0
1769 10 elsif ( $x =~ /\A--(instance|token|name|labels)\z/ ) { $o{$1} = shift @a }
1770 3 elsif ( $x eq '--no-interactive' ) { $o{ni} = 1 }
1771 0 ▶ elsif ( $x eq '-c' || $x eq '--config' ) { $o{config} = shift @a }
Condition0%0/3
$x eq "-c" or $x eq "--config"
l!l&&r!l&&!r
000
MC/DC0%0/2
$x eq "-c" or $x eq "--config"
$x eq "-c" $x eq "--config"
Truth table0%0/3
A or B
A= $x eq "-c"B= $x eq "--config"
ABresult
1X1
011
000
1772 0 else { return ( "Error: unknown flag: $x", 0 ) }
1773 }
1774 0 ▶ unless ( $o{ni} ) { push @GAPS, 'forgejo-runner register (interaktiv)'; return ( 'Error opening terminal: unknown.', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($o{"ni"}) 0 3 3
1775 3 ▶ return ( 'level=error msg="instance address is empty"', 0 ) unless length( $o{instance} // '' );
Branch: 1 branch
BranchTrueFalseTotal
unless length($o{"instance"} // "") 0 3 3
Condition50%1/2
$o{"instance"} // ""
l!l
30
MC/DC0%0/1
$o{"instance"} // ""
$o{"instance"}
Truth table50%1/2
A
A= $o{"instance"}
Aresult
11
00
1776 3 ▶ return ( 'level=error msg="token is empty"', 0 ) unless length( $o{token} // '' );
Branch: 1 branch
BranchTrueFalseTotal
unless length($o{"token"} // "") 0 3 3
Condition50%1/2
$o{"token"} // ""
l!l
30
MC/DC0%0/1
$o{"token"} // ""
$o{"token"}
Truth table50%1/2
A
A= $o{"token"}
Aresult
11
00
1777 3 ( my $want = $o{instance} ) =~ s{/+\z}{};
1778 3 my ($host) = $want =~ m{\Ahttps?://([^/:]+)};
1779 3 ▶ my ($srv) = grep { ( ( ( $ctx->{state}{$_} || {} )->{forgejo} || {} )->{root_url} // "\0" ) =~ m{\A\Q$want\E/?\z} } sort keys %{ $ctx->{state} || {} };
Condition75%6/8
(($$ctx{"state"}{$_} || {})->{"forgejo"} || {})->{"root_url"} // "\0"
l!l
36
($$ctx{'state'}{$_} || {})->{'forgejo'} || {}
l!l
36
$$ctx{'state'}{$_} || {}
l!l
90
$$ctx{'state'} || {}
l!l
30
MC/DC0%0/1
(($$ctx{"state"}{$_} || {})->{"forgejo"} || {})->{"root_url"} // "\0"
$$ctx{'state'}{$_}
MC/DC0%0/1
$$ctx{'state'} || {}
$$ctx{'state'}
Truth table50%1/2
A
A= $$ctx{'state'}{$_}
Aresult
11
00
Truth table50%1/2
A
A= $$ctx{'state'}
Aresult
11
00
1780 3 ▶ return ( qq{level=error msg="Cannot ping the Forgejo instance server" error="unavailable: dial tcp: lookup } . ( $host // $want ) . ' on 127.0.0.53:53: no such host"', 0 ) unless defined $srv;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $srv 0 3 3
Condition0%0/3
$host // $want
l!l&&r!l&&!r
000
MC/DC0%0/2
$host // $want
$host $want
Truth table0%0/3
A // B
A= $hostB= $want
ABresult
1X1
011
000
1781 3 my $fj = $ctx->{state}{$srv}{forgejo};
1782 return ( 'level=info msg="Registering runner, name=' . ( $o{name} // '' ) . ", instance=$o{instance}, labels=[" . ( $o{labels} // '' ) . "].\"\n"
1783 . 'level=fatal msg="Failed to register runner" error="unauthenticated: runner registration token not found"', 0 )
1784 3 ▶ unless grep { $_ eq $o{token} } @{ $fj->{runner_tokens} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $o{"token"};} @{$$fj{"runner_tokens"} or [];} 1 2 3
Condition50%3/6
$$fj{'runner_tokens'} || []
l!l
30
$o{"name"} // ""
l!l
10
$o{"labels"} // ""
l!l
01
MC/DC0%0/1
$$fj{'runner_tokens'} || []
$$fj{'runner_tokens'}
MC/DC0%0/1
$o{"name"} // ""
$o{"name"}
MC/DC0%0/1
$o{"labels"} // ""
$o{"labels"}
Truth table50%1/2
A
A= $$fj{'runner_tokens'}
Aresult
11
00
Truth table50%1/2
A
A= $o{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $o{"labels"}
Aresult
11
00
1785 2 ▶ my $name = $o{name} // $dev->{hostname} // 'runner';
Condition40%2/5
($o{"name"} // $$dev{"hostname"}) // "runner"
l!l
20
$o{"name"} // $$dev{"hostname"}
l!l&&r!l&&!r
200
MC/DC0%0/2
($o{"name"} // $$dev{"hostname"}) // "runner"
$o{"name"} $$dev{"hostname"}
Truth table33%1/3
A // B
A= $o{"name"}B= $$dev{"hostname"}
ABresult
1X1
011
000
1786 2 ▶ my @labels = grep {length} split /\s*,\s*/, $o{labels} // '';
Condition100%2/2
$o{"labels"} // ""
l!l
11
MC/DC100%1/1
$o{"labels"} // ""
$o{"labels"}
Truth table100%2/2
A
A= $o{"labels"}
Aresult
11
00
1787 2 ▶ my $id = 1 + scalar keys %{ $fj->{runners} || {} };
Condition100%2/2
$$fj{'runners'} || {}
l!l
11
MC/DC100%1/1
$$fj{'runners'} || {}
$$fj{'runners'}
Truth table100%2/2
A
A= $$fj{'runners'}
Aresult
11
00
1788 2 $fj->{runners}{$name} = { id => $id, labels => \@labels };
1789 2 my $uuid = join '-', unpack 'A8 A4 A4 A4 A12', Digest::SHA::sha1_hex( "$srv/$name/$id" );
1790 2 ▶ my $file = ( $cwd // ( ( $user // 'root' ) eq 'root' ? '/root' : ( ( ( $dev->{users} || {} )->{$user} || {} )->{home} // "/home/$user" ) ) ) . '/.runner';
Branch: 1 branch
BranchTrueFalseTotal
($user // 'root') eq 'root' ? : 0 0 0
Condition10%1/10
$cwd // (($user // "root") eq "root" ? "/root" : (($$dev{"users"} || {})->{$user} || {})->{"home"} // "/home/$user")
l!l
20
$user // "root"
l!l
00
(($$dev{"users"} || {})->{$user} || {})->{"home"} // "/home/$user"
l!l
00
($$dev{'users'} || {})->{$user} || {}
l!l
00
$$dev{'users'} || {}
l!l
00
MC/DC0%0/1
$cwd // (($user // "root") eq "root" ? "/root" : (($$dev{"users"} || {})->{$user} || {})->{"home"} // "/home/$user")
$cwd
MC/DC0%0/1
(($$dev{"users"} || {})->{$user} || {})->{"home"} // "/home/$user"
$$dev{'users'}
Truth table50%1/2
A
A= $cwd
Aresult
11
00
Truth table0%0/2
A
A= $$dev{'users'}
Aresult
11
00
1791 $dev->{files}{$file} = { content => JSON::MaybeXS->new( canonical => 1, pretty => 1 )->encode( {
1792 WARNING => 'This file is automatically generated by act-runner. Do not edit it manually unless you know what you are doing. Removing this file will cause act runner to re-register as a new runner.',
1793 2 ▶ id => $id, uuid => $uuid, name => $name, token => substr( Digest::SHA::sha1_hex("token/$uuid"), 0, 40 ), address => $o{instance}, labels => \@labels } ) =~ s{" : }{": }gr,
Condition100%4/4
$user // "root"
l!l
11
$user // "root"
l!l
11
MC/DC100%1/1
$user // "root"
$user
MC/DC100%1/1
$user // "root"
$user
Truth table100%2/2
A
A= $user
Aresult
11
00
Truth table100%2/2
A
A= $user
Aresult
11
00
1794 owner => $user // 'root', group => $user // 'root', mode => '0600' };
1795 2 return ( 'level=info msg="Registering runner, name=' . $name . ", instance=$o{instance}, labels=[" . join( ' ', @labels ) . "].\"\n"
1796 . 'level=debug msg="Successfully pinged the Forgejo instance server"' . "\n" . 'level=info msg="Runner registered successfully."', 1 );
1797 }
1798  
1799 2 1;
1800  
1801 __END__
« blib/lib/Langertha/Holmgang/Sim/Linux/Storage.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Postgres.pm »