git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 2/2] repo: add --all to git-repo-info

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Nov 18, 2025, 20:16 UTC
Message-ID
<DA3814BC-D6A5-4EF1-9A2B-9687D1B6C26A@gmail.com>
In-Reply-To
<xmqqh5usiizp.fsf@gitster.g>
Show 6 quoted lines
>> + for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
>> 
> I am not sure if "unsigned long i" is the type you want here.  I do
> not mind, and actually I prefer, a simple platform natural "int i"
> for something simple like this [*], but I know other people prefer to
> use "size_t" to work with ARRAY_SIZE() these days.

Yeah, I also thought it an unsigned long feels out of place, but I was only following ARRAY_SIZE. Actually, I was trying to avoid a warning. In this case we have very few `repo_info_field`s and any int type would work here...

I'll replace it by size_t, then.
Show 7 quoted lines
>    Side note: The reason they insist using size_t here is that
>        "-Wsign-compare" makes the compiler complain.  But I would
>        say that it only shows what a misguided feature
>        -Wsign-compare warning is, especially given that the
>        compiler perfectly well knows how big repo_info_fields[]
>        array is and the iteration cannot do any harm if done with a
>        signed integer smaller than size_t

Perhaps if ARRAY_SIZE(repo_info_fields) is bigger than the maximum limit of the integer type, which would overflow and this for would loop forever. But, obviously this wouldn't happen here.

Show 13 quoted lines
> This would work, but the symmetry between a list of keys vs the
> "--all" option is lost.
> 
> I'd rather see something like the following after a #leftoverbits
> clean-up commit:
> 
> if (all_keys && argc)
> die(_("--all and <key> cannot be used together"));
> 
> if (all_keys)
> return print_all_fields(repo, format);
> else
> return print_fields(argc, argv, repo, format);
I'll change it in v5.
> Again, this would work for now, but maybe "git repo info --keys"
> that emits these would be easier to manage.  This can be left to
> #leftoverbits of course.

I can't see a use for it other than these tests. What about writing a helper inside t/helpers for that?

> But then we have seem to have seen too many #leftoverbits material,
> you might want to handle some or all of them in this series in a
> reroll?  I am starting to become undecided.

I agree with all of them, but I think they were too much for this series... I also think that after git-repo-structure being added to repo.c I think that it deserves a patchset only for refactoring.

But I'll send a v5 containing the changes directly related to this series.

Thanks again. I'll send a v5 soon.
Previous: Junio C HamanoNext: Junio C Hamano
Message 20 of 30 in “repo: add --all to git-repo-info”
  1. repo: add --all to git-repo-infoLucas Seiki Oshiro, Sep 15, 2025
  2. Junio C HamanoSep 15, 2025
  3. Patrick SteinhardtSep 16, 2025
  4. Junio C HamanoSep 16, 2025
  5. Patrick SteinhardtSep 17, 2025
  6. 0/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Oct 26, 2025
  7. 1/2 repo: factor out field printing to dedicated functionLucas Seiki Oshiro, Oct 26, 2025
  8. Eric SunshineOct 26, 2025
  9. Eric SunshineOct 26, 2025
  10. Junio C HamanoOct 27, 2025
  11. Eric SunshineOct 27, 2025
  12. 2/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Oct 26, 2025
  13. Eric SunshineOct 27, 2025
  14. Eric SunshineOct 27, 2025
  15. 0/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 17, 2025
  16. 1/2 repo: factor out field printing to dedicated functionLucas Seiki Oshiro, Nov 17, 2025
  17. Junio C HamanoNov 17, 2025
  18. 2/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 17, 2025
  19. Junio C HamanoNov 17, 2025
  20. Lucas Seiki OshiroNov 18, 2025
  21. Junio C HamanoNov 18, 2025
  22. Lucas Seiki OshiroNov 20, 2025
  23. Eric SunshineNov 19, 2025
  24. Junio C HamanoNov 19, 2025
  25. Junio C HamanoNov 17, 2025
  26. 0/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 18, 2025
  27. 1/2 repo: factor out field printing to dedicated functionLucas Seiki Oshiro, Nov 18, 2025
  28. 2/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 18, 2025
  29. Junio C HamanoNov 18, 2025
  30. Eric SunshineNov 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.