git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avery Pennarun <apenwarr@gmail.com>
To: Eric Wong <normalperson@yhbt.net>, Adam Roben <aroben@apple.com>,
	Samuel Bronson <naesten@gmail.com>,
	B.Steinbrink@gmx.de, git@vger.kernel.org
Cc: Avery Pennarun <apenwarr@gmail.com>
Subject: [PATCH] Revert "git-svn: Speed up fetch"
Date: Sat, 28 Jun 2008 16:57:53 -0400	[thread overview]
Message-ID: <1214686673-28099-1-git-send-email-apenwarr@gmail.com> (raw)
In-Reply-To: <20080628194808.GA29908@atjola.homenet>

This reverts commit ffe256f9bac8a40ff751a9341a5869d98f72c285, because it
was causing errors of the form:

Checksum mismatch: trunk/.depend 16e748c219f9f95bf3d05c6b2af5444290bc8471
expected: 05fb5edb8c8057be006c7e913ae0c764
     got: 763b9a426c5bd61e0a85252459d37cfa
     
Note that the exact failing file and checksum seems to vary if you clear
the repository and try again.

Conflicts:

	git-svn.perl
---
Obviously it would be better to actually fix the bug here than the revert
the patch (because the patch really *does* make fetch go a lot faster), but
I don't know where to begin, and it's a pain to debug because of the
variability.

 git-svn.perl |   42 ++++++++++++++++++++++--------------------
 1 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 4c9c59b..a02bcf4 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4,7 +4,7 @@
 use warnings;
 use strict;
 use vars qw/	$AUTHOR $VERSION
-		$sha1 $sha1_short $_revision $_repository
+		$sha1 $sha1_short $_revision
 		$_q $_authors %users/;
 $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
 $VERSION = '@@GIT_VERSION@@';
@@ -223,7 +223,6 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 		}
 		$ENV{GIT_DIR} = $git_dir;
 	}
-	$_repository = Git->repository(Repository => $ENV{GIT_DIR});
 }
 
 my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
@@ -305,7 +304,6 @@ sub do_git_init_db {
 			}
 		}
 		command_noisy(@init_db);
-		$_repository = Git->repository(Repository => ".git");
 	}
 	my $set;
 	my $pfx = "svn-remote.$Git::SVN::default_repo_id";
@@ -322,7 +320,6 @@ sub init_subdir {
 	mkpath([$repo_path]) unless -d $repo_path;
 	chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";
 	$ENV{GIT_DIR} = '.git';
-	$_repository = Git->repository(Repository => $ENV{GIT_DIR});
 }
 
 sub cmd_clone {
@@ -3040,7 +3037,6 @@ use vars qw/@ISA/;
 use strict;
 use warnings;
 use Carp qw/croak/;
-use File::Temp qw/tempfile/;
 use IO::File qw//;
 
 # file baton members: path, mode_a, mode_b, pool, fh, blob, base
@@ -3196,9 +3192,14 @@ sub apply_textdelta {
 	my $base = IO::File->new_tmpfile;
 	$base->autoflush(1);
 	if ($fb->{blob}) {
-		print $base 'link ' if ($fb->{mode_a} == 120000);
-		my $size = $::_repository->cat_blob($fb->{blob}, $base);
-		die "Failed to read object $fb->{blob}" if ($size < 0);
+		defined (my $pid = fork) or croak $!;
+		if (!$pid) {
+			open STDOUT, '>&', $base or croak $!;
+			print STDOUT 'link ' if ($fb->{mode_a} == 120000);
+			exec qw/git-cat-file blob/, $fb->{blob} or croak $!;
+		}
+		waitpid $pid, 0;
+		croak $? if $?;
 
 		if (defined $exp) {
 			seek $base, 0, 0 or croak $!;
@@ -3239,18 +3240,14 @@ sub close_file {
 				sysseek($fh, 0, 0) or croak $!;
 			}
 		}
-
-		my ($tmp_fh, $tmp_filename) = File::Temp::tempfile(UNLINK => 1);
-		my $result;
-		while ($result = sysread($fh, my $string, 1024)) {
-			syswrite($tmp_fh, $string, $result);
+		defined(my $pid = open my $out,'-|') or die "Can't fork: $!\n";
+		if (!$pid) {
+			open STDIN, '<&', $fh or croak $!;
+			exec qw/git-hash-object -w --stdin/ or croak $!;
 		}
-		defined $result or croak $!;
-		close $tmp_fh or croak $!;
-
+		chomp($hash = do { local $/; <$out> });
+		close $out or croak $!;
 		close $fh or croak $!;
-
-		$hash = $::_repository->hash_and_insert_object($tmp_filename);
 		$hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n";
 		close $fb->{base} or croak $!;
 	} else {
@@ -3576,8 +3573,13 @@ sub chg_file {
 	} elsif ($m->{mode_a} =~ /^120/ && $m->{mode_b} !~ /^120/) {
 		$self->change_file_prop($fbat,'svn:special',undef);
 	}
-	my $size = $::_repository->cat_blob($m->{sha1_b}, $fh);
-	croak "Failed to read object $m->{sha1_b}" if ($size < 0);
+	defined(my $pid = fork) or croak $!;
+	if (!$pid) {
+		open STDOUT, '>&', $fh or croak $!;
+		exec qw/git-cat-file blob/, $m->{sha1_b} or croak $!;
+	}
+	waitpid $pid, 0;
+	croak $? if $?;
 	$fh->flush == 0 or croak $!;
 	seek $fh, 0, 0 or croak $!;
 
-- 
1.5.4.3

  reply	other threads:[~2008-06-28 20:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-28 19:48 git-svn messed up import, badly Björn Steinbrink
2008-06-28 20:57 ` Avery Pennarun [this message]
2008-06-28 23:33   ` [PATCH v2] git-svn: avoid filling up the disk with temp files Avery Pennarun
2008-06-29  0:58     ` Björn Steinbrink
2008-06-29  1:21       ` [PATCH] git cat-file: Fix memory leak in batch mode Björn Steinbrink
2008-06-29  3:36         ` Junio C Hamano
2008-06-29 11:54           ` Björn Steinbrink
2008-06-29  2:24       ` [PATCH v2] git-svn: avoid filling up the disk with temp files Björn Steinbrink
2008-06-29  2:38     ` Eric Wong
2008-06-28 23:51   ` [PATCH] Revert "git-svn: Speed up fetch" Mikael Magnusson
2008-06-28 23:58     ` Avery Pennarun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1214686673-28099-1-git-send-email-apenwarr@gmail.com \
    --to=apenwarr@gmail.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=aroben@apple.com \
    --cc=git@vger.kernel.org \
    --cc=naesten@gmail.com \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).