threads / patch / 11855

patch, 2 partsgit-svn: Don't call git-repack anymore

Subject: [PATCH 1/2] git-svn: Don't call git-repack anymore

## tl;dr

3 messages between Feb 3, 2008 and Feb 3, 2008. Diffs are folded; open one to read it.

replies: 2people: 1as markdown or json

Karl Hasselström· Feb 3, 2008, 16:55 UTC · lore

[PATCH 0/2] "git svn" and "git gc --auto"

On 2008-01-21 14:48:28 -0800, Eric Wong wrote:
> Sorry for the latency[1], ack on both of Karl's patches for
> post-1.5.4.

So here they are again. There was a trivial merge conflict with Eric's fix, but otherwise they are unchanged.

---
Karl Hasselström (2):
      Let "git svn" run "git gc --auto" occasionally
      git-svn: Don't call git-repack anymore
 git-svn.perl |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Karl Hasselström· Feb 3, 2008, 16:56 UTC · re: Karl Hasselström · lore

In a moment, we'll start calling git-gc --auto instead, since it is a better fit to what we're trying to accomplish.

The command line options are still accepted, but don't have any effect, and we warn the user about that.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 git-svn.perl |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)
Show changes to git-svn.perl +3 −11
diff --git a/git-svn.perl b/git-svn.perl
index 75e97cc..074068c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1247,7 +1247,6 @@ use File::Path qw/mkpath/;
 use File::Copy qw/copy/;
 use IPC::Open3;
 
-my $_repack_nr;
 # properties that we do not log:
 my %SKIP_PROP;
 BEGIN {
@@ -1408,9 +1407,9 @@ sub read_all_remotes {
 }
 
 sub init_vars {
-	$_repack = 1000 unless (defined $_repack && $_repack > 0);
-	$_repack_nr = $_repack;
-	$_repack_flags ||= '-d';
+	if (defined $_repack || defined $_repack_flags) {
+	       warn "Repack options are obsolete; they have no effect.\n";
+	}
 }
 
 sub verify_remotes_sanity {
@@ -2149,13 +2148,6 @@ sub do_git_commit {
 		                   0, $self->svm_uuid);
 	}
 	print " = $commit ($self->{ref_id})\n";
-	if ($_repack && (--$_repack_nr == 0)) {
-		$_repack_nr = $_repack;
-		# repack doesn't use any arguments with spaces in them, does it?
-		print "Running git repack $_repack_flags ...\n";
-		command_noisy('repack', split(/\s+/, $_repack_flags));
-		print "Done repacking\n";
-	}
 	return $commit;
 }
 
Karl Hasselström· Feb 3, 2008, 16:56 UTC · re: Karl Hasselström · lore

[PATCH 2/2] Let "git svn" run "git gc --auto" occasionally

Let "git svn" run "git gc --auto" every 1000 imported commits to reduce the number of loose objects.

To handle the common use case of frequent imports, where each invocation typically fetches much less than 1000 commits, also run gc unconditionally at the end of the import.

"1000" is the same number that was used by default when we called git-repack. It isn't necessarily still the best choice.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 git-svn.perl |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
Show changes to git-svn.perl +12 −0
diff --git a/git-svn.perl b/git-svn.perl
index 074068c..6cc3157 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1247,6 +1247,8 @@ use File::Path qw/mkpath/;
 use File::Copy qw/copy/;
 use IPC::Open3;
 
+my ($_gc_nr, $_gc_period);
+
 # properties that we do not log:
 my %SKIP_PROP;
 BEGIN {
@@ -1407,6 +1409,7 @@ sub read_all_remotes {
 }
 
 sub init_vars {
+	$_gc_nr = $_gc_period = 1000;
 	if (defined $_repack || defined $_repack_flags) {
 	       warn "Repack options are obsolete; they have no effect.\n";
 	}
@@ -2095,6 +2098,10 @@ sub restore_commit_header_env {
 	}
 }
 
+sub gc {
+	command_noisy('gc', '--auto');
+};
+
 sub do_git_commit {
 	my ($self, $log_entry) = @_;
 	my $lr = $self->last_rev;
@@ -2148,6 +2155,10 @@ sub do_git_commit {
 		                   0, $self->svm_uuid);
 	}
 	print " = $commit ($self->{ref_id})\n";
+	if (--$_gc_nr == 0) {
+		$_gc_nr = $_gc_period;
+		gc();
+	}
 	return $commit;
 }
 
@@ -3975,6 +3986,7 @@ sub gs_fetch_loop_common {
 		$max += $inc;
 		$max = $head if ($max > $head);
 	}
+	Git::SVN::gc();
 }
 
 sub match_globs {

← back to recent threads