All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Meet Soni <meetsoni3017@gmail.com>
Cc: git@vger.kernel.org, shejialuo@gmail.com
Subject: Re: [GSoC][PATCH 1/5] builtin/pack-refs: factor out core logic into a helper
Date: Tue, 2 Sep 2025 12:18:01 +0200	[thread overview]
Message-ID: <aLbEWSHUotkmSiCq@pks.im> (raw)
In-Reply-To: <20250826073645.1074397-2-meetsoni3017@gmail.com>

On Tue, Aug 26, 2025 at 01:06:41PM +0530, Meet Soni wrote:
> The implementation of `git pack-refs` is monolithic within
> `cmd_pack_refs()`, making it impossible to share its logic with other
> commands. To enable code reuse for the upcoming `git refs optimize`
> subcommand, refactor the core logic into a shared helper function.
> 
> Introduce a new `pack-refs.h` header to define the public interface
> for this shared logic. It contains the declaration for a new helper
> function, `pack_refs_core()`, and a macro for the common usage
> options.
> 
> Move the option parsing and packing logic from `cmd_pack_refs()` into a
> new helper function named `pack_refs_core()`. This helper is made
> generic by accepting the command's usage string as a parameter.
> 
> The original `cmd_pack_refs()` is simplified to a thin wrapper that
> is only responsible for defining its specific usage array and calling
> the shared helper.
> 
> Mentored-by: Patrick Steinhardt <ps@pks.im>
> Mentored-by: shejialuo <shejialuo@gmail.com>
> Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
> ---
>  builtin/pack-refs.c | 31 ++++++++++++++++++++-----------
>  pack-refs.h         | 22 ++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 11 deletions(-)
>  create mode 100644 pack-refs.h

Shouldn't that header live in "builtin/pack-refs.h"? Makes it way more
obvious that it exposes functions from "builtin/pack-refs.c".

> diff --git a/pack-refs.h b/pack-refs.h
> new file mode 100644
> index 0000000000..ba51d154e3
> --- /dev/null
> +++ b/pack-refs.h
> @@ -0,0 +1,22 @@
> +#ifndef PACK_REFS_H
> +#define PACK_REFS_H
> +
> +struct repository;

Let's add a newline here.

> +/*
> + * Shared usage string for options common to git-pack-refs(1)
> + * and git-refs-optimize(1). The command-specific part (e.g., "git refs optimize ")
> + * must be prepended by the caller.
> + */
> +#define PACK_REFS_OPTS \
> +	"[--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>]"
> +
> +/*
> + * The core logic for pack-refs and its clones

And a dot after to terminate the sentence.

> + */
> +int pack_refs_core(int argc,
> +		   const char **argv,
> +		   const char *prefix,
> +		   struct repository *repo,
> +		   const char * const *usage_opts);
> +
> +#endif /* PACK_REFS_H */

Patrick

  reply	other threads:[~2025-09-02 10:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26  7:36 [GSoC][PATCH 0/5] Add refs optimize subcommand Meet Soni
2025-08-26  7:36 ` [GSoC][PATCH 1/5] builtin/pack-refs: factor out core logic into a helper Meet Soni
2025-09-02 10:18   ` Patrick Steinhardt [this message]
2025-09-03  3:56     ` Meet Soni
2025-09-03  4:37       ` Patrick Steinhardt
2025-09-03  5:25     ` Junio C Hamano
2025-09-03  6:00       ` Patrick Steinhardt
2025-09-03 18:20         ` Junio C Hamano
2025-08-26  7:36 ` [GSoC][PATCH 2/5] doc: factor out common option Meet Soni
2025-08-26  7:36 ` [GSoC][PATCH 3/5] builtin/refs: add optimize subcommand Meet Soni
2025-09-02 10:18   ` Patrick Steinhardt
2025-08-26  7:36 ` [GSoC][PATCH 4/5] t0601: refactor tests to be shareable Meet Soni
2025-08-26  7:36 ` [GSoC][PATCH 5/5] t: add test for git refs optimize subcommand Meet Soni
2025-08-26 15:18   ` shejialuo
2025-08-31  6:20     ` Meet Soni
2025-09-02 10:18   ` Patrick Steinhardt
2025-09-03  3:58     ` Meet Soni

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=aLbEWSHUotkmSiCq@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=meetsoni3017@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.