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

[PATCH] Invoke "git gc --auto" when a commit is successful.

From
David J. Mellor <dmellor@whistlingcat.com>
Date
Mar 21, 2009, 22:34 UTC
Message-ID
<1237674894-8151-1-git-send-email-dmellor@whistlingcat.com>

This functionality was added to the previous git-commit.sh script in d4bb43e, but omitted when the script was ported to C in f5bbc32. This patch reinstates the functionality by copying the equivalent code that was introduced in builtin-merge.c in 1c7b76b.

Signed-off-by: David J. Mellor <dmellor@whistlingcat.com>
---
 builtin-commit.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 46e649c..780c142 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -1029,5 +1029,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (!quiet)
 		print_summary(prefix, commit_sha1);
 
+	/*
+	 * Perform an automatic garbage collection if the commit was successful.
+	 * We ignore errors in 'gc --auto', since the user should see them.
+	 */
+	const char *argv_gc_auto[] = { "gc", "--auto", NULL };
+	run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+
 	return 0;
 }
-- 
1.6.2.1
Next: Junio C Hamano
Message 1 of 3 in “Invoke "git gc --auto" when a commit is successful.”
  1. Invoke "git gc --auto" when a commit is successful.David J. Mellor, Mar 21, 2009
  2. Junio C HamanoMar 21, 2009
  3. David J. MellorMar 21, 2009

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.