Git/IndexInfo.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 39 SCAR 24.8
CC
3
Cov
0%
remove
6.0
update
6.0
new
2.0
CRAP 12.0
1 package Git::IndexInfo;
2 use strict;
3 use warnings;
4 use Git qw/command_input_pipe command_close_pipe/;
5  
6 sub new {
7 my ($class) = @_;
8 my ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/);
9 bless { gui => $gui, ctx => $ctx, nr => 0}, $class;
10 }
11  
12 sub remove {
13 my ($self, $path) = @_;
14 if (print { $self->{gui} } '0 ', 0 x 40, "\t", $path, "\0") {
15 return ++$self->{nr};
16 }
17 undef;
18 }
19  
20 sub update {
21 my ($self, $mode, $hash, $path) = @_;
22 if (print { $self->{gui} } $mode, ' ', $hash, "\t", $path, "\0") {
23 return ++$self->{nr};
24 }
25 undef;
26 }
27  
28 sub DESTROY {
29 my ($self) = @_;
30 command_close_pipe($self->{gui}, $self->{ctx});
31 }
32  
33 1;