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

Re: [PATCH v4] rev-list: support human-readable output for `--disk-usage`

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 11, 2022, 05:20 UTC
Message-ID
<xmqqy1vvgxv5.fsf@gitster.g>
In-Reply-To
<YvQhHOkjZatIqlFr@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> I don't care much between "printf directly vs strbuf" for the non-human
> case, but it was an earlier review suggestion to connect them. I do
> think the result is a little easier to follow, but mostly I want to make
> it clear that the author is getting stuck between warring review
> comments here. ;)

The function does look like it can later be called millions of times, at which time we may want to measure, but as the only use of this helper function is to get called just once at the end with a single number and print it (as opposed to getting called once per each object), I do not care too much about the normal case being made unnecessarily more expensive, either.

I still do not see the point of changing it to print to a strbuf and puts() the result, though. It does not make the code shorter, more efficient, or more readable. Once "if (we are producing humanize format)" condition is hit, both of its branches can either be (1) responsible to print the number to the standard output stream, using whatever implementation, or (2) responsible to print the number to a strbuf, so that somebody outside the if statement will be respohnsible for printing that string to the standard output stream.

The patch chooses (2), which is more complex, for no good reason. A good thing about (1) is that the non-human codepath can STAY to be the same as before, which is one fewer chance to introduce unnecessary bugs.

Anyway...
Previous: Junio C HamanoNext: Jeff King
Message 14 of 17 in “rev-list: support `--human-readable` option when applied `disk-usage`”
  1. rev-list: support `--human-readable` option when applied `disk-usage`Li Linchao via GitGitGadget, Aug 5, 2022
  2. Ævar Arnfjörð BjarmasonAug 5, 2022
  3. lilinchao@oschina.cnAug 5, 2022
  4. rev-list: support human-readable output for `--disk-usage`Li Linchao via GitGitGadget, Aug 8, 2022
  5. lilinchao@oschina.cnAug 8, 2022
  6. Jeff KingAug 9, 2022
  7. lilinchao@oschina.cnAug 9, 2022
  8. rev-list: support human-readable output for `--disk-usage`Li Linchao via GitGitGadget, Aug 10, 2022
  9. Johannes SixtAug 10, 2022
  10. rev-list: support human-readable output for `--disk-usage`Li Linchao via GitGitGadget, Aug 10, 2022
  11. Junio C HamanoAug 10, 2022
  12. Jeff KingAug 10, 2022
  13. Junio C HamanoAug 10, 2022
  14. Junio C HamanoAug 11, 2022
  15. Jeff KingAug 11, 2022
  16. rev-list: support human-readable output for `--disk-usage`Li Linchao via GitGitGadget, Aug 11, 2022
  17. Junio C HamanoAug 11, 2022

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.