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

Re: [PATCH] Documentation: pruning recipe for destructive filter-branch

From
Jan Krüger <jk@jk.gs>
Date
Feb 14, 2009, 06:49 UTC
Message-ID
<20090214074954.7e423dd2@perceptron>
In-Reply-To
<alpine.DEB.1.00.0902140642520.10279@pacific.mpi-cbg.de>
Hi,

On Sat, 14 Feb 2009 06:46:18 +0100 (CET), Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 6 quoted lines
> > Is the --expire=now actually needed for prune? The way I read it
> > git-prune(1), it defaults to pruning everything anyway.
> 
> [...] Ah, that default is only set in "git gc", and "git prune" still
> prunes everything. [...] But maybe we do not want to direct the user
> to use "prune" here, but rather "gc"?

I just read the source code of gc and noticed that the only way to influence its expiration limit for prune is to set it in the config file (gc.pruneExpire). Thus there is no immediate way to tell gc to prune *all* unreachable objects and we need to stick to the instructions that are in the patch (minus the unnecessary --expire=now for prune). The alternative would be to add a command line option to gc that corresponds to gc.pruneExpire. I don't really care about that, but a patch for it is below.

-Jan
-----8<-----
From 42226c6c542be4e9fff0817662115f180033e75a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Jan=20Kr=C3=BCger?= <jk@jk.gs>
Date: Sat, 14 Feb 2009 07:39:23 +0100
Subject: [PATCH] gc: add --prune-expire option equivalent to gc.pruneExpire
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

In semi-regular intervals, people tend to want to get rid of huge objects they accidentally created in a repository. Of course it shouldn't be too easy to do but also not too hard. Thus we allow them to get rid of unreferenced objects more easily once they have managed to make the objects unreferenced, by allowing them to override the prune expiration limit.

Signed-off-by: Jan Krüger <jk@jk.gs>
---
 Documentation/git-gc.txt |    5 +++++
 builtin-gc.c             |    5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index 7086eea..a4d35fb 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -59,6 +59,11 @@ are consolidated into a single pack by using the `-A` option of
 'git-repack'. Setting `gc.autopacklimit` to 0 disables
 automatic consolidation of packs.
 
+--prune-expire <time>::
+	Expire unreachable objects older than <time>, rather than
+	considering the configuration variable or the default explained in
+	the next section.
+
 --quiet::
 	Suppress all progress reports.
 
diff --git a/builtin-gc.c b/builtin-gc.c
index a201438..a62c762 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -179,16 +179,17 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 	int quiet = 0;
 	char buf[80];
 
+	git_config(gc_config, NULL);
+
 	struct option builtin_gc_options[] = {
 		OPT_BOOLEAN(0, "prune", &prune, "prune unreferenced objects (deprecated)"),
+		OPT_STRING(0, "prune-expire", &prune_expire, "time", "expire unreferenced objects older than <time>"),
 		OPT_BOOLEAN(0, "aggressive", &aggressive, "be more thorough (increased runtime)"),
 		OPT_BOOLEAN(0, "auto", &auto_gc, "enable auto-gc mode"),
 		OPT_BOOLEAN('q', "quiet", &quiet, "suppress progress reports"),
 		OPT_END()
 	};
 
-	git_config(gc_config, NULL);
-
 	if (pack_refs < 0)
 		pack_refs = !is_bare_repository();
 
-- 
1.6.2.rc0.61.g5cd12.dirty
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 5 of 17 in “Documentation: pruning recipe for destructive filter-branch”
  1. Documentation: pruning recipe for destructive filter-branchThomas Rast, Feb 13, 2009
  2. Junio C HamanoFeb 14, 2009
  3. Jan KrügerFeb 14, 2009
  4. Johannes SchindelinFeb 14, 2009
  5. Jan KrügerFeb 14, 2009
  6. Johannes SchindelinFeb 14, 2009
  7. Documentation: pruning recipe for destructive filter-branchThomas Rast, Feb 14, 2009
  8. Johannes SchindelinFeb 14, 2009
  9. Junio C HamanoFeb 14, 2009
  10. Documentation: pruning recipe for destructive filter-branchThomas Rast, Feb 14, 2009
  11. gc: make --prune useful again by accepting an optional parameterJohannes Schindelin, Feb 14, 2009
  12. Thomas RastFeb 14, 2009
  13. Johannes SchindelinFeb 14, 2009
  14. gc: make --prune useful again by accepting an optional parameterJohannes Schindelin, Feb 14, 2009
  15. Thomas RastFeb 14, 2009
  16. Junio C HamanoFeb 15, 2009
  17. Jan KrügerFeb 14, 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.