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

Re: [PATCH] diff: use 64-bit integers for diffstat calculations

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 17, 2010, 17:00 UTC
Message-ID
<7vvdbq2ev7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100417102543.GB23110@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> Yuck, we use "unsigned int" for the actual storage, and then convert to
> a regular "int" in some other places. I think we should just do this:
>
> -- >8 --
> Subject: [PATCH] diff: use 64-bit integers for diffstat calculations
>
> The diffstat "added" and "changed" fields generally store
> line counts; however, for binary files, they store file
> sizes. Since we store and print these values as ints, a
> diffstat on a file larger than 2G can show a negative size.
> Instead, let's explicitly use 64-bit integers.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---

Yes, but we would probably be better off using using uintmax_t for things like this if the quantity a variable represents is not closely tied to external file format (e.g. the offset field of pack idx file), nor the code is only for a particular platform (e.g. compat/win32mmap.c), don't you think?

That is the impression I am getting on the discipline expressed in the current codebase, from browsing the output from "git grep uint64_t".

Previous: Jeff KingNext: Jeff King
Message 4 of 5 in “A bug in git 1.6.5.2 with git log --stat: shows a negative number as a size”
  1. Heikki OrsilaApr 16, 2010
  2. Tomas CarneckyApr 16, 2010
  3. diff: use 64-bit integers for diffstat calculationsJeff King, Apr 17, 2010
  4. Junio C HamanoApr 17, 2010
  5. Jeff KingApr 17, 2010

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.