Re: [RFC PATCH 1/5] ref-filter: add objectsize:disk option
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Nov 12, 2018, 12:03 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1811121300520.39@tvgsbejvaqbjf.bet>
- In-Reply-To
- <xmqqr2fq3n1j.fsf@gitster-ct.c.googlers.com>
Hi,
On Mon, 12 Nov 2018, Junio C Hamano wrote:
Show 22 quoted lines
> Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:
>
> > @@ -876,11 +882,13 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
> > name++;
> > if (!strcmp(name, "objecttype"))
> > v->s = xstrdup(type_name(oi->type));
> > - else if (!strcmp(name, "objectsize")) {
> > + else if (!strcmp(name, "objectsize:disk")) {
> > + v->value = oi->disk_size;
> > + v->s = xstrfmt("%lld", (long long)oi->disk_size);
>
> oi.disk_size is off_t; do we know "long long"
>
> (1) is available widely enough (I think it is from c99)?
>
> (2) is sufficiently wide so that we can safely cast off_t to?
>
> (3) will stay to be sufficiently wide as machines get larger
> together with standard types like off_t in the future?
>
> I'd rather use intmax_t (as off_t is a signed integral type) so that
> we do not have to worry about these questions in the first place.You mean something like
v->s = xstrfmt("%"PRIdMAX, (intmax_t)oi->disk_size);If so, I agree.
Ciao, Dscho
P.S.: I wondered whether we have precedent for PRIdMAX, as we used to use only PRIuMAX, but yes: JeffH's json-writer uses PRIdMAX.
Show 24 quoted lines
>
> > + } else if (!strcmp(name, "objectsize")) {
> > v->value = oi->size;
> > v->s = xstrfmt("%lu", oi->size);
>
> This is not a suggestion but is a genuine question, but I wonder if
> two years down the road somebody who meets this API for the first
> time find the asymmetry between "objectsize" and "objectsize:disk" a
> tad strange and suggest the former to have "objectsize:real" or some
> synonym. Or we can consider "objectsize" the primary thing (hence
> needing no colon-plus-modifier to clarify what kind of size we are
> asking) and leave these two deliberatly asymmetric. I am leaning
> towards the latter myself.
>
> > - }
> > - else if (deref)
> > + } else if (deref)
> > grab_objectname(name, &oi->oid, v, &used_atom[i]);
> > }
> > }
> >
> > --
> > https://github.com/git/git/pull/552
>