summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 94058a9)
raw | patch | inline | side by side (parent: 94058a9)
author | Eric Wong <normalperson@yhbt.net> | |
Sat, 19 Dec 2009 21:49:00 +0000 (13:49 -0800) | ||
committer | Eric Wong <normalperson@yhbt.net> | |
Sat, 19 Dec 2009 22:07:24 +0000 (14:07 -0800) |
The "git svn gc" command creates and appends to unhandled.log.gz
files which should be parsed before the uncompressed
unhandled.log files.
Reported-by: Robert Zeh
Signed-off-by: Eric Wong <normalperson@yhbt.net>
files which should be parsed before the uncompressed
unhandled.log files.
Reported-by: Robert Zeh
Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl | patch | blob | history | |
t/t9146-git-svn-empty-dirs.sh | patch | blob | history |
diff --git a/git-svn.perl b/git-svn.perl
index a4b052c71e9a3b7da1ac95aaf11a206152f8e1a4..d362de7364e1e67808846cc891b706dc8029bb20 100755 (executable)
--- a/git-svn.perl
+++ b/git-svn.perl
sub mkemptydirs {
my ($self, $r) = @_;
+
+ sub scan {
+ my ($r, $empty_dirs, $line) = @_;
+ if (defined $r && $line =~ /^r(\d+)$/) {
+ return 0 if $1 > $r;
+ } elsif ($line =~ /^ \+empty_dir: (.+)$/) {
+ $empty_dirs->{$1} = 1;
+ } elsif ($line =~ /^ \-empty_dir: (.+)$/) {
+ my @d = grep {m[^\Q$1\E(/|$)]} (keys %$empty_dirs);
+ delete @$empty_dirs{@d};
+ }
+ 1; # continue
+ };
+
my %empty_dirs = ();
+ my $gz_file = "$self->{dir}/unhandled.log.gz";
+ if (-f $gz_file) {
+ if (!$can_compress) {
+ warn "Compress::Zlib could not be found; ",
+ "empty directories in $gz_file will not be read\n";
+ } else {
+ my $gz = Compress::Zlib::gzopen($gz_file, "rb") or
+ die "Unable to open $gz_file: $!\n";
+ my $line;
+ while ($gz->gzreadline($line) > 0) {
+ scan($r, \%empty_dirs, $line) or last;
+ }
+ $gz->gzclose;
+ }
+ }
- open my $fh, '<', "$self->{dir}/unhandled.log" or return;
- binmode $fh or croak "binmode: $!";
- while (<$fh>) {
- if (defined $r && /^r(\d+)$/) {
- last if $1 > $r;
- } elsif (/^ \+empty_dir: (.+)$/) {
- $empty_dirs{$1} = 1;
- } elsif (/^ \-empty_dir: (.+)$/) {
- my @d = grep {m[^\Q$1\E(/|$)]} (keys %empty_dirs);
- delete @empty_dirs{@d};
+ if (open my $fh, '<', "$self->{dir}/unhandled.log") {
+ binmode $fh or croak "binmode: $!";
+ while (<$fh>) {
+ scan($r, \%empty_dirs, $_) or last;
}
+ close $fh;
}
- close $fh;
my $strip = qr/\A\Q$self->{path}\E(?:\/|$)/;
foreach my $d (sort keys %empty_dirs) {
index 9b8d0463fad6dbc2fb3c56c94033269a11404f35..3f2d7198270f0ad4bcb4d1082a0b452e37a53f05 100755 (executable)
test ! -e removed/d
'
+unhandled=.git/svn/refs/remotes/git-svn/unhandled.log
+test_expect_success 'git svn gc-ed files work' '
+ (
+ cd removed &&
+ git svn gc &&
+ : Compress::Zlib may not be available &&
+ if test -f "$unhandled".gz
+ then
+ svn mkdir -m gz "$svnrepo"/gz &&
+ git reset --hard $(git rev-list HEAD | tail -1) &&
+ git svn rebase &&
+ test -f "$unhandled".gz &&
+ test -f "$unhandled" &&
+ for i in a b c "weird file name" gz "! !"
+ do
+ if ! test -d "$i"
+ then
+ echo >&2 "$i does not exist"
+ exit 1
+ fi
+ done
+ fi
+ )
+'
test_done