Re: [PATCH v6 6/7] builtin/repo: add keyvalue and nul format for structure stats
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Oct 23, 2025, 00:03 UTC
- Message-ID
- <f3lthzionr4wktkgddb4lwu7njucrny2jmjhtbtiifbwsceuaf@oqx7q7y6alze>
- In-Reply-To
- <A076B823-F619-435F-9A7D-40C6D60254D1@gmail.com>
On 25/10/22 05:34PM, Lucas Seiki Oshiro wrote:
Show 11 quoted lines
> > > All repository structure stats are outputted in a human-friendly table > > form. This format is not suitable for machine parsing. Add a --format > > option that supports three output modes: `table`, `keyvalue`, and `nul`. > > The `table` mode is the default format and prints the same table output > > as before. > > Now I'm thinking... What about making --format a flag for git-repo, > working for both git-repo-info and git-repo-structure? It doesn't seem > to be hard to make git-repo-info compatible with your table format and > it looks to me that it would make git-repo more consistent.
Since currently these different subcommands don't support all the same formats anyways, I don't think it matters too much that they both define their own `--format` option. If git-repo-info were to add support for a table format in the future though, I do think we could probably lift this option up at that time if we wanted.
> I'm also wondering if git-repo-info use this table format by default. > git-repo-info and git-repo-structure are completely different under > the hood, but their interface are very similar and it seems to be that > they could be more closer to each other.
I think that could be nice, but is should probably be done in a separate series. I do like the idea of aligning the interfaces of these subcommands though. :)
Show 10 quoted lines
> > "git repo info [--format=(keyvalue|nul)] [-z] [<key>...]", > > - "git repo structure", > > + "git repo structure [--format=(table|keyvalue|nul)]", > > Do you intend to add a key parameter like in git-repo-info? This way, > we could run: > > git repo structure references.branches.count references.tags.count > > and it would return only the branch and tag count.
Currently I do not intend to add key parameters similar to git-repo-info. For git-repo-structure, I don't think it would add much value to filter out certain values unless it would simplify overall computation. In the case of `references.branches.count` and `references.tags.count`, figuring these values out requires iterating across all the references anyways. Even if we only wanted object count data we would still have to iterate across all the references too.
If we just wanted reference data, we could have an option to skip the path walking, but that would really limit the data we display and probably not be that useful overall.
-Justin