public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
To: git@vger•kernel.org
Cc: sunshine@sunshineco•com, ps@pks•im, karthik.188@gmail•com,
	gitster@pobox•com,
	Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
Subject: [PATCH v5 0/2] repo: add --all to git-repo-info
Date: Tue, 18 Nov 2025 17:37:02 -0300	[thread overview]
Message-ID: <20251118204929.43597-1-lucasseikioshiro@gmail.com> (raw)
In-Reply-To: <20250915223618.13093-1-lucasseikioshiro@gmail.com>

Hi!

This v5 addresses the issues pointed by Junio in the previous versions. They
are two small changes:

- `print_all_fields` now has the same signature `print_fields`

- now it uses `size_t` instead of `unsigned long` in a `for` loop

Lucas Seiki Oshiro (2):
  repo: factor out field printing to dedicated function
  repo: add --all to git-repo-info

 Documentation/git-repo.adoc |  6 ++--
 builtin/repo.c              | 63 ++++++++++++++++++++++++++-----------
 t/t1900-repo.sh             | 21 +++++++++++++
 3 files changed, 69 insertions(+), 21 deletions(-)

Range-diff against v4:
1:  fce09770b8 ! 1:  c792715fdd repo: factor out field printing to dedicated function
    @@ Commit message
         `print_field`, allowing it to be called by functions other than
         `print_fields`.
     
    +    Also change its use of quote_c_style() helper to output directly to
    +    the standard output stream, instead of taking a result in a strbuf
    +    and then printing it outselves.
    +
         Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
     
      ## builtin/repo.c ##
2:  ccdad86123 ! 2:  b309d0e13c repo: add --all to git-repo-info
    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,
      	return ret;
      }
      
    -+static void print_all_fields(struct repository *repo,
    -+			     enum output_format format)
    ++static int print_all_fields(struct repository *repo,
    ++			    enum output_format format)
     +{
     +	struct strbuf valbuf = STRBUF_INIT;
     +
    -+	for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
    ++	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
     +		const struct field *field = &repo_info_fields[i];
     +
     +		strbuf_reset(&valbuf);
    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,
     +	}
     +
     +	strbuf_release(&valbuf);
    ++	return 0;
     +}
     +
      static int parse_format_cb(const struct option *opt,
    @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char
      	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
      		die(_("unsupported output format"));
      
    -+	if (all_keys) {
    -+		if (argc)
    -+			die(_("--all and <key> cannot be used together"));
    +-	return print_fields(argc, argv, repo, format);
    ++	if (all_keys && argc)
    ++		die(_("--all and <key> cannot be used together"));
     +
    -+		print_all_fields(repo, format);
    -+		return 0;
    -+	}
    -+
    - 	return print_fields(argc, argv, repo, format);
    ++	if (all_keys)
    ++		return print_all_fields(repo, format);
    ++	else
    ++		return print_fields(argc, argv, repo, format);
      }
      
    + struct ref_stats {
     
      ## t/t1900-repo.sh ##
     @@ t/t1900-repo.sh: test_description='test git repo-info'
-- 
2.50.1 (Apple Git-155)


  parent reply	other threads:[~2025-11-18 20:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15 22:36 [PATCH] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-09-15 23:58 ` Junio C Hamano
2025-09-16  8:06 ` Patrick Steinhardt
2025-09-16 16:19   ` Junio C Hamano
2025-09-17  5:34     ` Patrick Steinhardt
2025-10-26 22:52 ` [PATCH v3 0/2] " Lucas Seiki Oshiro
2025-10-26 22:52   ` [PATCH v3 1/2] repo: factor out field printing to dedicated function Lucas Seiki Oshiro
2025-10-26 23:53     ` Eric Sunshine
2025-10-26 23:56       ` Eric Sunshine
2025-10-27 14:56         ` Junio C Hamano
2025-10-27 16:09           ` Eric Sunshine
2025-10-26 22:52   ` [PATCH v3 2/2] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-10-27  0:22     ` Eric Sunshine
2025-10-27  0:24       ` Eric Sunshine
2025-11-17 15:02 ` [PATCH v4 0/2] " Lucas Seiki Oshiro
2025-11-17 15:02   ` [PATCH v4 1/2] repo: factor out field printing to dedicated function Lucas Seiki Oshiro
2025-11-17 18:48     ` Junio C Hamano
2025-11-17 15:02   ` [PATCH v4 2/2] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-11-17 18:58     ` Junio C Hamano
2025-11-18 20:16       ` Lucas Seiki Oshiro
2025-11-18 21:28         ` Junio C Hamano
2025-11-20 22:50           ` Lucas Seiki Oshiro
2025-11-19  7:32       ` Eric Sunshine
2025-11-19 14:33         ` Junio C Hamano
2025-11-17 18:14   ` [PATCH v4 0/2] " Junio C Hamano
2025-11-18 20:37 ` Lucas Seiki Oshiro [this message]
2025-11-18 20:37   ` [PATCH v5 1/2] repo: factor out field printing to dedicated function Lucas Seiki Oshiro
2025-11-18 20:37   ` [PATCH v5 2/2] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-11-18 21:34   ` [PATCH v5 0/2] " Junio C Hamano
2025-11-19  7:35     ` Eric Sunshine

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=20251118204929.43597-1-lucasseikioshiro@gmail.com \
    --to=lucasseikioshiro@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=karthik.188@gmail$(echo .)com \
    --cc=ps@pks$(echo .)im \
    --cc=sunshine@sunshineco$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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