Re: [GSoC RFC PATCH v2 4/7] repo-info: add the --allow-empty flag
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 20, 2025, 21:39 UTC
- Message-ID
- <xmqq1pre14ae.fsf@gitster.g>
- In-Reply-To
- <20250619225751.99699-5-lucasseikioshiro@gmail.com>
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:
> Add a flag --allow-empty, which will force the output data to be empty > when no field is requested.
I still think we should flip the polarity of the option and give "--all" to iterate over all variables, and by default show nothing.
Show 43 quoted lines
> Mentored-by: Karthik Nayak <karthik.188@gmail.com>
> Mentored-by Patrick Steinhardt <ps@pks.im>
> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
> ---
> builtin/repo-info.c | 3 +++
> t/t1900-repo-info.sh | 5 +++--
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/repo-info.c b/builtin/repo-info.c
> index cd7c110f47..6499be0eae 100644
> --- a/builtin/repo-info.c
> +++ b/builtin/repo-info.c
> @@ -68,9 +68,12 @@ int cmd_repo_info(int argc,
> };
> struct repo_info repo_info;
> char *format = NULL;
> + int allow_empty = 0;
> struct option options[] = {
> OPT_STRING(0, "format", &format, N_("format"),
> N_("output format")),
> + OPT_BOOL(0, "allow-empty", &allow_empty,
> + "when set, it will use an empty set of fields if no field is requested"),
> OPT_END()
> };
>
> diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
> index 998c835795..db4a6aad17 100755
> --- a/t/t1900-repo-info.sh
> +++ b/t/t1900-repo-info.sh
> @@ -15,11 +15,12 @@ test_lazy_prereq PERLJSON '
> '
>
> test_expect_success PERLJSON 'json: returns empty output with allow-empty' '
> - git repo-info --format=json >output &&
> + git repo-info --allow-empty --format=json >output &&
> test_line_count = 2 output
> '
> +
> test_expect_success 'plaintext: returns empty output with allow-empty' '
> - git repo-info --format=plaintext >output &&
> + git repo-info --allow-empty --format=plaintext >output &&
> test_line_count = 0 output
> '