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

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

From
Karl Hasselström <kha@treskal.com>
Date
Jan 19, 2008, 22:36 UTC
Message-ID
<20080119223249.8227.31460.stgit@yoghurt>
In-Reply-To
<20080119123557.GA30778@diana.vm.bytemark.co.uk>

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

To handle the common use case of frequent imports, where each invocation typically fetches less than 100 commits, randomly set the counter to something in the range 1-100 on initialization. It's almost as good as saving the counter, and much less of a hassle.

Oh, and 100 is just my best guess at a reasonable number. It could conceivably need tweaking.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
On 2008-01-19 13:35:57 +0100, Karl Hasselström wrote:
Show 5 quoted lines
> On 2008-01-18 12:44:08 -0800, Junio C Hamano wrote:
> 
> > Patches?
> 
> Just hot air and noise for now from my end. Sorry.

OK, it didn't feel good saying that. So here's my attempt at being a model citizen. (It's not hard with a change this small ...)

I'm not quite sure how this should interact with the --repack flag. Right now they just coexist, except for never running right after one another, but conceivably we should do something cleverer. Eric?

 git-svn.perl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 9f2b587..89e1d61 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1247,7 +1247,7 @@ use File::Path qw/mkpath/;
 use File::Copy qw/copy/;
 use IPC::Open3;
 
-my $_repack_nr;
+my ($_repack_nr, $_gc_nr, $_gc_period);
 # properties that we do not log:
 my %SKIP_PROP;
 BEGIN {
@@ -1413,6 +1413,8 @@ sub init_vars {
 		$_repack_nr = $_repack;
 		$_repack_flags ||= '-d';
 	}
+	$_gc_period = 100;
+	$_gc_nr = int(rand($_gc_period)) + 1;
 }
 
 sub verify_remotes_sanity {
@@ -2157,6 +2159,9 @@ sub do_git_commit {
 		print "Running git repack $_repack_flags ...\n";
 		command_noisy('repack', split(/\s+/, $_repack_flags));
 		print "Done repacking\n";
+	} elsif (--$_gc_nr == 0) {
+		$_gc_nr = $_gc_period;
+		command_noisy('gc', '--auto');
 	}
 	return $commit;
 }
Previous: Kevin BallardNext: Harvey Harrison
Message 6 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.