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

Re: [PATCH] xdiff-interface.c (buffer_is_binary): Remove buffer size limitation

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 4, 2007, 01:00 UTC
Message-ID
<Pine.LNX.4.64.0712040054280.27959@racer.site>
In-Reply-To
<alpine.LFD.0.9999.0712031559480.8458@woody.linux-foundation.org>
Hi,
On Mon, 3 Dec 2007, Linus Torvalds wrote:
Show 8 quoted lines
> On Tue, 4 Dec 2007, Dmitry V. Levin wrote:
> >
> > Average file size in the linux-2.6.23.9 kernel tree is 10944 bytes,
> 
> Don't do "average" sizes. That's an almost totally meaningless number.
> 
> "Average" makes sense if you have some kind of gaussian distribution or 
> similar.

To enhance on that: Gaussian is symmetric, which cannot be the proper distribution for anything that is non-negative.

I see so many mis-applications of statistics/probability theory in my day job that I cannot resist pointing people to the Poisson distribution here (in whose context "average" actually makes kind of sense).

But back to the problem: if you have a truly binary file, then _every_ byte (absent further information, of course) has a probability of 1/256 of being 0.

Which means that if a file is binary, but is unusual enough to have that property only for half of the first 8192 bytes, you get a probability of 1 - 1 / 256^4096 = 1 - 1 / 2 ^ 32768 that the current test succeeds.

I fail to see how this test can possibly fail for the average case.

So if it fails only for special cases, we are probably (in the common, not the mathematical, sense) better off asking those people encountering them to add git-attributes for the files.

IMHO that is not asking for too much.

Ciao, Dscho

Previous: Linus TorvaldsNext: David Kastrup
Message 6 of 7 in “xdiff-interface.c (buffer_is_binary): Remove buffer size limitation”
  1. xdiff-interface.c (buffer_is_binary): Remove buffer size limitationDmitry V. Levin, Dec 1, 2007
  2. Junio C HamanoDec 1, 2007
  3. Dmitry V. LevinDec 3, 2007
  4. Junio C HamanoDec 3, 2007
  5. Linus TorvaldsDec 4, 2007
  6. Johannes SchindelinDec 4, 2007
  7. David KastrupDec 5, 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.