All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcus Griep <marcus@griep.us>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: Re: [RFC Redux] strbuf: Add method to convert byte-size to human readable form
Date: Fri, 19 Sep 2008 11:56:42 -0400	[thread overview]
Message-ID: <48D3CBBA.8060507@griep.us> (raw)
In-Reply-To: <1221279997-9336-1-git-send-email-marcus@griep.us>

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

If there is no comment on this, Junio, would you be ok accepting this as a patch,
even as a feature-branch on pu or next?

Marcus Griep wrote:
> Takes a strbuf as its first argument and appends the human-readable
> form of 'value', the second argument, to that buffer.
> 
> e.g. strbuf_append_human_readable(sb, 1012, 0, 0, HR_SPACE)
> produces "0.9 Ki".
> 
> Documented in strbuf.h; units can be directly appended to the strbuf
> to produce "0.9 KiB/s", "0.9 KiB".
> 
> Supports SI magnitude prefixes as well as padding and spacing of
> the units portion of the output.
> 
> Also, add in test cases to ensure it produces the expected output
> and to demonstrate what different arguments do.
> 
> Signed-off-by: Marcus Griep <marcus@griep.us>
> ---
> 
>  This is a redux of a prior patch as part of a series on count-objects
>  but is now split off and submitted on its own as an RFC for a library
>  function to be added to strbuf.  If accepted, I'd like to standardize
>  upon this method for user visible byte-sizes, thoroughput, large object
>  counts, etc.
> 
>  Provides similar functionality similar to the '-h' size output of du
>  in the default case.
> 
>  Based on master, but also applies cleanly to next.
> 
>  .gitignore                |    1 +
>  Makefile                  |    2 +-
>  strbuf.c                  |   92 +++++++++++++++++++++++++++++++++++++++++++++
>  strbuf.h                  |   30 +++++++++++++++
>  t/t0031-human-readable.sh |   49 ++++++++++++++++++++++++
>  test-human-read.c         |   23 +++++++++++
>  6 files changed, 196 insertions(+), 1 deletions(-)
>  create mode 100755 t/t0031-human-readable.sh
>  create mode 100644 test-human-read.c

-- 
Marcus Griep
GPG Key ID: 0x5E968152
——
http://www.boohaunt.net
את.ψο´


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 793 bytes --]

  reply	other threads:[~2008-09-19 15:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-13  4:26 [RFC Redux] strbuf: Add method to convert byte-size to human readable form Marcus Griep
2008-09-19 15:56 ` Marcus Griep [this message]
2008-09-19 20:32   ` Junio C Hamano
2008-09-19 20:59     ` Daniel Barkalow
2008-09-19 21:55 ` Junio C Hamano
2008-09-19 22:37   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48D3CBBA.8060507@griep.us \
    --to=marcus@griep.us \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.