Skip to content

Commit bbb896d

Browse files
committed
gitattributes: -crlf is not binary
The description of crlf attribute incorrectly said that "-crlf" means binary. It is true that for binary files you would want "-crlf", but that is not the same thing. We also have supported attribute macros and via that mechanism a handy "binary" to specify "-crlf -diff" at the same time. It was not documented anywhere as far as I can tell, even though the support was there from the very beginning. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent ed0f47a commit bbb896d

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

Documentation/gitattributes.txt

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ Set::
105105

106106
Unset::
107107

108-
Unsetting the `crlf` attribute on a path is meant to
109-
mark the path as a "binary" file. The path never goes
110-
through line endings conversion upon checkin/checkout.
108+
Unsetting the `crlf` attribute on a path tells git not to
109+
attempt any end-of-line conversion upon checkin or checkout.
111110

112111
Unspecified::
113112

@@ -482,6 +481,41 @@ in the file. E.g. the string `$Format:%H$` will be replaced by the
482481
commit hash.
483482

484483

484+
USING ATTRIBUTE MACROS
485+
----------------------
486+
487+
You do not want any end-of-line conversions applied to, nor textual diffs
488+
produced for, any binary file you track. You would need to specify e.g.
489+
490+
------------
491+
*.jpg -crlf -diff
492+
------------
493+
494+
but that may become cumbersome, when you have many attributes. Using
495+
attribute macros, you can specify groups of attributes set or unset at
496+
the same time. The system knows a built-in attribute macro, `binary`:
497+
498+
------------
499+
*.jpg binary
500+
------------
501+
502+
which is equivalent to the above. Note that the attribute macros can only
503+
be "Set" (see the above example that sets "binary" macro as if it were an
504+
ordinary attribute --- setting it in turn unsets "crlf" and "diff").
505+
506+
507+
DEFINING ATTRIBUTE MACROS
508+
-------------------------
509+
510+
Custom attribute macros can be defined only in the `.gitattributes` file
511+
at the toplevel (i.e. not in any subdirectory). The built-in attribute
512+
macro "binary" is equivalent to:
513+
514+
------------
515+
[attr]binary -diff -crlf
516+
------------
517+
518+
485519
EXAMPLE
486520
-------
487521

0 commit comments

Comments
 (0)