Skip to content

Commit 37ee62b

Browse files
committed
Merge branch 'jk/diff-driver-binary-doc'
* jk/diff-driver-binary-doc: docs: explain diff.*.binary option
2 parents 4b297df + ab43561 commit 37ee62b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Documentation/gitattributes.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,39 @@ and now produces better output), you can remove the cache
591591
manually with `git update-ref -d refs/notes/textconv/jpg` (where
592592
"jpg" is the name of the diff driver, as in the example above).
593593

594+
Marking files as binary
595+
^^^^^^^^^^^^^^^^^^^^^^^
596+
597+
Git usually guesses correctly whether a blob contains text or binary
598+
data by examining the beginning of the contents. However, sometimes you
599+
may want to override its decision, either because a blob contains binary
600+
data later in the file, or because the content, while technically
601+
composed of text characters, is opaque to a human reader. For example,
602+
many postscript files contain only ascii characters, but produce noisy
603+
and meaningless diffs.
604+
605+
The simplest way to mark a file as binary is to unset the diff
606+
attribute in the `.gitattributes` file:
607+
608+
------------------------
609+
*.ps -diff
610+
------------------------
611+
612+
This will cause git to generate `Binary files differ` (or a binary
613+
patch, if binary patches are enabled) instead of a regular diff.
614+
615+
However, one may also want to specify other diff driver attributes. For
616+
example, you might want to use `textconv` to convert postscript files to
617+
an ascii representation for human viewing, but otherwise treat them as
618+
binary files. You cannot specify both `-diff` and `diff=ps` attributes.
619+
The solution is to use the `diff.*.binary` config option:
620+
621+
------------------------
622+
[diff "ps"]
623+
textconv = ps2ascii
624+
binary = true
625+
------------------------
626+
594627
Performing a three-way merge
595628
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
596629

0 commit comments

Comments
 (0)