git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Thorsten Otto <admin@tho-otto.de>
Cc: git@vger.kernel.org
Subject: Re: "git diff" does not show a diff for newly added, binary files
Date: Tue, 04 Apr 2023 08:37:22 -0700	[thread overview]
Message-ID: <xmqqo7o33bgt.fsf@gitster.g> (raw)
In-Reply-To: <3473764.PTxrJRyG3s@earendil> (Thorsten Otto's message of "Tue, 04 Apr 2023 11:58:38 +0200")

Thorsten Otto <admin@tho-otto.de> writes:

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

The command is working as designed, either for newly added ones,
modified ones, or deleted ones.  In your sample output, we can see
"Binary files differ", which is the default "diff" for binary
contents.  It is in line with the way "diff" by other people work.

> What happened instead? (Actual behavior)
>
> The "git diff" command only showed a diff for the text file c, 
> but not for the binary file b:
>
> diff --git a/b b/b
> new file mode 100644
> index 0000000..a64a5a9
> Binary files /dev/null and b/b differ
> diff --git a/c b/c
> new file mode 100644
> index 0000000..ce01362
> --- /dev/null
> +++ b/c
> @@ -0,0 +1 @@
> +hello

As the primary purpose of "git format-patch" is to convey the
content change between pair of states (i.e. change to bring the
state at a particular commit to another state at a commit that is
its child), it implicitly enables the "binary patch" option, but for
"git diff" which is meant to be an interactive browser of changes
for human consumption, the "binary patch" option is off by default.

You can run "git diff --binary".

  parent reply	other threads:[~2023-04-04 15:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04  9:58 "git diff" does not show a diff for newly added, binary files Thorsten Otto
2023-04-04 10:17 ` Kristoffer Haugsbakk
2023-04-04 10:39   ` Thorsten Otto
2023-04-04 10:45     ` Kristoffer Haugsbakk
2023-04-04 11:23       ` Thorsten Otto
2023-04-04 11:29         ` Kristoffer Haugsbakk
2023-04-04 15:36     ` Jeff King
2023-04-04 15:42   ` Junio C Hamano
2023-04-04 15:37 ` Junio C Hamano [this message]
2023-04-04 15:39 ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqo7o33bgt.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=admin@tho-otto.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).