git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Meet Soni <meetsoni3017@gmail.com>
To: git@vger.kernel.org
Cc: ps@pks.im, shejialuo@gmail.com, gitster@pobox.com,
	Meet Soni <meetsoni3017@gmail.com>
Subject: [GSoC][PATCH v4 0/9] Add refs optimize subcommand
Date: Fri, 19 Sep 2025 13:56:38 +0530	[thread overview]
Message-ID: <20250919082647.535213-1-meetsoni3017@gmail.com> (raw)
In-Reply-To: <20250918054704.544254-1-meetsoni3017@gmail.com>

Hi everyone,

This series introduces `git refs optimize` as a modern replacement for
`git pack-refs`, continuing the effort to consolidate commands under the
`git refs` namespace.

Changes in v4:
- Improved commit messages and formatting.
- Removed the NULL check from the refs_optimize() dispatcher in refs.c
  to align with the project's conventions for API functions

Meet Soni (9):
  refs: add a generic 'optimize' API
  files-backend: implement 'optimize' action
  reftable-backend: implement 'optimize' action
  builtin/pack-refs: convert to use the generic refs_optimize() API
  builtin/pack-refs: factor out core logic into a shared library
  doc: pack-refs: factor out common options
  builtin/refs: add optimize subcommand
  t0601: refactor tests to be shareable
  t: add test for git refs optimize subcommand

 Documentation/git-pack-refs.adoc     |  53 +---
 Documentation/git-refs.adoc          |  10 +
 Documentation/pack-refs-options.adoc |  52 ++++
 Makefile                             |   1 +
 builtin/pack-refs.c                  |  54 +---
 builtin/refs.c                       |  17 ++
 meson.build                          |   1 +
 pack-refs.c                          |  56 ++++
 pack-refs.h                          |  23 ++
 refs.c                               |   5 +
 refs.h                               |   6 +
 refs/files-backend.c                 |  10 +
 refs/refs-internal.h                 |   3 +
 refs/reftable-backend.c              |   7 +
 t/meson.build                        |   3 +-
 t/pack-refs-tests.sh                 | 431 +++++++++++++++++++++++++++
 t/t0601-reffiles-pack-refs.sh        | 430 +-------------------------
 t/t1463-refs-optimize.sh             |  17 ++
 18 files changed, 648 insertions(+), 531 deletions(-)
 create mode 100644 Documentation/pack-refs-options.adoc
 create mode 100644 pack-refs.c
 create mode 100644 pack-refs.h
 create mode 100644 t/pack-refs-tests.sh
 create mode 100755 t/t1463-refs-optimize.sh

