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

Re: [PATCH v3 1/2] repo: factor out field printing to dedicated function

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Oct 27, 2025, 16:09 UTC
Message-ID
<CAPig+cThZd3urbiPJ6WiToLcdmaj6AqRpj-edEjiD54Lt_r-1Q@mail.gmail.com>
In-Reply-To
<xmqqwm4gl7fg.fsf@gitster.g>
On Mon, Oct 27, 2025 at 10:56 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > Or, even better, scope the strbuf just to the `case` branch which needs it:
> >
> >     case FORMAT_KEYVALUE: {
> >         struct strbuf buf = STRBUF_INIT;
> >         quote_c_style(value, buf, NULL, 0);
> >         printf("%s=%s\n", key, buf->buf);
> >         strbuf_release(&buf);
> >         break;
> >      }
>
> For something simple like this, quote_c_style() can take "FILE *"
> instead of struct "strbuf *" so that you do not have to allocate;
> especially without any need for i18n, perhaps
>
>     printf("%s=", key);
>     quote_c_style(value, NULL, stdout, 0);
Thanks, that's even better. Nice and clean and easy to read.

(I didn't have the Git source code at hand, so didn't know that `quote_c_style` could take `FILE *`.)

Previous: Junio C HamanoNext: Lucas Seiki Oshiro
Message 11 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.