+sub copy_subdir($$$$$$) {
+ # Somebody copied a whole subdirectory.
+ # We need to find the index entries from the old version which the
+ # SVN log entry points to, and add them to the new place.
+
+ my($newrev,$newbranch,$path,$oldpath,$rev,$new) = @_;
+ my($branch,$srcpath) = split_path($rev,$oldpath);
+
+ my $gitrev = $branches{$branch}{$rev};
+ unless($gitrev) {
+ print STDERR "$newrev:$newbranch: could not find $oldpath \@ $rev\n";
+ return;
+ }
+ print "$newrev:$newbranch:$path: copying from $branch:$srcpath @ $rev\n" if $opt_v;
+ $srcpath =~ s#/*$#/#;
+ open my $f,"-|","git-ls-tree","-r","-z",$gitrev,$srcpath;
+ local $/ = "\0";
+ while(<$f>) {
+ chomp;
+ my($m,$p) = split(/\t/,$_,2);
+ my($mode,$type,$sha1) = split(/ /,$m);
+ next if $type ne "blob";
+ $p = substr($p,length($srcpath)-1);
+ print "... found $path$p ...\n" if $opt_v;
+ push(@$new,[$mode,$sha1,$path.$p]);
+ }
+ close($f) or
+ print STDERR "$newrev:$newbranch: could not list files in $oldpath \@ $rev\n";
+}
+