Range-diff against v3:
 1:  a837ae6f5d !  1:  8d8aa56fe9 refs: add a generic 'optimize' API
    @@ Metadata
      ## Commit message ##
         refs: add a generic 'optimize' API
     
    -    Add a new generic refs_optimize() API function that dispatches to a
    +    The existing `pack-refs` API is conceptually tied to the 'files'
    +    backend, but its behavior is generic (e.g., it triggers compaction for
    +    reftable). This naming is confusing.
    +
    +    Introduce a new generic refs_optimize() API that dispatches to a
         backend-specific implementation via a new 'optimize' vtable method.
     
         This lays the architectural groundwork for different reference backends
    @@ refs.c: int refs_pack_refs(struct ref_store *refs, struct pack_refs_opts *opts)
      
     +int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts)
     +{
    -+	if (!refs->be->optimize)
    -+		return 0;
     +	return refs->be->optimize(refs, opts);
     +}
     +
 2:  e0613b14b6 =  2:  aebdf90fef files-backend: implement 'optimize' action
 3:  ae8d2d29d9 =  3:  0b41b52e36 reftable-backend: implement 'optimize' action
 4:  a8cba8a355 !  4:  bcb76f2460 builtin/pack-refs: convert to use the generic refs_optimize() API
    @@ Metadata
      ## Commit message ##
         builtin/pack-refs: convert to use the generic refs_optimize() API
     
    -    The `git pack-refs` command is tied to the 'files' reference backend. In
    -    a repository that uses a different backend (like 'reftable'), the
    -    command is a no-op.
    +    The `git pack-refs` command behaves generically, triggering a pack for
    +    the 'files' backend and a compaction for the 'reftable' backend.
    +    However, the name of the command and its corresponding API is
    +    conceptually tied to the 'files' backend implementation.
     
    -    To make `git pack-refs` a truly generic frontend for reference
    -    optimization, refactor it to use the new generic `refs_optimize()` API.
    -    This will allow the command to automatically work with any backend
    -    that implements the `optimize` action in the future.
    +    To create a cleaner, more generic interface, refactor `git pack-refs` to
    +    use the new `refs_optimize()` API. "Optimize" is a better semantic term
    +    for this generic action.
     
    -    The command continues to handle parsing its own command-line options,
    -    but now calls the generic API to perform the action instead of a
    -    backend-specific function.
    +    This change allows `git pack-refs` to act as a backend-agnostic frontend
    +    for reference optimization, and paves the way for the new `git refs
    +    optimize` command to do the same.
     
         Mentored-by: Patrick Steinhardt <ps@pks.im>
         Mentored-by: shejialuo <shejialuo@gmail.com>
 5:  ec1085ccd8 =  5:  6c6d63edff builtin/pack-refs: factor out core logic into a shared library
 6:  e1758816bf =  6:  5c5d3e2699 doc: pack-refs: factor out common options
 7:  e3a908fe72 !  7:  d2bff276b8 builtin/refs: add optimize subcommand
    @@ builtin/refs.c: static int cmd_refs_list(int argc, const char **argv, const char
      }
      
     +static int cmd_refs_optimize(int argc, const char **argv, const char *prefix,
    -+			   struct repository *repo)
    ++			     struct repository *repo)
     +{
     +	static char const * const refs_optimize_usage[] = {
     +		REFS_OPTIMIZE_USAGE,
 8:  4f63632ac2 =  8:  5a865d2828 t0601: refactor tests to be shareable
 9:  39eed2831a =  9:  3d7d40b510 t: add test for git refs optimize subcommand

base-commit: f814da676ae46aac5be0a98b99373a76dee6cedb
-- 
2.34.1


  parent reply	other threads:[~2025-09-19  8:26 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-06  7:51 [GSoC][PATCH v2 0/5] Add refs optimize subcommand Meet Soni
2025-09-06  7:51 ` [GSoC][PATCH v2 1/5] builtin/pack-refs: factor out core logic into a shared library Meet Soni
2025-09-06  7:51 ` [GSoC][PATCH v2 2/5] doc: factor out common option Meet Soni
2025-09-08 16:44   ` Junio C Hamano
2025-09-06  7:51 ` [GSoC][PATCH v2 3/5] builtin/refs: add optimize subcommand Meet Soni
2025-09-06  7:51 ` [GSoC][PATCH v2 4/5] t0601: refactor tests to be shareable Meet Soni
2025-09-06  7:51 ` [GSoC][PATCH v2 5/5] t: add test for git refs optimize subcommand Meet Soni
2025-09-08 14:07 ` [GSoC][PATCH v2 0/5] Add " Junio C Hamano
2025-09-08 16:41   ` Junio C Hamano
2025-09-18  5:46 ` [GSoC][PATCH v3 0/9] " Meet Soni
2025-09-18  5:46   ` [GSoC][PATCH v3 1/9] refs: add a generic 'optimize' API Meet Soni
2025-09-18 10:44     ` shejialuo
2025-09-18 15:39       ` Junio C Hamano
2025-09-18  5:46   ` [GSoC][PATCH v3 2/9] files-backend: implement 'optimize' action Meet Soni
2025-09-18  5:46   ` [GSoC][PATCH v3 3/9] reftable-backend: " Meet Soni
2025-09-18  5:46   ` [GSoC][PATCH v3 4/9] builtin/pack-refs: convert to use the generic refs_optimize() API Meet Soni
2025-09-18 10:43     ` shejialuo
2025-09-18  5:47   ` [GSoC][PATCH v3 5/9] builtin/pack-refs: factor out core logic into a shared library Meet Soni
2025-09-18  5:47   ` [GSoC][GSoC][PATCH v3 6/9] doc: pack-refs: factor out common options Meet Soni
2025-09-18  5:47   ` [GSoC][PATCH v3 7/9] builtin/refs: add optimize subcommand Meet Soni
2025-09-18 16:06     ` Junio C Hamano
2025-09-18  5:47   ` [GSoC][PATCH v3 8/9] t0601: refactor tests to be shareable Meet Soni
2025-09-18  5:47   ` [GSoC][PATCH v3 9/9] t: add test for git refs optimize subcommand Meet Soni
2025-09-19  8:26   ` Meet Soni [this message]
2025-09-19  8:26     ` [GSoC][PATCH v4 1/9] refs: add a generic 'optimize' API Meet Soni
2025-09-24  6:18       ` Patrick Steinhardt
2025-09-19  8:26     ` [GSoC][PATCH v4 2/9] files-backend: implement 'optimize' action Meet Soni
2025-09-19  8:26     ` [GSoC][PATCH v4 3/9] reftable-backend: " Meet Soni
2025-09-19  8:26     ` [GSoC][PATCH v4 4/9] builtin/pack-refs: convert to use the generic refs_optimize() API Meet Soni
2025-09-19  8:26     ` [GSoC][PATCH v4 5/9] builtin/pack-refs: factor out core logic into a shared library Meet Soni
2025-09-24  6:18       ` Patrick Steinhardt
2025-09-19  8:26     ` [GSoC][PATCH v4 6/9] doc: pack-refs: factor out common options Meet Soni
2025-09-19  8:26     ` [GSoC][PATCH v4 7/9] builtin/refs: add optimize subcommand Meet Soni
2025-09-19  8:26     ` [GSoC][PATCH v4 8/9] t0601: refactor tests to be shareable Meet Soni
2025-09-19  8:26     ` [GSoC][PATCH v4 9/9] t: add test for git refs optimize subcommand Meet Soni
2025-09-19 18:43     ` [GSoC][PATCH v4 0/9] Add " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250919082647.535213-1-meetsoni3017@gmail.com \
    --to=meetsoni3017@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ps@pks.im \
    --cc=shejialuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).