Git development
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: kerylefondji7@gmail.com, kristofferhaugsbakk@fastmail.com
Cc: git@vger.kernel.org, gitster@pobox.com,
	christian.couder@gmail.com, siddharthasthana31@gmail.com
Subject: Re: [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API
Date: Sun, 18 Oct 2026 10:45:36 +0100	[thread overview]
Message-ID: <d748915d-c50c-4143-8140-ae885a6ba604@gmail.com> (raw)
In-Reply-To: <20261017131730.642-1-kerylefondji7@gmail.com>

Hi Beryle

On 17/10/2026 14:17, kerylefondji7@gmail.com wrote:
> From: Keryle Fondji <kerylefondji7@gmail.com>
> 
> Migrate option handling in 'git var' to the parse-options API.
> This update also aligns variable resolution with current Git configuration
> and attribute handling.

This all looks very sensible, but "git var" was recently converted to 
use the parse_options() api in e19f0779c67 (var: add "-z" output mode, 
2026-09-26) which has been merge to master.

Thanks

Phillip

> Signed-off-by: Keryle Fondji <kerylefondji7@gmail.com>
> ---
>   builtin/var.c | 32 +++++++++++++++++++++++---------
>   1 file changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/builtin/var.c b/builtin/var.c
> index cc3a43cde2..b9234a55eb 100644
> --- a/builtin/var.c
> +++ b/builtin/var.c
> @@ -3,11 +3,9 @@
>    *
>    * Copyright (C) Eric Biederman, 2005
>    */
> -
>   #define USE_THE_REPOSITORY_VARIABLE
>   
>   #include "builtin.h"
> -
>   #include "attr.h"
>   #include "config.h"
>   #include "editor.h"
> @@ -18,8 +16,12 @@
>   #include "path.h"
>   #include "strbuf.h"
>   #include "run-command.h"
> +#include "parse-options.h"
>   
> -static const char var_usage[] = "git var (-l | <variable>)";
> +static const char * const var_usage[] = {
> +	N_("git var (-l | <variable>)"),
> +	NULL
> +};
>   
>   static char *committer(int ident_flag)
>   {
> @@ -120,6 +122,7 @@ struct git_var {
>   	char *(*read)(int);
>   	int multivalued;
>   };
> +
>   static struct git_var git_vars[] = {
>   	{
>   		.name = "GIT_COMMITTER_IDENT",
> @@ -221,21 +224,32 @@ int cmd_var(int argc,
>   {
>   	const struct git_var *git_var;
>   	char *val;
> +	int list = 0;
>   
> -	show_usage_if_asked(argc, argv, var_usage);
> -	if (argc != 2)
> -		usage(var_usage);
> +	struct option builtin_var_options[] = {
> +		OPT_BOOL('l', "list", &list, N_("list builtin variables")),
> +		OPT_END()
> +	};
>   
> -	if (strcmp(argv[1], "-l") == 0) {
> +	argc = parse_options(argc, argv, prefix, builtin_var_options,
> +			     var_usage, 0);
> +
> +	if (list) {
> +		if (argc > 0)
> +			usage(var_usage[0]);
>   		repo_config(the_repository, show_config, NULL);
>   		list_vars();
>   		return 0;
>   	}
> +
> +	if (argc != 1)
> +		usage(var_usage[0]);
> +
>   	repo_config(the_repository, git_default_config, NULL);
>   
> -	git_var = get_git_var(argv[1]);
> +	git_var = get_git_var(argv[0]);
>   	if (!git_var)
> -		usage(var_usage);
> +		usage(var_usage[0]);
>   
>   	val = git_var->read(IDENT_STRICT);
>   	if (!val)


  reply	other threads:[~2026-10-18  9:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 13:17 [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API kerylefondji7
2026-10-18  9:45 ` Phillip Wood [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-10-18 14:52 kerylefondji7
2026-10-18 15:09 ` Phillip Wood
2026-10-18 20:55   ` Junio C Hamano
2026-10-18 15:29 kerylefondji7

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=d748915d-c50c-4143-8140-ae885a6ba604@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kerylefondji7@gmail.com \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=siddharthasthana31@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