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

3 messages from 2008-02-03 to 2008-02-03. Participants: Karl Hasselström.
Thread: https://gitlist.dev/t/11855

## Karl Hasselström, 2008-02-03 16:55

Subject: [PATCH 0/2] "git svn" and "git gc --auto"
Message-ID: <20080203165234.10816.6061.stgit@yoghurt>
URL: https://gitlist.dev/e/20080203165234.10816.6061.stgit%40yoghurt
In-Reply-To: <20080121224818.GA8872@untitled>

```
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, 2008-02-03 16:56

Subject: [PATCH 1/2] git-svn: Don't call git-repack anymore
Message-ID: <20080203165612.10816.35458.stgit@yoghurt>
URL: https://gitlist.dev/e/20080203165612.10816.35458.stgit%40yoghurt
In-Reply-To: <20080203165234.10816.6061.stgit@yoghurt>

```
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(-)


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, 2008-02-03 16:56

Subject: [PATCH 2/2] Let "git svn" run "git gc --auto" occasionally
Message-ID: <20080203165618.10816.6757.stgit@yoghurt>
URL: https://gitlist.dev/e/20080203165618.10816.6757.stgit%40yoghurt
In-Reply-To: <20080203165234.10816.6061.stgit@yoghurt>

```
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(-)


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 {

```
