# [PATCH] Invoke "gc --auto" from git commit

4 messages from 2008-11-25 to 2008-11-26. Participants: Jean-Luc Herren, Johannes Schindelin.
Thread: https://gitlist.dev/t/16464

## Jean-Luc Herren, 2008-11-25 16:15

Subject: [PATCH] Invoke "gc --auto" from git commit
Message-ID: <492C24B9.6090200@gmx.ch>
URL: https://gitlist.dev/e/492C24B9.6090200%40gmx.ch

```
This feature was lost during the port of git commit to C.

Signed-off-by: Jean-Luc Herren <jlh@gmx.ch>
---
 builtin-commit.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 591d16b..209805b 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -947,6 +947,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	struct commit_list *parents = NULL, **pptr = &parents;
 	struct stat statbuf;
 	int allow_fast_forward = 1;
+	const char *argv_gc_auto[] = { "gc", "--auto", NULL };
 
 	git_config(git_commit_config, NULL);
 
@@ -1068,6 +1069,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		     "not exceeded, and then \"git reset HEAD\" to recover.");
 
 	rerere();
+	run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
 	run_hook(get_index_file(), "post-commit", NULL);
 	if (!quiet)
 		print_summary(prefix, commit_sha1);
-- 
1.6.0.4

```

## Johannes Schindelin, 2008-11-25 23:57

Subject: Re: [PATCH] Invoke "gc --auto" from git commit
Message-ID: <alpine.DEB.1.00.0811260056480.30769@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0811260056480.30769%40pacific.mpi-cbg.de
In-Reply-To: <492C24B9.6090200@gmx.ch>

```
Hi,

On Tue, 25 Nov 2008, Jean-Luc Herren wrote:

> This feature was lost during the port of git commit to C.

See http://article.gmane.org/gmane.comp.version-control.git/82125

Ciao,
Dscho

```

## Jean-Luc Herren, 2008-11-26 01:00

Subject: Re: [PATCH] Invoke "gc --auto" from git commit
Message-ID: <492C9FAF.4090407@gmx.ch>
URL: https://gitlist.dev/e/492C9FAF.4090407%40gmx.ch
In-Reply-To: <alpine.DEB.1.00.0811260056480.30769@pacific.mpi-cbg.de>

```
Johannes Schindelin wrote:
> On Tue, 25 Nov 2008, Jean-Luc Herren wrote:
>> This feature was lost during the port of git commit to C.
> 
> See http://article.gmane.org/gmane.comp.version-control.git/82125

Oh, I missed that.  But then the only commands ever invoking git
gc --auto would be git rebase -i, git merge, git svn and git am.
I don't know if some people have repositories where they never use
any of those, but I certainly have repositories where I only ever
use git rebase -i and never any of the other.  'git commit' is
something everyone is bound to use and thus it would be the best
place for running 'git gc --auto'.

As for the performance impact, on my machine 'git gc --auto' runs
500 times per second in a loop on the git repository (it won't
call the hook unless repacking is necessary).  I suppose any
script calling git commit in a loop would do substantially more
work than git gc --auto itself.  And if that bit of performance
really matters, it could be invoked by git commit only if (rand()
% 20 == 0).

My two cents anyway.

jlh

```

## Johannes Schindelin, 2008-11-26 12:37

Subject: Re: [PATCH] Invoke "gc --auto" from git commit
Message-ID: <alpine.DEB.1.00.0811261335320.30769@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0811261335320.30769%40pacific.mpi-cbg.de
In-Reply-To: <492C9FAF.4090407@gmx.ch>

```
Hi,

On Wed, 26 Nov 2008, Jean-Luc Herren wrote:

> As for the performance impact, on my machine 'git gc --auto' runs
> 500 times per second in a loop on the git repository (it won't
> call the hook unless repacking is necessary).

Ummm.

How many people do you think share your luck?  git.git is _small_.  Your 
machine is _fast_.  It is the typical mistake in IT, not thinking about 
real-world cases...

Ciao,
Dscho

```
