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

Re: "git diff" does not show a diff for newly added, binary files

From
Jeff King <peff@peff.net>
Date
Apr 4, 2023, 15:39 UTC
Message-ID
<20230404153918.GB160693@coredump.intra.peff.net>
In-Reply-To
<3473764.PTxrJRyG3s@earendil>
On Tue, Apr 04, 2023 at 11:58:38AM +0200, Thorsten Otto wrote:
Show 18 quoted lines
> "git diff" does not show a diff for newly added, binary files
> 
> What did you do before the bug happened? (Steps to reproduce your issue)
> 
> $ git init .
> $ touch a
> $ git add a
> $ git commit -m "first commit"
> $ dd if=/dev/zero of=b count=1
> $ git add b
> $ echo hello > c
> $ git add c
> $ git diff --cached
> 
> What did you expect to happen? (Expected behavior)
> 
> I expected a binary diff for the new file, just like it is done
> when comparing two different, already committed revisions.

I responded elsewhere in the thread mentioning "git diff --binary", but note this part of the report is a little misleading. The difference is not showing newly added files versus committed revisions. The difference is between "git diff" and "git format-patch". If you commit the result above and then run:

  git diff HEAD^ HEAD

it will likewise not show the binary patch (unless you specify --binary). Likewise for "git show", etc. I think that format-patch is the only command with binary diffs turned on by default.

-Peff
Previous: Junio C Hamano
Message 10 of 10 in “"git diff" does not show a diff for newly added, binary files”
  1. Thorsten OttoApr 4, 2023
  2. Kristoffer HaugsbakkApr 4, 2023
  3. Thorsten OttoApr 4, 2023
  4. Kristoffer HaugsbakkApr 4, 2023
  5. Thorsten OttoApr 4, 2023
  6. Kristoffer HaugsbakkApr 4, 2023
  7. Jeff KingApr 4, 2023
  8. Junio C HamanoApr 4, 2023
  9. Junio C HamanoApr 4, 2023
  10. Jeff KingApr 4, 2023

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.