- while(my($path,$action) = each %$changed_paths) {
- if ($action->[0] eq "A") {
- my $f = get_file($revision,$branch,$path);
- push(@new,$f) if $f;
- } elsif ($action->[0] eq "D") {
- push(@old,$path);
- } elsif ($action->[0] eq "M") {
- my $f = get_file($revision,$branch,$path);
- push(@new,$f) if $f;
- } elsif ($action->[0] eq "R") {
- # refer to a file/tree in an earlier commit
- push(@old,$path); # remove any old stuff
-
- # ... and add any new stuff
- my($b,$p) = split_path($revision,$action->[1]);
- open my $F,"-|","git-ls-tree","-r","-z", $branches{$b}{$action->[2]}, $p;
+ my $cid;
+ if($tag and not %$changed_paths) {
+ $cid = $rev;
+ } else {
+ while(my($path,$action) = each %$changed_paths) {
+ if ($action->[0] eq "A") {
+ my $f = get_file($revision,$branch,$path);
+ push(@new,$f) if $f;
+ } elsif ($action->[0] eq "D") {
+ push(@old,$path);
+ } elsif ($action->[0] eq "M") {
+ my $f = get_file($revision,$branch,$path);
+ push(@new,$f) if $f;
+ } elsif ($action->[0] eq "R") {
+ # refer to a file/tree in an earlier commit
+ push(@old,$path); # remove any old stuff
+
+ # ... and add any new stuff
+ my($b,$p) = split_path($revision,$action->[1]);
+ open my $F,"-|","git-ls-tree","-r","-z", $branches{$b}{$action->[2]}, $p;
+ local $/ = '\0';
+ while(<$F>) {
+ chomp;
+ my($m,$p) = split(/\t/,$_,2);
+ my($mode,$type,$sha1) = split(/ /,$m);
+ next if $type ne "blob";
+ push(@new,[$mode,$sha1,$p]);
+ }
+ } else {
+ die "$revision: unknown action '".$action->[0]."' for $path\n";
+ }
+ }
+
+ if(@old) {
+ open my $F, "-|", "git-ls-files", "-z", @old or die $!;
+ @old = ();