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

Re: Force git diff to create a binary patch?

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 14, 2020, 15:35 UTC
Message-ID
<xmqqv9iqkt2d.fsf@gitster.c.googlers.com>
In-Reply-To
<CAGPh-qPH+gGYHCy+rQJvzwr-Vp71UJxwr+w-G9GaV_o40K8P-Q@mail.gmail.com>
Jason Xu <jasonx98@gmail.com> writes:
Show 5 quoted lines
>> The "--binary" option was invented as a way to tell Git to
>> produce something that can be applied, where Git stopped at
>> saying "binary files differ".
>
> Doesn't `--text` already do that? Albeit with whitespace warnings.

I do not think so. --text is about forcing everything to be treated text, so you'll not see binary patches but the patch-looking thing with binary garbage you wrote in the message that started this thread. IOW, that is the opposite of what you want. And I agree that such a "diff -a" output is prone to corruption during transfer (e.g. over e-mail) and a way to tell exactly which paths should be shown as binary patches is a good thing to have.

> That's why I propose better binary file detection, instead of (what I
> understand to be) "make all patches in a patch file GIT binary
> patches, regardless if a file is text".

Oh, I agree that "treat everything as binary and produce binary patch for all paths" is a nonsense option no sane person would want to use. The users are better off exchanging bundles at that point, as such a binary-only patches are unreadable anyway.

There is no "better detection"; the only thing you could get is "better heuristics" and there will always be a limit to what heuristics can do for you.

And that is why you were given gitattributes very early in the discussion ;-) That is the mechanism to tell exactly which paths should be treated as binary.

Previous: Jason Xu
Message 7 of 7 in “Force git diff to create a binary patch?”
  1. Jason XuJul 13, 2020
  2. Junio C HamanoJul 13, 2020
  3. Jason XuJul 14, 2020
  4. Junio C HamanoJul 14, 2020
  5. Junio C HamanoJul 14, 2020
  6. Jason XuJul 14, 2020
  7. Junio C HamanoJul 14, 2020

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.