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

Re: [PATCH] Show binary file size change in diff --stat

From
RDRogan Dawes <lists@dawes.za.net>
Date
Apr 4, 2007, 16:00 UTC
Message-ID
<4613CB87.2090306@dawes.za.net>
In-Reply-To
<BAFDAA7B-60EC-44FD-8DAA-EB2F9C835F51@adacore.com>
Geert Bosch wrote:
Show 22 quoted lines
> 
> On Apr 4, 2007, at 09:34, Rogan Dawes wrote:
> 
>> For binary files, it would be consistent to show the number of bytes 
>> added/deleted. I have not investigated the output format for the 
>> libxdiff binary patch format, but hopefully it would not be too 
>> difficult to calculate the deletions and additions.
> 
> For binary files it is impractical to do insert/delete type of differences.
> For text files, treating lines as indivisible entities to insert/delete
> make some sense. For binary files, you'd have to use some arbitrary
> context-defined breakpoints and then go from there. The result would
> be some very complicated and unclear algorithm that would have no use
> in the real world.
> 
> Many binary files, such as an images, waveforms or virtually any compressed
> stream, can change in a way that changes all bytes in the file, while
> the changes in the displayed image or the uncompressed stream are
> imperceptible or absent. Guessing semantic differences between binary
> blobs is hopeless and subjective, while differences in size are fact.
> 
>   -Geert

As per my mail to Andy, we *already* do this for text files. e.g. wrap an XML document in an additional tag, and update the indentation to match.

The semantic change is minimal (perhaps 2 new lines), but the reported change reflects n lines deleted, and n+2 added.

Exactly because we *don't* do any semantic analysis (for text or binary files), we should simply report the number of bytes changed, exactly as we do for text files (reporting number of lines changed). This is _consistent_ with what we do currently for text files.

Note that Andy's apparent preference (to know how the sizes have changed) can still largely be satisfied by this approach.

  somefile.bin  | 1000 -> 1000 bytes
and
  somefile.bin  | 500 bytes removed, 500 bytes added

You can still see that the overall size of the file has not changed, but you get the additional information about how many bytes were actually changed at the same time, which you don't get just showing the sizes.

Rogan
Previous: Geert BoschNext: Andy Parkins
Message 4 of 12 in “Show binary file size change in diff --stat”
  1. Show binary file size change in diff --statAndy Parkins, Apr 4, 2007
  2. Rogan DawesApr 4, 2007
  3. Geert BoschApr 4, 2007
  4. Rogan DawesApr 4, 2007
  5. Andy ParkinsApr 4, 2007
  6. Rogan DawesApr 4, 2007
  7. Johannes SchindelinApr 4, 2007
  8. Rogan DawesApr 4, 2007
  9. Linus TorvaldsApr 4, 2007
  10. Johannes SchindelinApr 4, 2007
  11. Linus TorvaldsApr 4, 2007
  12. Junio C HamanoApr 4, 2007

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.