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

Re: [git-for-windows] How is detected binary files?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 27, 2015, 14:14 UTC
Message-ID
<alpine.DEB.1.00.1511271510520.1686@s15462909.onlinehome-server.info>
In-Reply-To
<487b881f-9e3e-4d22-ba1e-af3beeaccd6e@googlegroups.com>
Hi Andrzej,
On Wed, 25 Nov 2015, Andrzej Borucki wrote:
Show 5 quoted lines
> How git detects that file is binary? This must be safe because it not 
> allowed to change line breaks in binary files. 
> Binary files can contain byte 0 (zero), but:
> - 16 bit UTF also can contain zero
> - short binary files can not contain zero

It would probably be better to direct this question to the general Git mailing list (you reached the Git for Windows one, and this issue is not specific to Windows).

To answer your question, a NUL byte within the first 8000 bytes is indeed considered as an indicator for binary files.

If you use UTF-16, you will need to mark your files as such explicitly (Git does not handle UTF-16 internally).

As to short binary files, you will also have to mark those explicitly.

Ciao, Johannes

Next: Jeff King
Message 1 of 2 in “Re: [git-for-windows] How is detected binary files?”
  1. Johannes SchindelinNov 27, 2015
  2. Jeff KingDec 2, 2015

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.