Merge branch 'sg/httpd-test-unflake'
[git/git.git] / perl / Git / IndexInfo.pm
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;