public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC RFC PATCH] builtin/repo.c: change info default behavior to show all fields
@ 2026-02-24 20:40 SoutrikDas
  2026-02-24 21:03 ` [PATCH v2] " SoutrikDas
  2026-02-24 21:23 ` [RFC RFC PATCH] " Junio C Hamano
  0 siblings, 2 replies; 14+ messages in thread
From: SoutrikDas @ 2026-02-24 20:40 UTC (permalink / raw)
  To: git
  Cc: SoutrikDas, karthik.188, jltobler, ayu.chandekar,
	siddharthasthana31, lucasseikioshiro

Hi everyone!

I wish to undertake the "Improve repo" GSOC idea,so I was going through
the repo.c code and trying to make a small patch.

I saw that by default "git repo info" does not print anything at all,
I went through the first discussions [1] : 
>> Also add a flag --allow-empty, which will force the output data to be
>> empty when no field is requested.
>>
>
> Why do you suppose we need this, I'm not against it, but it would be
> nice to state why this is necessary. The idea is to have a default
> output when a user runs `git repo-info`, so I'm missing why this would
> be useful.

And 

> I was thinking about use cases where repo-info is used inside scripts.
> A simple (but kinda useless...) example: an application that is a GUI
> for this command, where the fields are selected in a checkbox, calling
> repo-info with them and then displaying their contents in a dialog.
> 
> In this example, if no field is selected and there's no validation in
> the GUI side, the default set of data will be retrieved. With
> git repo-info --allow-empty, we don't need to care about it.

Would it not be a bit better if we allow the default behaviour to show all
fields and then any subsequent scripts or application can make sure to 
check if they are appending any fields to the git repo info command, 
if not then dont show anything, because even if they ran the command without 
any fields they would get nothing. 

But now if we change default behaviour to show all fields then it becomes a 
bit more user friendly.

> After this review, I'm starting to think that leaving it empty by default
> would be better. Specially after the review by Phillip Wood [2], who
> has a good argument for it:
> 
> """
>   As this is a plumbing command I think it would be clearer if the caller 
>   was required to specify the output format and the information that they 
>   require with an "--all" option for "show me everything" as Junio 
>   suggested. If we were to set defaults for the format and keys now we 
>   would be stuck with them forever.
> """

I don't really have much experience writing scripts, but ... if one is 
scripting to get a certain value, would they not specify that ? like 
why would they excecute a "git repo info" without any fields?

Also ... mayeb this does not make much sense, but the
'git repo info --all' has only 4 fields now, so showing all 4, should be okay ?
Or maybe not.


[1] : https://public-inbox.org/git/20250610152117.14826-1-lucasseikioshiro@gmail.com/t/#m04cb1fc694f334cc861f6ab146f50b45ae277874
[2] : https://lore.kernel.org/git/af27af92-73d5-4f0a-84f4-9c91de6ab6e6@gmail.com/
---
Previously, git repo info would print nothing,
when invoked without arguements. Change the default
behaviour to display all available fields, to make
it a little more user friendly.

Signed-off-by: SoutrikDas <valusoutrik@gmail.com>
---
 builtin/repo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/builtin/repo.c b/builtin/repo.c
index 0ea045abc1..4d7efcd833 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -193,6 +193,8 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 
 	if (all_keys)
 		return print_all_fields(repo, format);
+	else if(!argc)
+		return print_fields(argc, argv, repo, format);
 	else
 		return print_fields(argc, argv, repo, format);
 }
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-02-25 17:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 20:40 [RFC RFC PATCH] builtin/repo.c: change info default behavior to show all fields SoutrikDas
2026-02-24 21:03 ` [PATCH v2] " SoutrikDas
2026-02-24 21:23 ` [RFC RFC PATCH] " Junio C Hamano
2026-02-24 22:08   ` SoutrikDas
2026-02-25  0:14     ` K Jayatheerth
2026-02-25  2:44       ` Junio C Hamano
2026-02-25 15:34         ` SoutrikDas
2026-02-25 15:46           ` Junio C Hamano
2026-02-25 15:48           ` Kristoffer Haugsbakk
2026-02-25 17:02           ` JAYATHEERTH K
2026-02-25 15:11       ` Lucas Seiki Oshiro
2026-02-25 15:38         ` SoutrikDas
2026-02-25 15:31       ` SoutrikDas
2026-02-25 16:08         ` Lucas Seiki Oshiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox