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

Re: [PATCH] revert & cherry-pick: run git gc --auto

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Oct 11, 2018, 09:23 UTC
Message-ID
<20f33df8-7ba8-af26-e0c8-16152345c85b@talktalk.net>
In-Reply-To
<20181010193557.19052-1-avarab@gmail.com>
Hi Ævar
On 10/10/2018 20:35, Ævar Arnfjörð Bjarmason wrote:
Show 7 quoted lines
> Expand on the work started in 095c741edd ("commit: run git gc --auto
> just before the post-commit hook", 2018-02-28) to run "gc --auto" in
> more commands where new objects can be created.
> 
> The notably missing commands are now "rebase" and "stash". Both are
> being rewritten in C, so any use of "gc --auto" there can wait for
> that.

If cherry-pick, revert or 'rebase -i' edit the commit message then they fork 'git commit' so gc --auto will be run there anyway. I wonder if it would be better to call 'gc --auto' from sequencer.c at the end of a string of successful picks, that would cover cherry-pick, 'rebase -iu' and revert. With 'rebase -i' it might be nice to avoid calling 'gc --auto' until the very end, rather than every time we stop for an edit but that is probably more trouble than it is worth.

Best Wishes
Phillip
Show 52 quoted lines
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> 
> After reading the "Users are encouraged to run this task..." paragraph
> in the git-gc manpage I was wondering if due to gc --auto all over the
> place now (including recently in git-commit with a patch of mine) if
> we shouldn't change that advice.
> 
> I'm meaning to send some doc changes to git-gc.txt, but in the
> meantime let's address this low-hanging fruit of running gc --auto
> when we revert or cherry-pick commits, which can like git-commit
> create a significant amount of loose objects.
> 
>  builtin/revert.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/builtin/revert.c b/builtin/revert.c
> index 9a66720cfc..1b20902910 100644
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -209,6 +209,7 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
>  {
>  	struct replay_opts opts = REPLAY_OPTS_INIT;
>  	int res;
> +	const char *argv_gc_auto[] = {"gc", "--auto", NULL};
>  
>  	if (isatty(0))
>  		opts.edit = 1;
> @@ -217,6 +218,7 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
>  	res = run_sequencer(argc, argv, &opts);
>  	if (res < 0)
>  		die(_("revert failed"));
> +	run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
>  	return res;
>  }
>  
> @@ -224,11 +226,13 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
>  {
>  	struct replay_opts opts = REPLAY_OPTS_INIT;
>  	int res;
> +	const char *argv_gc_auto[] = {"gc", "--auto", NULL};
>  
>  	opts.action = REPLAY_PICK;
>  	sequencer_init_config(&opts);
>  	res = run_sequencer(argc, argv, &opts);
>  	if (res < 0)
>  		die(_("cherry-pick failed"));
> +	run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
>  	return res;
>  }
> 
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 2 of 7 in “revert & cherry-pick: run git gc --auto”
  1. revert & cherry-pick: run git gc --autoÆvar Arnfjörð Bjarmason, Oct 10, 2018
  2. Phillip WoodOct 11, 2018
  3. Ævar Arnfjörð BjarmasonOct 11, 2018
  4. SZEDER GáborOct 11, 2018
  5. Ævar Arnfjörð BjarmasonOct 11, 2018
  6. SZEDER GáborOct 11, 2018
  7. Phillip WoodOct 11, 2018

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.