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

Force git diff to create a binary patch?

From
JXJason Xu <jasonx98@gmail.com>
Date
Jul 13, 2020, 04:58 UTC
Message-ID
<CAGPh-qNrjQ5xwbPcfJdBqrqOJQsVpa2hy-XHwN-8rhPPZe4Vpg@mail.gmail.com>
Hello everyone,

Here are two small files with non-ASCII data, yet git diff considers them text instead of binary.

    echo -n -e '\x01\xff\xdf' > bin1
    echo -n -e '\x01\xdf\xff' > bin2
    git diff --binary bin1 bin2
Result:
    diff --git a/bin1 b/bin2
    index 802dc8e..c39b638 100644
    --- a/bin1
    +++ b/bin2
    @@ -1 +1 @@
    -^A<FF><DF>
    \ No newline at end of file
    +^A<DF><FF>
    \ No newline at end of file

I think `--binary` for `git diff` should force the creation of git binary patches if there are any non-printable-ASCII characters, since my understanding is that `--binary` is for safe encoding for email. Otherwise `-a` can be used.

Original post: https://stackoverflow.com/questions/62858327/how-can-i-force-git-diff-to-create-a-git-binary-patch
Thanks
Next: Junio C Hamano
Message 1 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.