perl / Git / IndexInfo.pmon commit Merge branch 'jh/status-no-ahead-behind' (4094e47)
   1package Git::IndexInfo;
   2use strict;
   3use warnings;
   4use Git qw/command_input_pipe command_close_pipe/;
   5
   6sub 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
  12sub 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
  20sub 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
  28sub DESTROY {
  29        my ($self) = @_;
  30        command_close_pipe($self->{gui}, $self->{ctx});
  31}
  32
  331;