From: Jeff King <peff@peff.net>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH] docs: explain diff.*.binary option
Date: Sun, 9 Jan 2011 15:10:04 -0500 [thread overview]
Message-ID: <20110109201003.GA4406@sigill.intra.peff.net> (raw)
In-Reply-To: <vpqr5clsy8g.fsf@bauges.imag.fr>
This was added long ago as part of the userdiff refactoring
for textconv, as internally it made the code simpler and
cleaner. However, there was never a concrete use case for
actually using the config variable.
Now that Matthieu Moy has provided such a use case, it's
easy to explain it using his example.
Signed-off-by: Jeff King <peff@peff.net>
---
On Sun, Jan 09, 2011 at 07:55:43PM +0100, Matthieu Moy wrote:
> Jeff King <peff@peff.net> writes:
>
> > you can get what you want with:
> >
> > echo '*.ps diff=ps' >.gitattributes
> > git config diff.ps.textconv ps2ascii
> > git config diff.ps.binary true
>
> Yes, this works great. Thanks.
>
> Did I miss something, or is this undocumented? I can't find that in
> either man gitattributes or man git-config.
Nope, it was never documented, probably because I never figured out what
it was good for. :)
Documentation/gitattributes.txt | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 22b8582..a282adb 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -591,6 +591,39 @@ and now produces better output), you can remove the cache
manually with `git update-ref -d refs/notes/textconv/jpg` (where
"jpg" is the name of the diff driver, as in the example above).
+Marking files as binary
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Git usually guesses correctly whether a blob contains text or binary
+data by examining the beginning of the contents. However, sometimes you
+may want to override its decision, either because a blob contains binary
+data later in the file, or because the content, while technically
+composed of text characters, is opaque to a human reader. For example,
+many postscript files contain only ascii characters, but produce noisy
+and meaningless diffs.
+
+The simplest way to mark a file as binary is to unset the diff
+attribute in the `.gitattributes` file:
+
+------------------------
+*.ps -diff
+------------------------
+
+This will cause git to generate `Binary files differ` (or a binary
+patch, if binary patches are enabled) instead of a regular diff.
+
+However, one may also want to specify other diff driver attributes. For
+example, you might want to use `textconv` to convert postscript files to
+an ascii representation for human viewing, but otherwise treat them as
+binary files. You cannot specify both `-diff` and `diff=ps` attributes.
+The solution is to use the `diff.*.binary` config option:
+
+------------------------
+[diff "ps"]
+ textconv = ps2ascii
+ binary = true
+------------------------
+
Performing a three-way merge
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
1.7.3.5.4.g0dc52
next prev parent reply other threads:[~2011-01-09 20:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-04 15:50 PostScript files: textconv and "git add -p" Matthieu Moy
2011-01-05 5:18 ` Jeff King
2011-01-09 18:55 ` Matthieu Moy
2011-01-09 20:10 ` Jeff King [this message]
2011-01-09 20:31 ` [PATCH] docs: explain diff.*.binary option Matthieu Moy
2011-01-10 17:59 ` Junio C Hamano
2011-01-11 6:11 ` 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=20110109201003.GA4406@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).