* [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API
@ 2026-10-17 13:17 kerylefondji7
2026-10-18 9:45 ` Phillip Wood
0 siblings, 1 reply; 6+ messages in thread
From: kerylefondji7 @ 2026-10-17 13:17 UTC (permalink / raw)
To: kristofferhaugsbakk
Cc: git, gitster, christian.couder, siddharthasthana31, Keryle Fondji
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.
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)
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API
2026-10-17 13:17 [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API kerylefondji7
@ 2026-10-18 9:45 ` Phillip Wood
0 siblings, 0 replies; 6+ messages in thread
From: Phillip Wood @ 2026-10-18 9:45 UTC (permalink / raw)
To: kerylefondji7, kristofferhaugsbakk
Cc: git, gitster, christian.couder, siddharthasthana31
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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API
@ 2026-10-18 14:52 kerylefondji7
2026-10-18 15:09 ` Phillip Wood
0 siblings, 1 reply; 6+ messages in thread
From: kerylefondji7 @ 2026-10-18 14:52 UTC (permalink / raw)
To: phillipwood123
Cc: git, gitster, christian.couder, siddharthasthana31, Keryle Fondji
From: Keryle Fondji <kerylefondji7@gmail.com>
Hi Phillip,
Thank you very much for reviewing my patch and for pointing this out! I didn't realize that `git var` had already been converted.
I am new to open source and to this ecosystem, so I am still getting familiar with how everything works. Could you please advise on where I can find a list of available microprojects or files to work on, to make sure I don't pick something that is already done?
Thank you again for your guidance and patience.
Best regards,
Keryle
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API
2026-10-18 14:52 kerylefondji7
@ 2026-10-18 15:09 ` Phillip Wood
2026-10-18 20:55 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Phillip Wood @ 2026-10-18 15:09 UTC (permalink / raw)
To: kerylefondji7; +Cc: git, gitster, christian.couder, siddharthasthana31
Hi Keryle
On 18/10/2026 15:52, kerylefondji7@gmail.com wrote:
> From: Keryle Fondji <kerylefondji7@gmail.com>
>
> Hi Phillip,
>
> Thank you very much for reviewing my patch and for pointing this out!
> I didn't realize that `git var` had already been converted.>
> I am new to open source and to this ecosystem, so I am still getting
> familiar with how everything works. Could you please advise on where I
> can find a list of available microprojects or files to work on, to
> make sure I don't pick something that is already done?
There are suggestions for microprojects at [1] and some additional
guidance at [2]. The test conversions are a good way to get familiar
with our test suite. To check you're not working on the same thing as
someone else you should scan the mailing list archives [3] and/or see
what is in the "seen" branch. In many ways the main point of a
microproject is to get candidates familiar with sending patches to the
mailing list and interacting with reviewers. You've shown that you
understand how to send patches, respond to comments and ask for help
even if this particular patch (which looked very sensible) did not end
up being merged.
Thanks
Phillip
[1] https://git.github.io/SoC-2026-Microprojects/
[2] https://git.github.io/General-Microproject-Information/
[3] https://lore.kernel.org/git
> Thank you again for your guidance and patience.
>
> Best regards,
> Keryle
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API
2026-10-18 15:09 ` Phillip Wood
@ 2026-10-18 20:55 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2026-10-18 20:55 UTC (permalink / raw)
To: Phillip Wood; +Cc: kerylefondji7, git, christian.couder, siddharthasthana31
Phillip Wood <phillip.wood123@gmail.com> writes:
> ... In many ways the main point of a
> microproject is to get candidates familiar with sending patches to the
> mailing list and interacting with reviewers.
Thanks for highlighting this important point. Highly appreciated.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API
@ 2026-10-18 15:29 kerylefondji7
0 siblings, 0 replies; 6+ messages in thread
From: kerylefondji7 @ 2026-10-18 15:29 UTC (permalink / raw)
To: phillipwood123; +Cc: git, gitster, christian.couder, siddharthasthana31
Hi Phillip,
Thank you so much for your kind words and encouragement! It is very reassuring to hear that, and I really appreciate you taking the time to share these useful links and advice.
I will check out the microprojects list and the archives carefully before picking my next task.
Thank you again for your patience and guidance!
Best regards,
Keryle
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-10-18 20:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-17 13:17 [Outreachy][PATCH v3] builtin/var: refactor to use parse-options API kerylefondji7
2026-10-18 9:45 ` Phillip Wood
-- 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox