git-svn: make --repack work consistently between fetch and multi-fetch
Since fetch reforks itself at most every 1000 revisions, we need to update the counter in the parent process to have a working count if we set our repack interval to be > ~1000 revisions. multi-fetch has always done this correctly because of an extra process; now fetch uses the extra process; as well. While we're at it, only compile the $sha1 regex that checks for repacking once. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Eric Wong committed
Jan 4, 2007 at 18:09 UTC
2a3240beaad73dd86d9220c8a8a6e76c6d034a57
1 file changed
+6
-4
git-svn.perl
+6
-4
@@ -102,7 +102,7 @@ my %cmt_opts = ( 'edit|e' => \$_edit,
102
);
103
104
my %cmd = (
105
- fetch => [ \&fetch, "Download new revisions from SVN",
105
+ fetch => [ \&cmd_fetch, "Download new revisions from SVN",
106
{ 'revision|r=s' => \$_revision, %fc_opts } ],
107
init => [ \&init, "Initialize a repo for tracking" .
108
" (requires URL argument)",
@@ -293,6 +293,10 @@ sub init {
293
setup_git_svn();
294
}
295
296
+sub cmd_fetch {
297
+ fetch_child_id($GIT_SVN, @_);
298
+}
299
+
300
sub fetch {
301
check_upgrade_needed();
302
$SVN_URL ||= file_to_s("$GIT_SVN_DIR/info/url");
@@ -836,7 +840,6 @@ sub fetch_child_id {
840
my $ref = "$GIT_DIR/refs/remotes/$id";
841
defined(my $pid = open my $fh, '-|') or croak $!;
842
if (!$pid) {
839
- $_repack = undef;
843
$GIT_SVN = $ENV{GIT_SVN_ID} = $id;
844
init_vars();
845
fetch(@_);
@@ -844,7 +847,7 @@ sub fetch_child_id {
847
}
848
while (<$fh>) {
849
print $_;
847
- check_repack() if (/^r\d+ = $sha1/);
850
+ check_repack() if (/^r\d+ = $sha1/o);
851
}
852
close $fh or croak $?;
853
}
@@ -1407,7 +1410,6 @@ sub git_commit {
1410
1411
# this output is read via pipe, do not change:
1412
print "r$log_msg->{revision} = $commit\n";
1410
- check_repack();
1413
return $commit;
1414
}
1415