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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin wrote:
> 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@xxxxxx>
> ---

<snip>

> 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".

> +			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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux