git-svn: Introduce SVN::Git::Editor::_chg_file_get_blob
Signed-off-by: Florian Weimer <fw@deneb.enyo.de> Acked-by: Eric Wong <normalperson@yhbt.net>
Florian Weimer committed
Aug 31, 2008 at 17:45 UTC
214a34d22ec59ec7e1166772f06ecf8799f96c96
1 file changed
+19
-12
git-svn.perl
+19
-12
@@ -3663,28 +3663,35 @@ sub change_file_prop {
3663
$self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
3664
}
3665
3666
-sub chg_file {
3667
- my ($self, $fbat, $m) = @_;
3668
- if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) {
3669
- $self->change_file_prop($fbat,'svn:executable','*');
3670
- } elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
3671
- $self->change_file_prop($fbat,'svn:executable',undef);
3672
- }
3673
- my $fh = Git::temp_acquire('git_blob');
3674
- if ($m->{mode_b} =~ /^120/) {
3666
+sub _chg_file_get_blob ($$$$) {
3667
+ my ($self, $fbat, $m, $which) = @_;
3668
+ my $fh = Git::temp_acquire("git_blob_$which");
3669
+ if ($m->{"mode_$which"} =~ /^120/) {
3670
print $fh 'link ' or croak $!;
3671
$self->change_file_prop($fbat,'svn:special','*');
3677
- } elsif ($m->{mode_a} =~ /^120/ && $m->{mode_b} !~ /^120/) {
3672
+ } elsif ($m->{mode_a} =~ /^120/ && $m->{"mode_$which"} !~ /^120/) {
3673
$self->change_file_prop($fbat,'svn:special',undef);
3674
}
3680
- my $size = $::_repository->cat_blob($m->{sha1_b}, $fh);
3681
- croak "Failed to read object $m->{sha1_b}" if ($size < 0);
3675
+ my $blob = $m->{"sha1_$which"};
3676
+ return ($fh,) if ($blob =~ /^0{40}$/);
3677
+ my $size = $::_repository->cat_blob($blob, $fh);
3678
+ croak "Failed to read object $blob" if ($size < 0);
3679
$fh->flush == 0 or croak $!;
3680
seek $fh, 0, 0 or croak $!;
3681
3682
my $exp = ::md5sum($fh);
3683
seek $fh, 0, 0 or croak $!;
3684
+ return ($fh, $exp);
3685
+}
3686
3687
+sub chg_file {
3688
+ my ($self, $fbat, $m) = @_;
3689
+ if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) {
3690
+ $self->change_file_prop($fbat,'svn:executable','*');
3691
+ } elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
3692
+ $self->change_file_prop($fbat,'svn:executable',undef);
3693
+ }
3694
+ my ($fh, $exp) = _chg_file_get_blob $self, $fbat, $m, 'b';
3695
my $pool = SVN::Pool->new;
3696
my $atd = $self->apply_textdelta($fbat, undef, $pool);
3697
my $got = SVN::TxDelta::send_stream($fh, @$atd, $pool);