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

Re: [PATCH] gc: make --prune useful again by accepting an optional parameter

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Dec 15, 2008, 21:07 UTC
Message-ID
<j2kXTHA5qGwfTMznJutKnr1RHH7prDrQbr4BYlw-pt2V9gVgqTSERQ@cipher.nrlssc.navy.mil>
In-Reply-To
<alpine.DEB.1.00.0812152121260.30769@pacific.mpi-cbg.de>
Johannes Schindelin wrote:
Show 6 quoted lines
> With this patch, "git gc --no-prune" will not prune any loose (and
> dangling) object, and "git gc --prune=5.minutes.ago" will prune
> all loose objects older than 5 minutes.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
<snip>
Show 18 quoted lines
> diff --git a/builtin-gc.c b/builtin-gc.c
> index bbc41ac..078c5b3 100644
> --- a/builtin-gc.c
> +++ b/builtin-gc.c
> @@ -199,14 +199,15 @@ static int need_to_gc(void)
>  
>  int cmd_gc(int argc, const char **argv, const char *prefix)
>  {
> -	int prune = 0;
>  	int aggressive = 0;
>  	int auto_gc = 0;
>  	int quiet = 0;
>  	char buf[80];
>  
>  	struct option builtin_gc_options[] = {
> -		OPT_BOOLEAN(0, "prune", &prune, "prune unreferenced objects (deprecated)"),
> +		{ OPTION_STRING, 0, "prune", &prune_expire, "date",
> +			"prune unreferenced objects (deprecated)",
The help string still contains "deprecated".
Show 16 quoted lines
> +			PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },
>  		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"),
> @@ -255,9 +256,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
>  	if (run_command_v_opt(argv_repack, RUN_GIT_CMD))
>  		return error(FAILED_RUN, argv_repack[0]);
>  
> -	argv_prune[2] = prune_expire;
> -	if (run_command_v_opt(argv_prune, RUN_GIT_CMD))
> -		return error(FAILED_RUN, argv_prune[0]);
> +	if (prune_expire) {
> +		argv_prune[2] = prune_expire;
> +		if (run_command_v_opt(argv_prune, RUN_GIT_CMD))
> +			return error(FAILED_RUN, argv_prune[0]);
> +	}

When --no-prune is used, not only will packed loose objects not be pruned, but the cleanup of temporary files that git-prune performs will not be done.

Maybe this should be relaxed from "will not prune _any_ loose object" to "will not prune any unreferenced object".

If something like:
   if (!prune_expire)
   	prune_expire = "never";

is added after option parsing, then I think this will satisfy people's requests and it will also apply nicely on top of Nico's patch to avoid unpacking objects when prune_expire == "now".

-brandon
Previous: Johannes SchindelinNext: Brandon Casey
Message 2 of 3 in “gc: make --prune useful again by accepting an optional parameter”
  1. gc: make --prune useful again by accepting an optional parameterJohannes Schindelin, Dec 15, 2008
  2. Brandon CaseyDec 15, 2008
  3. Brandon CaseyDec 15, 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.