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