git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git svn mkdirs ignores compressed unhandled.log files

From
EWEric Wong <normalperson@yhbt.net>
Date
Dec 17, 2009, 20:08 UTC
Message-ID
<20091217200852.GA5797@dcvr.yhbt.net>
In-Reply-To
<8BB233FB-4269-4B14-8703-A4FF1E25FB0D@gmail.com>
Robert Zeh <robert.a.zeh@gmail.com> wrote:
> It looks like there is a conflict between git svn gc and git svn
> mkdirs.  The git svn mkdirs command only looks at unhandled.log files.
> Shouldn't it also look at any compressed unhandled.log files too?
Hi Robert,
Yes, an oversight. Does this patch work for you? (Highly untested)

Would you mind writing a test case, been a bit busy with other stuff. Thanks.

diff --git a/git-svn.perl b/git-svn.perl
index a4b052c..d362de7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2740,21 +2740,44 @@ sub do_fetch {
 
 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) {
-- 
Eric Wong
Previous: Robert ZehNext: Eric Wong
Message 2 of 7 in “git svn mkdirs ignores compressed unhandled.log files”
  1. Robert ZehDec 17, 2009
  2. Eric WongDec 17, 2009
  3. git svn: make empty directory creation gc-awareEric Wong, Dec 19, 2009
  4. Junio C HamanoDec 20, 2009
  5. Eric WongDec 20, 2009
  6. 2/1 t9146: use 'svn_cmd' wrapperEric Wong, Dec 20, 2009
  7. Robert ZehDec 23, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.