Subject: [RFC RFC PATCH] builtin/repo.c: change info default behavior to show all fields

From: SoutrikDas <[email-masked]>
Date: Wed, 25 Feb 2026 02:10:47 +0530

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/[email-masked]/t/#m04cb1fc694f334cc861f6ab146f50b45ae277874
[2] : https://lore.kernel.org/git/[email-masked]/
---
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 <[email-masked]>
---
 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