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

Re: [PATCH 1/2] maintenance: add pack-refs task

From
Taylor Blau <me@ttaylorr.com>
Date
Feb 8, 2021, 22:53 UTC
Message-ID
<YCHA991dv0V0hNb+@nand.local>
In-Reply-To
<33b7a74af4eb45756c3648eb7b002d06e4ec3563.1612795943.git.gitgitgadget@gmail.com>
On Mon, Feb 08, 2021 at 02:52:22PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 6 quoted lines
> +pack-refs::
> +	The `pack-refs` task collects the loose reference files and
> +	collects them into a single file. This speeds up operations that
> +	need to iterate across many refereences. See linkgit:git-pack-refs[1]
> +	for more information.
> +

Do you think it's worth documenting here or in git-gc(1) that running this has the effect of disabling the same step during gc?

Show 21 quoted lines
>  OPTIONS
>  -------
>  --auto::
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 4c40594d660e..8f13c3bb8607 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -54,7 +54,6 @@ static const char *prune_worktrees_expire = "3.months.ago";
>  static unsigned long big_pack_threshold;
>  static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
>
> -static struct strvec pack_refs_cmd = STRVEC_INIT;
>  static struct strvec reflog = STRVEC_INIT;
>  static struct strvec repack = STRVEC_INIT;
>  static struct strvec prune = STRVEC_INIT;
> @@ -163,6 +162,15 @@ static void gc_config(void)
>  	git_config(git_default_config, NULL);
>  }
>
> +struct maintenance_run_opts;
> +static int maintenance_task_pack_refs(struct maintenance_run_opts *opts)

It may be worth calling this "unused", since you explicitly pass NULL below.

Show 18 quoted lines
> +{
> +	struct strvec pack_refs_cmd = STRVEC_INIT;
> +	strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
> +
> +	return run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD);
> +}
> +
>  static int too_many_loose_objects(void)
>  {
>  	/*
> @@ -518,8 +526,8 @@ static void gc_before_repack(void)
>  	if (done++)
>  		return;
>
> -	if (pack_refs && run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD))
> -		die(FAILED_RUN, pack_refs_cmd.v[0]);
> +	if (pack_refs && maintenance_task_pack_refs(NULL))
> +		die(FAILED_RUN, "pack-refs");

Hmm. Am I missing where opting into the maintenance step disables this in gc? You suggest that it does in the commit message, but I can't seem to see it here.

Show 8 quoted lines
> +test_expect_success 'pack-refs task' '
> +	for n in $(test_seq 1 5)
> +	do
> +		git branch -f to-pack/$n HEAD || return 1
> +	done &&
> +	git maintenance run --task=pack-refs &&
> +	ls .git/refs/heads/ >after &&
> +	test_must_be_empty after
Worth testing that $GIT_DIR/packed-refs exists, too?

Thanks, Taylor

Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee
Message 4 of 12 in “Maintenance: add pack-refs task”
  1. 0/2 Maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 8, 2021
  2. 2/2 maintenance: incremental strategy runs pack-refs weeklyDerrick Stolee via GitGitGadget, Feb 8, 2021
  3. 1/2 maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 8, 2021
  4. Taylor BlauFeb 8, 2021
  5. Derrick StoleeFeb 9, 2021
  6. Eric SunshineFeb 8, 2021
  7. Derrick StoleeFeb 9, 2021
  8. Taylor BlauFeb 8, 2021
  9. 0/2 Maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 9, 2021
  10. 1/2 maintenance: add pack-refs taskDerrick Stolee via GitGitGadget, Feb 9, 2021
  11. 2/2 maintenance: incremental strategy runs pack-refs weeklyDerrick Stolee via GitGitGadget, Feb 9, 2021
  12. Taylor BlauFeb 10, 2021

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.