From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 0/2] git-config and large integers
Date: Tue, 20 Aug 2013 22:43:55 -0400 [thread overview]
Message-ID: <20130821024355.GB25296@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqhaekudzp.fsf@gitster.dls.corp.google.com>
On Tue, Aug 20, 2013 at 04:41:30PM -0700, Junio C Hamano wrote:
> If this applied on the writing side, I would understand it very
> much, i.e.
>
> $ git config --int32 foo.size 2g
> fatal: "2g" is too large to be read as "int32".
It does, by the way. When you request a type on the writing side, we
normalize (and complain in the same way as we do when reading).
> and as a complement it may make sense as a warning mechanism to also
> error out when existing value does not fit on the "platform" int, so
> your
>
> >> $ git config --int foo.size
> >> fatal: bad config value for 'foo.size' in .git/config
>
> might make sense (even though I'd suggest being more explicit than
> "bad value" in this case---"the value specified will not fit when
> used in a variable of type int on this platform").
Yes, the error message is terrible, and I think an extra patch on top to
improve it is worth doing. But note that I am not introducing that error
here at all. On 32-bit systems, we already correctly range-checked and
produced that error. It is only on 64-bit systems that the range check
was flat out wrong. It checked against "long"'s precision, but then cast
the result to an int, losing bits. A possibly worse example than the
negative one is:
$ git config foo.bar 4g
$ git config --int foo.bar
0
Again, that is what git's internal code is seeing. And that is why
keeping the range check for git-config has value: it lets you see what
git would see internally.
> When .git/config is shared on two different boxes (think: NFS), the
> size of "int" might be different between them, so the logic to produce
> such a warning may have to explicitly check against int32_t, not
> platform int and say "will not fit in 'int' on some machines".
I don't really see the value in that. You can always write whatever you
like in the config file. The reader is responsible during parsing for
saying "Hey, I am 32-bit and I can't handle this". And we already do
that, and it works fine. So if you have an NFS-shared .git/config, and
you set "pack.deltacachesize" to "4g", a 64-bit machine will do fine
with that, and a 32-bit machine will complain. Which seems like the only
sane thing to do.
There are a few config options that use "unsigned long" that I would
argue should be "off_t" or something (for example,
core.bigFileThreshold, which cannot be more than 4G on a 32-bit machine,
simply because we can't represent the size. On the other hand, there is
probably a ton of stuff that does not work with 4G files on such a
system, because we use unsigned long all over the place inside the
code).
-Peff
next prev parent reply other threads:[~2013-08-21 2:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 22:39 [PATCH 0/2] git-config and large integers Jeff King
2013-08-20 22:42 ` [PATCH 1/2] config: properly range-check integer values Jeff King
2013-08-20 23:07 ` Jonathan Nieder
2013-08-21 2:55 ` Jeff King
2013-08-20 22:44 ` [PATCH 0/2] git-config and large integers Stefan Beller
2013-08-20 22:48 ` Jeff King
2013-08-20 22:47 ` [PATCH 2/2] teach git-config to output " Jeff King
2013-08-20 22:57 ` Jonathan Nieder
2013-08-21 3:00 ` Jeff King
2013-08-21 4:38 ` Jonathan Nieder
2013-08-21 5:00 ` Jeff King
2013-08-21 6:34 ` Jonathan Nieder
2013-08-20 23:06 ` [PATCH 0/2] git-config and " Junio C Hamano
2013-08-20 23:41 ` Junio C Hamano
2013-08-21 2:43 ` Jeff King [this message]
2013-08-21 2:34 ` Jeff King
2013-09-08 8:27 ` [PATCHv2 0/5] " Jeff King
2013-09-08 8:29 ` [PATCH 1/5] config: factor out integer parsing from range checks Jeff King
2013-09-08 8:33 ` [PATCH 2/5] config: properly range-check integer values Jeff King
2013-09-08 8:36 ` [PATCH 3/5] config: set errno in numeric git_parse_* functions Jeff King
2013-09-09 0:36 ` Eric Sunshine
2013-09-09 19:53 ` Jeff King
2013-09-08 8:38 ` [PATCH 4/5] config: make numeric parsing errors more clear Jeff King
2013-09-08 8:40 ` [PATCH 5/5] git-config: always treat --int as 64-bit internally Jeff King
2013-09-09 18:58 ` [PATCHv2 0/5] git-config and large integers 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130821024355.GB25296@sigill.intra.peff.net \
--to=peff@peff.net \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).