git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcus Griep <marcus@griep.us>
To: Petr Baudis <pasky@suse.cz>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 2/3] strbuf: Add method to convert byte-size to human readable form
Date: Thu, 14 Aug 2008 20:46:21 -0400	[thread overview]
Message-ID: <48A4D1DD.9060202@griep.us> (raw)
In-Reply-To: <20080814223429.GC10544@machine.or.cz>

Petr Baudis wrote:
> Frankly, I doubt this has too much value, and it complicates the code _a
> lot_. If you can't fit your stuff into pretty column, it's better to
> just print whatever you have to and disrupt the columns instead of
> _failing_, isn't it?

Generally, the only reason for such a failure would be requesting
conflicting scale and maxlen values or requesting a maxlen which would
be too small to reasonably display any value, hence an empty string and
a number reporting how much more is necessary to get appropriate output.

In other words, a failure reports that you probably requested an
irrational number for maxlen.  It would probably be easier to understand
if it were in terms of the numeric output rather than the entire string.
If I change it that way, then there shouldn't be an "irrational" positive
number to request, eliminating the need for these failures.

> Shouldn't pretty much all of this be documented in the code too?

Should I stuff this in comments in the header file, source file, or both?

> My point still stands - in case of binary units, we should always
> consistently use the i suffix. So having an example in the commit
> message that advertises "bps" is simply wrong when it should read "iB/s"
> (like it does with the current progress.c code).
> 
> I may sound boring, but it seems to me that you're still ignoring my
> point quitly without proper counter-argumentation and I think it's an
> important want, and since it's so hard to keep things consistent across
> the wide Git codebase, we should do all we can to keep it.

From a consistency standpoint, I can certainly agree.  It's not hard to
implement.  I wanted to avoid pigeon-holeing, but to keep our reporting
consistent, using '*i' for all binaries works for me.

> Whitespace damage? Also at a lot of other places in your patch.

No damage.  It was indicated to me that 80-ish was the preferred width, so
I was trying to follow that.  If that's not true in the C sources, I'll
bundle things up a bit more.

> Hmmm. We could have
> 
> +        char *hr_prefixes[] = {
> +		"", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi", NULL
> +	};
> +        char *hr_si_prefixes[] = {
> +		"", "k", "M", "G", "T", "P", "E", "Z", "Y", NULL
> +	};
> 
> ;-)

Per previous, sounds good to me.

Overall, I was looking to create a generic function that could be used
across Git without making assumptions of the consumer.  Hence the maxlen,
scale, SI, and space configurability.

Thanks for the input, and I'll work up another draft.

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

  parent reply	other threads:[~2008-08-15  0:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14 22:18 [PATCH v2 0/3] count-objects size and strbuf human-readable Marcus Griep
2008-08-14 22:18 ` [PATCH v2 1/3] count-objects: Add total pack size to verbose output Marcus Griep
2008-08-14 22:18   ` [PATCH v2 2/3] strbuf: Add method to convert byte-size to human readable form Marcus Griep
2008-08-14 22:18     ` [PATCH v2 3/3] count-objects: add human-readable size option Marcus Griep
2008-08-14 22:37       ` Petr Baudis
2008-08-14 23:52         ` Marcus Griep
2008-08-15  0:10           ` Junio C Hamano
2008-08-14 22:34     ` [PATCH v2 2/3] strbuf: Add method to convert byte-size to human readable form Petr Baudis
2008-08-14 23:04       ` Junio C Hamano
2008-08-14 23:24         ` Petr Baudis
2008-08-14 23:40           ` Junio C Hamano
2008-08-15  0:53         ` Marcus Griep
2008-08-15  0:46       ` Marcus Griep [this message]
2008-08-15  0:52         ` Shawn O. Pearce
2008-08-15  4:20 ` [PATCH v3 1/3] count-objects: Add total pack size to verbose output Marcus Griep
2008-08-15  4:20   ` [PATCH v3 2/3] strbuf: Add method to convert byte-size to human readable form Marcus Griep
2008-08-15  4:20     ` [PATCH v3 3/3] count-objects: add human-readable size option Marcus Griep
2008-08-15 15:47   ` [PATCH v3.1 1/3] count-objects: Add total pack size to verbose output Marcus Griep

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=48A4D1DD.9060202@griep.us \
    --to=marcus@griep.us \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pasky@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).