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

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

From
Karl Hasselström <kha@treskal.com>
Date
Jan 20, 2008, 21:40 UTC
Message-ID
<20080120214008.9679.69776.stgit@yoghurt>
In-Reply-To
<20080120093436.GA10924@diana.vm.bytemark.co.uk>

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 988d8f6..be4105c 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 {
Previous: Karl Hasselström
Message 27 of 27 in “git-svn should default to --repack”
  1. Kevin BallardJan 18, 2008
  2. Karl HasselströmJan 18, 2008
  3. Junio C HamanoJan 18, 2008
  4. Karl HasselströmJan 19, 2008
  5. Kevin BallardJan 19, 2008
  6. Let "git svn" run "git gc --auto" occasionallyKarl Hasselström, Jan 19, 2008
  7. Harvey HarrisonJan 19, 2008
  8. Eric WongJan 20, 2008
  9. Karl HasselströmJan 20, 2008
  10. Junio C HamanoJan 20, 2008
  11. Eric WongJan 21, 2008
  12. Junio C HamanoJan 22, 2008
  13. Eric WongJan 22, 2008
  14. Junio C HamanoJan 22, 2008
  15. git filter-branch should run git gc --autoKevin Ballard, Jan 23, 2008
  16. Junio C HamanoJan 23, 2008
  17. Junio C HamanoJan 23, 2008
  18. Kevin BallardJan 23, 2008
  19. Harvey HarrisonJan 23, 2008
  20. Kevin BallardJan 23, 2008
  21. Sam VilainJan 23, 2008
  22. Kevin BallardJan 23, 2008
  23. Mike HommeyJan 23, 2008
  24. Johannes SchindelinJan 23, 2008
  25. Junio C HamanoJan 23, 2008
  26. 1/2 git-svn: Don't call git-repack anymoreKarl Hasselström, Jan 20, 2008
  27. 2/2 Let "git svn" run "git gc --auto" occasionallyKarl Hasselström, Jan 20, 2008

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.